Fix equip packets, again

This commit is contained in:
libraryaddict
2020-02-07 16:30:52 +13:00
parent 1b2085c03f
commit 45996842d9
3 changed files with 79 additions and 21 deletions

View File

@@ -404,16 +404,24 @@ public class PacketHandlerSpawn implements IPacketHandler {
boolean delayedArmor =
DisguiseConfig.isPlayerHideArmor() && (disguise.isPlayerDisguise() && disguisedEntity != observer) &&
disguisedEntity instanceof LivingEntity;
if (delayedArmor) {
packets.setSendArmor(true);
packets.setRemoveMetaAt(7);
}
// This sends the armor packets so that the player isn't naked.
if (DisguiseConfig.isEquipmentPacketsEnabled() || delayedArmor) {
for (EquipmentSlot slot : EquipmentSlot.values()) {
// Get what the disguise wants to show for its armor
ItemStack itemToSend = disguise.getWatcher().getItemStack(slot);
ItemStack itemToSend;
// If the disguise armor isn't visible
if (itemToSend == null || itemToSend.getType() == Material.AIR) {
// If we need to send the natural armor if possible
if (delayedArmor) {
if (delayedArmor) {
itemToSend = new ItemStack(Material.AIR);
} else {
itemToSend = disguise.getWatcher().getItemStack(slot);
// If the disguise armor isn't visible
if (itemToSend == null || itemToSend.getType() != Material.AIR) {
itemToSend = ReflectionManager.getEquipment(slot, disguisedEntity);
// If natural armor isn't sent either
@@ -421,14 +429,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
continue;
}
} else {
// We don't need to send natural armor and disguise armor isn't visible
continue;
}
} else if (!delayedArmor && disguisedEntity instanceof LivingEntity) {
ItemStack item = ReflectionManager.getEquipment(slot, disguisedEntity);
// If the item was going to be sent anyways
if (item != null && item.getType() != Material.AIR) {
// Its air which shouldn't be sent
continue;
}
}
@@ -441,12 +442,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
mods.write(1, ReflectionManager.createEnumItemSlot(slot));
mods.write(2, ReflectionManager.getNmsItem(itemToSend));
if (delayedArmor) {
packets.addDelayedPacket(packet, 7);
packets.setRemoveMetaAt(7);
} else {
packets.addDelayedPacket(packet);
}
packets.addDelayedPacket(packet);
}
}
}