2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/item/ItemArmor.java
|
|
|
|
+++ b/net/minecraft/world/item/ItemArmor.java
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -28,6 +28,11 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.level.block.BlockDispenser;
|
|
|
|
import net.minecraft.world.phys.AxisAlignedBB;
|
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
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
private static final UUID[] ARMOR_MODIFIER_UUID_PER_SLOT = 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")};
|
2021-09-26 00:24:33 +02:00
|
|
|
@@ -54,8 +59,34 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
EntityLiving entityliving = (EntityLiving) list.get(0);
|
2021-06-11 07:00:00 +02:00
|
|
|
EnumItemSlot enumitemslot = EntityInsentient.getEquipmentSlotForItem(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
|
|
|
+
|
2019-06-02 11:49:41 +02: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) {
|
2021-06-11 13:33:49 +02:00
|
|
|
+ world.getCraftServer().getPluginManager().callEvent(event);
|
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.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());
|
2021-06-11 07:00:00 +02:00
|
|
|
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
|
|
|
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != ItemArmor.DISPENSE_ITEM_BEHAVIOR) {
|
2018-07-15 02:00:00 +02:00
|
|
|
+ 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
|
|
|
+ }
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2021-09-26 00:24:33 +02:00
|
|
|
- entityliving.setSlot(enumitemslot, itemstack1);
|
|
|
|
+ entityliving.setSlot(enumitemslot, CraftItemStack.asNMSCopy(event.getItem()));
|
|
|
|
+ // CraftBukkit end
|
2016-11-17 02:41:03 +01:00
|
|
|
if (entityliving instanceof EntityInsentient) {
|
2021-09-26 00:24:33 +02:00
|
|
|
((EntityInsentient) entityliving).a(enumitemslot, 2.0F);
|
|
|
|
((EntityInsentient) entityliving).setPersistent();
|