diff --git a/pom.xml b/pom.xml index d66e85a2..65d9cd77 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 LibsDisguises LibsDisguises - v3.4 + 3.4 src clean package diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java b/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java index 49a88e1b..7a775039 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java @@ -21,7 +21,7 @@ import org.bukkit.entity.Player; public class Disguise { protected DisguiseType disguiseType; - private Entity entity; + private Entity entity = null; private FlagWatcher watcher; protected Disguise(DisguiseType newType) { @@ -40,6 +40,8 @@ public class Disguise { EntityLiving entityLiving = ((MobDisguise) this).getEntityLiving(((CraftPlayer) p).getHandle().world, p.getLocation(), p.getEntityId()); spawnPacket = new Packet24MobSpawn(entityLiving); + if (getType() == DisguiseType.ENDER_DRAGON) + ((Packet24MobSpawn) spawnPacket).i -= 128; } else if (getType().isMisc()) { @@ -52,6 +54,8 @@ public class Disguise { spawnPacket = new Packet23VehicleSpawn(entity, getType().getEntityId(), ((MiscDisguise) this).getId()); } else spawnPacket = new Packet23VehicleSpawn(entity, getType().getEntityId()); + ((Packet23VehicleSpawn) spawnPacket).i += 64; + } else if (getType().isPlayer()) { EntityHuman entityHuman = ((CraftPlayer) p).getHandle(); @@ -65,6 +69,7 @@ public class Disguise { public Entity getEntity(World world, Location loc, int entityId) { if (entity != null) { entity.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); + entity.id = entityId; return entity; } try { diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java index 9fc4ad92..19417bdf 100644 --- a/src/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -12,6 +12,7 @@ import net.minecraft.server.v1_5_R3.WatchableObject; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_5_R3.CraftSound; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -28,7 +29,8 @@ public class LibsDisguises extends JavaPlugin { public void onEnable() { ProtocolLibrary.getProtocolManager().addPacketListener( new PacketAdapter(this, ConnectionSide.SERVER_SIDE, ListenerPriority.NORMAL, Packets.Server.NAMED_ENTITY_SPAWN, - Packets.Server.ENTITY_METADATA, Packets.Server.NAMED_SOUND_EFFECT, Packets.Server.ARM_ANIMATION) { + Packets.Server.ENTITY_METADATA, Packets.Server.NAMED_SOUND_EFFECT, Packets.Server.ARM_ANIMATION, + Packets.Server.REL_ENTITY_MOVE_LOOK, Packets.Server.ENTITY_LOOK, Packets.Server.ENTITY_TELEPORT) { @Override public void onPacketSending(PacketEvent event) { StructureModifier mods = event.getPacket().getModifier(); @@ -110,8 +112,9 @@ public class LibsDisguises extends JavaPlugin { } } } else { - org.bukkit.entity.Entity entity = event.getPacket().getEntityModifier(observer.getWorld()) - .read(0); + StructureModifier entityModifer = event.getPacket() + .getEntityModifier(observer.getWorld()); + org.bukkit.entity.Entity entity = entityModifer.read(0); if (entity instanceof Player) { Player watched = (Player) entity; if (DisguiseAPI.isDisguised(watched.getName())) { @@ -132,12 +135,17 @@ public class LibsDisguises extends JavaPlugin { event.setCancelled(true); DisguiseAPI.disguiseToPlayer(watched, observer, disguise); } - } else { - // Set the sounds and cancel bad packets. + } else if (event.getPacketID() == Packets.Server.ARM_ANIMATION) { if (disguise.getType().isMisc()) { - if (event.getPacketID() == Packets.Server.ARM_ANIMATION) { - event.setCancelled(true); - } + event.setCancelled(true); + } + } else { + if (disguise.getType() == DisguiseType.ENDER_DRAGON) { + byte value = (Byte) mods.read(4); + mods.write(4, (byte) (value - 128)); + } else if (disguise.getType().isMisc()) { + byte value = (Byte) mods.read(4); + mods.write(4, (byte) (value + 64)); } } }