BackSlotAddon

BackSlotAddon

2M Downloads

Belt lantern dynamic lighting

Venaf opened this issue ยท 4 comments

commented

Feature request: Could this be made compatible with LambDynamicLights? There's explicitly a configuration option to have a belt lantern and having it work with LDL would be amazing.

commented

I agree, otherwise putting a lantern in your back slot seems pretty pointless.

commented

Talked to the dev of it and there is no API for it + I don't use a slot lib which might have been compatible
I don't know what will happen in the future tho

commented

Thought the same and was able to make this mod compatible with LambDynamicLights in my fork by adding a mixin like this:

@Mixin(Entity.class)
public class EntityMixin {

    @Inject(method = "getItemsEquipped", at = @At("RETURN"), cancellable = true)
    public void getItemsEquippedWithBackSlotItems(CallbackInfoReturnable<Iterable<ItemStack>> cir) {
        Entity self = (Entity) (Object) this;
        if (self instanceof PlayerEntity) {
            PlayerEntity playerEntity = (PlayerEntity) self;
            ItemStack backSlotStack = playerEntity.getInventory().getStack(41);
            ItemStack beltSlotStack = playerEntity.getInventory().getStack(42);
            Iterable<ItemStack> equippedItems = cir.getReturnValue();
            Iterable<ItemStack> equippedBackSlotItems = Arrays.asList(backSlotStack, beltSlotStack);
            cir.setReturnValue(Iterables.concat(equippedItems, equippedBackSlotItems));
        }
    }

}

which makes LambDynamicLights able to recognize that player is equipped with an light emitting item in here.

But not sure whether this modification should only be applied to this addon or should go into the main mod,
which depends on a decision for the question that whether items in back/belts slots should also be considered as items equipped in general cases or not.

commented

Merged the PR, so in the next update this feature be enabled, by elbakramer :)