Fixed players being unable to equip items with binding curse from trinket slots in creative mode

https://github.com/emilyploszaj/trinkets/issues/237
This commit is contained in:
Sollace 2023-03-17 19:28:51 +00:00
parent a163686b3a
commit 112dd25d71

View file

@ -7,11 +7,13 @@ import com.minelittlepony.unicopia.item.FriendshipBraceletItem;
import com.minelittlepony.unicopia.item.WearableItem; import com.minelittlepony.unicopia.item.WearableItem;
import dev.emi.trinkets.api.*; import dev.emi.trinkets.api.*;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.attribute.EntityAttribute; import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeModifier; import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvent;
public class UnicopiaTrinket implements Trinket { public class UnicopiaTrinket implements Trinket {
@ -49,6 +51,11 @@ public class UnicopiaTrinket implements Trinket {
return slot.inventory().getStack(slot.index()).isEmpty(); 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 @Override
public void tick(ItemStack stack, SlotReference slot, LivingEntity entity) { public void tick(ItemStack stack, SlotReference slot, LivingEntity entity) {
item.inventoryTick(stack, entity.world, entity, slot.index(), false); item.inventoryTick(stack, entity.world, entity, slot.index(), false);