From 112dd25d71532d55b69f1a69bbb8623399d9f9ee Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 17 Mar 2023 19:28:51 +0000 Subject: [PATCH] Fixed players being unable to equip items with binding curse from trinket slots in creative mode https://github.com/emilyploszaj/trinkets/issues/237 --- .../minelittlepony/unicopia/trinkets/UnicopiaTrinket.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/minelittlepony/unicopia/trinkets/UnicopiaTrinket.java b/src/main/java/com/minelittlepony/unicopia/trinkets/UnicopiaTrinket.java index 4cbf1f16..28b5967d 100644 --- a/src/main/java/com/minelittlepony/unicopia/trinkets/UnicopiaTrinket.java +++ b/src/main/java/com/minelittlepony/unicopia/trinkets/UnicopiaTrinket.java @@ -7,11 +7,13 @@ import com.minelittlepony.unicopia.item.FriendshipBraceletItem; import com.minelittlepony.unicopia.item.WearableItem; import dev.emi.trinkets.api.*; +import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.attribute.EntityAttribute; import net.minecraft.entity.attribute.EntityAttributeModifier; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.sound.SoundEvent; public class UnicopiaTrinket implements Trinket { @@ -49,6 +51,11 @@ public class UnicopiaTrinket implements Trinket { return slot.inventory().getStack(slot.index()).isEmpty(); } + @Override + public boolean canUnequip(ItemStack stack, SlotReference slot, LivingEntity entity) { + return !(EnchantmentHelper.hasBindingCurse(stack) && EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.test(entity)); + } + @Override public void tick(ItemStack stack, SlotReference slot, LivingEntity entity) { item.inventoryTick(stack, entity.world, entity, slot.index(), false);