Files
CatServer/patches/net/minecraft/entity/item/EntityArmorStand.java.patch
2018-09-08 11:39:03 +08:00

107 lines
4.3 KiB
Diff

--- ../src-base/minecraft/net/minecraft/entity/item/EntityArmorStand.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityArmorStand.java
@@ -4,6 +4,14 @@
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
+
+import org.bukkit.craftbukkit.CraftEquipmentSlot;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.entity.ArmorStand;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
+import org.bukkit.inventory.EquipmentSlot;
+
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
@@ -68,12 +76,12 @@
public long punchCooldown;
private int disabledSlots;
private boolean wasMarker;
- private Rotations headRotation;
- private Rotations bodyRotation;
- private Rotations leftArmRotation;
- private Rotations rightArmRotation;
- private Rotations leftLegRotation;
- private Rotations rightLegRotation;
+ public Rotations headRotation;
+ public Rotations bodyRotation;
+ public Rotations leftArmRotation;
+ public Rotations rightArmRotation;
+ public Rotations leftLegRotation;
+ public Rotations rightLegRotation;
public EntityArmorStand(World worldIn)
{
@@ -466,6 +474,21 @@
{
if (itemstack != null || (this.disabledSlots & 1 << p_184795_2_.getSlotIndex() + 16) == 0)
{
+ // CraftBukkit start
+ org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemstack);
+ org.bukkit.inventory.ItemStack playerHeldItem = CraftItemStack.asCraftMirror(p_184795_3_);
+
+ Player bukkitPlayer = (Player) player.getBukkitEntity();
+ ArmorStand self = (ArmorStand) this.getBukkitEntity();
+
+ EquipmentSlot slot = CraftEquipmentSlot.getSlot(p_184795_2_);
+ PlayerArmorStandManipulateEvent armorStandManipulateEvent = new PlayerArmorStandManipulateEvent(bukkitPlayer, self, playerHeldItem, armorStandItem, slot);
+ this.worldObj.getServer().getPluginManager().callEvent(armorStandManipulateEvent);
+
+ if (armorStandManipulateEvent.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
if (player.capabilities.isCreativeMode && (itemstack == null || itemstack.getItem() == Item.getItemFromBlock(Blocks.AIR)) && p_184795_3_ != null)
{
ItemStack itemstack2 = p_184795_3_.copy();
@@ -493,6 +516,11 @@
public boolean attackEntityFrom(DamageSource source, float amount)
{
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, source, amount)) {
+ return false;
+ }
+ // CraftBukkit end
if (!this.worldObj.isRemote && !this.isDead)
{
if (DamageSource.outOfWorld.equals(source))
@@ -811,7 +839,7 @@
return this.isInvisible();
}
- private void setSmall(boolean small)
+ public void setSmall(boolean small)
{
this.dataManager.set(STATUS, Byte.valueOf(this.setBit(((Byte)this.dataManager.get(STATUS)).byteValue(), 1, small)));
}
@@ -821,7 +849,7 @@
return (((Byte)this.dataManager.get(STATUS)).byteValue() & 1) != 0;
}
- private void setShowArms(boolean showArms)
+ public void setShowArms(boolean showArms)
{
this.dataManager.set(STATUS, Byte.valueOf(this.setBit(((Byte)this.dataManager.get(STATUS)).byteValue(), 4, showArms)));
}
@@ -831,7 +859,7 @@
return (((Byte)this.dataManager.get(STATUS)).byteValue() & 4) != 0;
}
- private void setNoBasePlate(boolean noBasePlate)
+ public void setNoBasePlate(boolean noBasePlate)
{
this.dataManager.set(STATUS, Byte.valueOf(this.setBit(((Byte)this.dataManager.get(STATUS)).byteValue(), 8, noBasePlate)));
}
@@ -841,7 +869,7 @@
return (((Byte)this.dataManager.get(STATUS)).byteValue() & 8) != 0;
}
- private void setMarker(boolean marker)
+ public void setMarker(boolean marker)
{
this.dataManager.set(STATUS, Byte.valueOf(this.setBit(((Byte)this.dataManager.get(STATUS)).byteValue(), 16, marker)));
}