2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ItemArmor.java
+++ b/net/minecraft/server/ItemArmor.java
2018-07-15 02:00:00 +02:00
@@ -4,6 +4,11 @@
2015-02-26 23:41:06 +01:00
import java.util.List;
2016-02-29 22:32:46 +01:00
import java.util.UUID;
2015-02-26 23:41:06 +01:00
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
2018-09-08 06:15:33 +02:00
+import org.bukkit.event.block.BlockDispenseArmorEvent;
2015-02-26 23:41:06 +01:00
+// CraftBukkit end
+
public class ItemArmor extends Item {
2018-08-26 04:00:00 +02:00
private static final UUID[] k = new UUID[] { UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")};
2018-07-15 02:00:00 +02:00
@@ -29,6 +34,32 @@
2016-02-29 22:32:46 +01:00
EntityLiving entityliving = (EntityLiving) list.get(0);
2018-07-15 02:00:00 +02:00
EnumItemSlot enumitemslot = EntityInsentient.e(itemstack);
2016-11-17 02:41:03 +01:00
ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
2016-02-29 22:32:46 +01:00
+ // CraftBukkit start
+ World world = isourceblock.getWorld();
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
2015-02-26 23:41:06 +01:00
+
2018-09-08 06:15:33 +02:00
+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityliving.bukkitEntity);
2016-02-29 22:32:46 +01:00
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
2015-02-26 23:41:06 +01:00
+
2016-02-29 22:32:46 +01:00
+ if (event.isCancelled()) {
2016-11-17 02:41:03 +01:00
+ itemstack.add(1);
2016-02-29 22:32:46 +01:00
+ return itemstack;
+ }
2015-02-26 23:41:06 +01:00
+
2016-02-29 22:32:46 +01:00
+ if (!event.getItem().equals(craftItem)) {
2016-11-17 02:41:03 +01:00
+ itemstack.add(1);
2016-02-29 22:32:46 +01:00
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
2018-07-15 02:00:00 +02:00
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != ItemArmor.a) {
+ idispensebehavior.dispense(isourceblock, eventStack);
2015-02-26 23:41:06 +01:00
+ return itemstack;
+ }
2016-02-29 22:32:46 +01:00
+ }
+ // CraftBukkit end
2015-02-26 23:41:06 +01:00
2016-02-29 22:32:46 +01:00
entityliving.setSlot(enumitemslot, itemstack1);
2016-11-17 02:41:03 +01:00
if (entityliving instanceof EntityInsentient) {