Entitys now face the right way when spawning

This commit is contained in:
Andrew 2013-07-15 19:59:30 +12:00
parent 9ea389eaf8
commit 7ff7558809
3 changed files with 15 additions and 9 deletions

View File

@ -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<Object> 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<Object> mods = spawnPackets[1].getModifier();
mods.write(0, e.getEntityId());
mods.write(1, (byte) (int) Math.floor(loc.getYaw() * 256.0F / 360.0F));
}
return spawnPackets;
}

View File

@ -6,6 +6,7 @@ public class ArrowWatcher extends FlagWatcher {
public ArrowWatcher(int entityId) {
super(entityId);
setValue(16, (byte) 0);
}
public boolean isMoving() {

View File

@ -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));
}