Fix EntityEquipment for armor stands and redirect the getters/setters to use it

This commit is contained in:
Thinkofdeath 2014-12-21 23:26:42 +00:00
parent dbdf6cacbf
commit 40aaa31c49
2 changed files with 12 additions and 18 deletions

View File

@ -3,7 +3,6 @@ package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityArmorStand;
import net.minecraft.server.Vector3f;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
@ -11,12 +10,6 @@ import org.bukkit.util.EulerAngle;
public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
private static final int HAND = 0;
private static final int FEET = 1;
private static final int LEGS = 2;
private static final int CHEST = 3;
private static final int HEAD = 4;
public CraftArmorStand(CraftServer server, EntityArmorStand entity) {
super(server, entity);
}
@ -38,52 +31,52 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
@Override
public ItemStack getItemInHand() {
return CraftItemStack.asBukkitCopy(getHandle().getEquipment(HAND));
return getEquipment().getItemInHand();
}
@Override
public void setItemInHand(ItemStack item) {
getHandle().setEquipment(HAND, CraftItemStack.asNMSCopy(item));
getEquipment().setItemInHand(item);
}
@Override
public ItemStack getBoots() {
return CraftItemStack.asBukkitCopy(getHandle().getEquipment(FEET));
return getEquipment().getBoots();
}
@Override
public void setBoots(ItemStack item) {
getHandle().setEquipment(FEET, CraftItemStack.asNMSCopy(item));
getEquipment().setBoots(item);
}
@Override
public ItemStack getLeggings() {
return CraftItemStack.asBukkitCopy(getHandle().getEquipment(LEGS));
return getEquipment().getLeggings();
}
@Override
public void setLeggings(ItemStack item) {
getHandle().setEquipment(LEGS, CraftItemStack.asNMSCopy(item));
getEquipment().setLeggings(item);
}
@Override
public ItemStack getChestplate() {
return CraftItemStack.asBukkitCopy(getHandle().getEquipment(CHEST));
return getEquipment().getChestplate();
}
@Override
public void setChestplate(ItemStack item) {
getHandle().setEquipment(CHEST, CraftItemStack.asNMSCopy(item));
getEquipment().setChestplate(item);
}
@Override
public ItemStack getHelmet() {
return CraftItemStack.asBukkitCopy(getHandle().getEquipment(HEAD));
return getEquipment().getHelmet();
}
@Override
public void setHelmet(ItemStack item) {
getHandle().setEquipment(HEAD, CraftItemStack.asNMSCopy(item));
getEquipment().setHelmet(item);
}
@Override

View File

@ -7,6 +7,7 @@ import java.util.Iterator;
import java.util.List;
import net.minecraft.server.DamageSource;
import net.minecraft.server.EntityArmorStand;
import net.minecraft.server.EntityArrow;
import net.minecraft.server.EntityEgg;
import net.minecraft.server.EntityEnderDragon;
@ -67,7 +68,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public CraftLivingEntity(final CraftServer server, final EntityLiving entity) {
super(server, entity);
if (entity instanceof EntityInsentient) {
if (entity instanceof EntityInsentient || entity instanceof EntityArmorStand) {
equipment = new CraftEntityEquipment(this);
}
}