Trinkets (Fabric)

Trinkets (Fabric)

22M Downloads

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

Sollace opened this issue ยท 0 comments

commented

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