aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/og/net/minecraft/world/item/ItemArmor.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/og/net/minecraft/world/item/ItemArmor.patch')
-rw-r--r--patch-remap/og/net/minecraft/world/item/ItemArmor.patch51
1 files changed, 51 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/world/item/ItemArmor.patch b/patch-remap/og/net/minecraft/world/item/ItemArmor.patch
new file mode 100644
index 0000000000..4b18f9463e
--- /dev/null
+++ b/patch-remap/og/net/minecraft/world/item/ItemArmor.patch
@@ -0,0 +1,51 @@
+--- a/net/minecraft/world/item/ItemArmor.java
++++ b/net/minecraft/world/item/ItemArmor.java
+@@ -27,6 +27,12 @@
+ import net.minecraft.world.level.block.BlockDispenser;
+ import net.minecraft.world.phys.AxisAlignedBB;
+
++// CraftBukkit start
++import org.bukkit.craftbukkit.block.CraftBlock;
++import org.bukkit.craftbukkit.inventory.CraftItemStack;
++import org.bukkit.event.block.BlockDispenseArmorEvent;
++// CraftBukkit end
++
+ public class ItemArmor extends Item implements Equipable {
+
+ private static final EnumMap<ItemArmor.a, UUID> ARMOR_MODIFIER_UUID_PER_TYPE = (EnumMap) SystemUtils.make(new EnumMap(ItemArmor.a.class), (enummap) -> {
+@@ -58,8 +64,34 @@
+ EntityLiving entityliving = (EntityLiving) list.get(0);
+ EnumItemSlot enumitemslot = EntityInsentient.getEquipmentSlotForItem(itemstack);
+ ItemStack itemstack1 = itemstack.split(1);
++ // CraftBukkit start
++ World world = sourceblock.level();
++ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos());
++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+- entityliving.setItemSlot(enumitemslot, itemstack1);
++ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityliving.getBukkitEntity());
++ if (!BlockDispenser.eventFired) {
++ world.getCraftServer().getPluginManager().callEvent(event);
++ }
++
++ if (event.isCancelled()) {
++ itemstack.grow(1);
++ return false;
++ }
++
++ if (!event.getItem().equals(craftItem)) {
++ itemstack.grow(1);
++ // Chain to handler for new item
++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != ItemArmor.DISPENSE_ITEM_BEHAVIOR) {
++ idispensebehavior.dispense(sourceblock, eventStack);
++ return true;
++ }
++ }
++
++ entityliving.setItemSlot(enumitemslot, CraftItemStack.asNMSCopy(event.getItem()));
++ // CraftBukkit end
+ if (entityliving instanceof EntityInsentient) {
+ ((EntityInsentient) entityliving).setDropChance(enumitemslot, 2.0F);
+ ((EntityInsentient) entityliving).setPersistenceRequired();