Paper/nms-patches/ItemArmor.patch

48 lines
2.4 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ItemArmor.java
+++ b/net/minecraft/server/ItemArmor.java
2020-06-25 02:00:00 +02:00
@@ -6,6 +6,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
+
2020-06-25 02:00:00 +02:00
public class ItemArmor extends Item implements ItemWearable {
2015-02-26 23:41:06 +01:00
2020-06-25 02:00:00 +02:00
private static final UUID[] j = 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")};
@@ -32,6 +37,32 @@
2016-02-29 22:32:46 +01:00
EntityLiving entityliving = (EntityLiving) list.get(0);
2020-06-25 02:00:00 +02:00
EnumItemSlot enumitemslot = EntityInsentient.j(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
+
+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityliving.getBukkitEntity());
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);
2019-12-10 23:00:00 +01:00
+ return false;
2016-02-29 22:32:46 +01:00
+ }
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);
2019-12-10 23:00:00 +01:00
+ return true;
2015-02-26 23:41:06 +01:00
+ }
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) {