From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Sun, 25 Aug 2019 00:09:52 -0500 Subject: [PATCH] Dispenser curse of binding protection diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java index cc6148404f139464cc2f4f4fc7d5a0b45cb4929e..f444b36b4fddce06aaafabe3cfef463f173969ce 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -4599,6 +4599,12 @@ public abstract class LivingEntity extends Entity implements Attackable { return EquipmentSlot.MAINHAND; } + // Purpur start - Dispenser curse of binding protection + public @Nullable EquipmentSlot getEquipmentSlotForDispenserItem(ItemStack itemstack) { + return EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.BINDING_CURSE, itemstack) > 0 ? null : this.getEquipmentSlotForItem(itemstack); + } + // Purpur end - Dispenser curse of binding protection + private static SlotAccess createEquipmentSlotAccess(LivingEntity entity, EquipmentSlot slot) { return slot != EquipmentSlot.HEAD && slot != EquipmentSlot.MAINHAND && slot != EquipmentSlot.OFFHAND ? SlotAccess.forEquipmentSlot(entity, slot, (itemstack) -> { return itemstack.isEmpty() || entity.getEquipmentSlotForItem(itemstack) == slot; diff --git a/src/main/java/net/minecraft/world/item/ArmorItem.java b/src/main/java/net/minecraft/world/item/ArmorItem.java index 647a4601deace52f8d855f512a73671f82b4762a..d05b1e129eee07434d162e1b949fd5633418ef66 100644 --- a/src/main/java/net/minecraft/world/item/ArmorItem.java +++ b/src/main/java/net/minecraft/world/item/ArmorItem.java @@ -60,7 +60,7 @@ public class ArmorItem extends Item implements Equipable { return false; } else { LivingEntity entityliving = (LivingEntity) list.get(0); - EquipmentSlot enumitemslot = entityliving.getEquipmentSlotForItem(armor); + EquipmentSlot enumitemslot = pointer.level().purpurConfig.dispenserApplyCursedArmor ? entityliving.getEquipmentSlotForItem(armor) : entityliving.getEquipmentSlotForDispenserItem(armor); if (enumitemslot == null) return false; // Purpur - Dispenser curse of binding protection ItemStack itemstack1 = armor.copyWithCount(1); // Paper - shrink below and single item in event // CraftBukkit start Level world = pointer.level(); diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java index ed8f3c606984f83b77ca96cbfc8bcd454ad63ff8..2a301dc07863320ed3e57c9bd0d4ee5a16c9cbaf 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -221,6 +221,11 @@ public class PurpurWorldConfig { }); } + public boolean dispenserApplyCursedArmor = true; + private void dispenserSettings() { + dispenserApplyCursedArmor = getBoolean("blocks.dispenser.apply-cursed-to-armor-slots", dispenserApplyCursedArmor); + } + public boolean farmlandGetsMoistFromBelow = false; private void farmlandSettings() { farmlandGetsMoistFromBelow = getBoolean("blocks.farmland.gets-moist-from-below", farmlandGetsMoistFromBelow);