Fixed disguises interfering with player movement when they appear

This commit is contained in:
libraryaddict 2014-01-29 15:57:17 +13:00
parent b63df3943f
commit 6c6d6c6fe2

View File

@ -409,6 +409,7 @@ public class DisguiseUtilities {
}); });
return; return;
} }
int fakeId = selfDisguisesIds.get(player.getEntityId());
// Add himself to his own entity tracker // Add himself to his own entity tracker
((HashSet) entityTrackerEntry.getClass().getField("trackedPlayers").get(entityTrackerEntry)).add(ReflectionManager ((HashSet) entityTrackerEntry.getClass().getField("trackedPlayers").get(entityTrackerEntry)).add(ReflectionManager
.getNmsEntity(player)); .getNmsEntity(player));
@ -418,8 +419,8 @@ public class DisguiseUtilities {
.createPacket(player)); .createPacket(player));
manager.sendServerPacket( manager.sendServerPacket(
player, player,
manager.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, player.getEntityId(), manager.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, fakeId,
WrappedDataWatcher.getEntityWatcher(player), true).createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true).createPacket(fakeId,
WrappedDataWatcher.getEntityWatcher(player), true)); WrappedDataWatcher.getEntityWatcher(player), true));
boolean isMoving = false; boolean isMoving = false;
@ -435,9 +436,9 @@ public class DisguiseUtilities {
Vector velocity = player.getVelocity(); Vector velocity = player.getVelocity();
manager.sendServerPacket( manager.sendServerPacket(
player, player,
manager.createPacketConstructor(PacketType.Play.Server.ENTITY_VELOCITY, player.getEntityId(), manager.createPacketConstructor(PacketType.Play.Server.ENTITY_VELOCITY, fakeId, velocity.getX(),
velocity.getX(), velocity.getY(), velocity.getZ()).createPacket(player.getEntityId(), velocity.getY(), velocity.getZ()).createPacket(fakeId, velocity.getX(), velocity.getY(),
velocity.getX(), velocity.getY(), velocity.getZ())); velocity.getZ()));
} }
// Why the hell would he even need this. Meh. // Why the hell would he even need this. Meh.
@ -461,10 +462,9 @@ public class DisguiseUtilities {
} }
if (item != null && item.getType() != Material.AIR) { if (item != null && item.getType() != Material.AIR) {
manager.sendServerPacket( manager.sendServerPacket(player,
player, manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EQUIPMENT, fakeId, i, item)
manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EQUIPMENT, player.getEntityId(), i, .createPacket(fakeId, i, item));
item).createPacket(player.getEntityId(), i, item));
} }
} }
Location loc = player.getLocation(); Location loc = player.getLocation();
@ -480,9 +480,10 @@ public class DisguiseUtilities {
Iterator iterator = player.getActivePotionEffects().iterator(); Iterator iterator = player.getActivePotionEffects().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
PotionEffect potionEffect = (PotionEffect) iterator.next(); PotionEffect potionEffect = (PotionEffect) iterator.next();
manager.sendServerPacket(player, manager.sendServerPacket(
manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EFFECT, player.getEntityId(), potionEffect) player,
.createPacket(player.getEntityId(), potionEffect)); manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EFFECT, fakeId, potionEffect).createPacket(
fakeId, potionEffect));
} }
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();