emilyploszaj / trinkets

A data-driven accessory mod and API for Minecraft using Fabric.
https://www.curseforge.com/minecraft/mc-mods/trinkets
MIT License
171 stars 73 forks source link

Creative players cannot unequip items with curse of binding from trinket slots #237

Open Sollace opened 1 year ago

Sollace commented 1 year ago

The normal behaviour in vanilla is that players in creative mode can still unequip armour even when it has curse of binding.

It seems to be an oversight in Trinket#canUnequip where the method does not check if the wearer is a creative mode player.

    /**
     * Determines whether an entity can unequip a trinket
     *
     * @param stack The stack being unequipped
     * @param slot The slot the stack is being unequipped from
     * @param entity The entity that is unequipping the stack
     * @return Whether the stack can be unequipped
     */
    default boolean canUnequip(ItemStack stack, SlotReference slot, LivingEntity entity) {
        return !EnchantmentHelper.hasBindingCurse(stack);
    }

This is the fix I'm implementing in my subclass:

    @Override
    public boolean canUnequip(ItemStack stack, SlotReference slot, LivingEntity entity) {
        return !(EnchantmentHelper.hasBindingCurse(stack) && EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.test(entity));
    }

And a reference to vanilla to show that this is the intended behaviour:

image