aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/ArmorItem.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/ArmorItem.java.patch')
-rw-r--r--patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/ArmorItem.java.patch55
1 files changed, 55 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/ArmorItem.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/ArmorItem.java.patch
new file mode 100644
index 0000000000..3d4e9cf80c
--- /dev/null
+++ b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/ArmorItem.java.patch
@@ -0,0 +1,55 @@
+--- a/net/minecraft/world/item/ArmorItem.java
++++ b/net/minecraft/world/item/ArmorItem.java
+@@ -26,6 +26,11 @@
+ import net.minecraft.world.level.Level;
+ import net.minecraft.world.level.block.DispenserBlock;
+ import net.minecraft.world.phys.AABB;
++// CraftBukkit start
++import org.bukkit.craftbukkit.block.CraftBlock;
++import org.bukkit.craftbukkit.inventory.CraftItemStack;
++import org.bukkit.event.block.BlockDispenseArmorEvent;
++// CraftBukkit end
+
+ public class ArmorItem extends Item implements Equipable {
+
+@@ -59,6 +63,10 @@
+ LivingEntity livingentity = (LivingEntity) list.get(0);
+ EquipmentSlot equipmentslot = Mob.getEquipmentSlotForItem(itemstack);
+ ItemStack itemstack1 = itemstack.split(1);
++ // CraftBukkit start
++ Level world = sourceblock.level();
++ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos());
++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ livingentity.setItemSlot(equipmentslot, itemstack1);
+ if (livingentity instanceof Mob) {
+@@ -66,6 +73,29 @@
+ ((Mob) livingentity).setPersistenceRequired();
+ }
+
++ 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());
++ DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem());
++ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != ArmorItem.DISPENSE_ITEM_BEHAVIOR) {
++ idispensebehavior.dispense(sourceblock, eventStack);
++ return true;
++ }
++ }
++
++ entityliving.setItemSlot(enumitemslot, CraftItemStack.asNMSCopy(event.getItem()));
++ // CraftBukkit end
++ if (entityliving instanceof Mob) {
++ ((Mob) entityliving).setDropChance(enumitemslot, 2.0F);
++ ((Mob) entityliving).setPersistenceRequired();
++ }
++
+ return true;
+ }
+ }