Fixed armor helmet not appearing if you have no helmet and are holding a item

This commit is contained in:
libraryaddict 2013-11-30 23:09:29 +13:00
parent c63a08eca4
commit 857669fa86
2 changed files with 14 additions and 10 deletions

View File

@ -25,6 +25,7 @@ import me.libraryaddict.disguise.utilities.ReflectionManager;
public class FlagWatcher {
public enum SlotType {
BOOTS(0), CHESTPLATE(2), HELD_ITEM(4), HELMET(3), LEGGINGS(1);
// The ints is for bukkit. Not nms slots.
private int slotNo = 0;
private SlotType(int no) {

View File

@ -130,23 +130,26 @@ public class PacketsManager {
disguise.setEntity(disguisedEntity);
Object nmsEntity = ReflectionManager.getNmsEntity(disguisedEntity);
ArrayList<PacketContainer> packets = new ArrayList<PacketContainer>();
for (int i = 0; i < 5; i++) {
int slot = i - 1;
if (slot < 0)
slot = 4;
org.bukkit.inventory.ItemStack itemstack = disguise.getWatcher().getItemStack(slot);
// This sends the armor packets so that the player isn't naked.
for (int nmsSlot = 0; nmsSlot < 5; nmsSlot++) {
int armorSlot = nmsSlot - 1;
if (armorSlot < 0)
armorSlot = 4;
org.bukkit.inventory.ItemStack itemstack = disguise.getWatcher().getItemStack(armorSlot);
if (itemstack != null && itemstack.getTypeId() != 0) {
ItemStack item = null;
if (disguisedEntity instanceof LivingEntity)
if (i != 4)
item = ((LivingEntity) disguisedEntity).getEquipment().getArmorContents()[i];
else
if (disguisedEntity instanceof LivingEntity) {
if (nmsSlot == 0) {
item = ((LivingEntity) disguisedEntity).getEquipment().getItemInHand();
} else {
item = ((LivingEntity) disguisedEntity).getEquipment().getArmorContents()[armorSlot];
}
}
if (item == null || item.getType() == Material.AIR) {
PacketContainer packet = new PacketContainer(Packets.Server.ENTITY_EQUIPMENT);
StructureModifier<Object> mods = packet.getModifier();
mods.write(0, disguisedEntity.getEntityId());
mods.write(1, i);
mods.write(1, nmsSlot);
mods.write(2, ReflectionManager.getNmsItem(itemstack));
packets.add(packet);
}