From 7ff7558809fee658420218346e3a2cc3bb058dc2 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 15 Jul 2013 19:59:30 +1200 Subject: [PATCH] Entitys now face the right way when spawning --- .../disguise/DisguiseTypes/Disguise.java | 11 ++++++++--- .../DisguiseTypes/Watchers/ArrowWatcher.java | 1 + src/me/libraryaddict/disguise/LibsDisguises.java | 12 ++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java b/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java index 724abaa4..57f14e7b 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java @@ -44,7 +44,7 @@ public class Disguise { } public PacketContainer[] constructPacket(org.bukkit.entity.Entity e) { - PacketContainer[] spawnPackets = new PacketContainer[1]; + PacketContainer[] spawnPackets = new PacketContainer[2]; ProtocolManager manager = ProtocolLibrary.getProtocolManager(); Entity entity = ((CraftEntity) e).getHandle(); Location loc = e.getLocation(); @@ -60,7 +60,6 @@ public class Disguise { mods.write(4, 1); } else if (getType() == DisguiseType.PAINTING) { - spawnPackets = new PacketContainer[2]; spawnPackets[0] = manager.createPacket(Packets.Server.ENTITY_PAINTING); StructureModifier mods = spawnPackets[0].getModifier(); mods.write(0, e.getEntityId()); @@ -229,7 +228,13 @@ public class Disguise { mods.write(8, entity.getDataWatcher()); } - + if (spawnPackets[1] == null) { + // Make a packet to turn his head! + spawnPackets[1] = manager.createPacket(Packets.Server.ENTITY_HEAD_ROTATION); + StructureModifier mods = spawnPackets[1].getModifier(); + mods.write(0, e.getEntityId()); + mods.write(1, (byte) (int) Math.floor(loc.getYaw() * 256.0F / 360.0F)); + } return spawnPackets; } diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/ArrowWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/ArrowWatcher.java index 5f00a117..4c93e92c 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/ArrowWatcher.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/ArrowWatcher.java @@ -6,6 +6,7 @@ public class ArrowWatcher extends FlagWatcher { public ArrowWatcher(int entityId) { super(entityId); + setValue(16, (byte) 0); } public boolean isMoving() { diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java index 6ca981c0..653664bc 100644 --- a/src/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -143,7 +143,7 @@ public class LibsDisguises extends JavaPlugin implements Listener { e.printStackTrace(); } } - }); + }, 5); } } } else { @@ -159,7 +159,7 @@ public class LibsDisguises extends JavaPlugin implements Listener { e.printStackTrace(); } } - }); + }, 5); } } } else if (event.getPacketID() == Packets.Server.MOB_SPAWN @@ -178,7 +178,7 @@ public class LibsDisguises extends JavaPlugin implements Listener { e.printStackTrace(); } } - }); + }, 5); } } else if (event.getPacketID() == Packets.Server.ARM_ANIMATION || event.getPacketID() == Packets.Server.COLLECT) { @@ -195,10 +195,10 @@ public class LibsDisguises extends JavaPlugin implements Listener { mods.write(4, (byte) (value - 128)); } else if (disguise.getType().isMisc()) { byte value = (Byte) mods.read(4); - if (disguise.getType() == DisguiseType.ITEM_FRAME) { - mods.write(4, -value); + if (disguise.getType() == DisguiseType.ITEM_FRAME || disguise.getType() == DisguiseType.ARROW) { + mods.write(4, (byte) -value); } else if (disguise.getType() == DisguiseType.PAINTING) { - mods.write(4, -(value + 128)); + mods.write(4, (byte) -(value + 128)); } else if (disguise.getType().isMisc()) mods.write(4, (byte) (value - 64)); }