From 9b4e9b4b625c2e35640d2d513b16c92ef5c5c6be Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 20 Aug 2013 05:45:25 +1200 Subject: [PATCH] Let exp orbs be a little bit nicer --- .../disguise/DisguiseTypes/Disguise.java | 88 ++++++++++--------- .../disguise/PacketsManager.java | 1 - 2 files changed, 47 insertions(+), 42 deletions(-) diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java b/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java index 7429faaa..61238379 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java @@ -129,7 +129,6 @@ public class Disguise { fallSpeed = 0; break; case DROPPED_ITEM: - case EXPERIENCE_ORB: case MAGMA_CUBE: case PRIMED_TNT: fallSpeed = 0.2; @@ -139,6 +138,10 @@ public class Disguise { case FALLING_BLOCK: fallSpeed = 0.04; break; + case EXPERIENCE_ORB: + fallSpeed = 0.0221; + movement = true; + break; case SPIDER: case CAVE_SPIDER: fallSpeed = 0.0040; @@ -178,47 +181,50 @@ public class Disguise { if (vector.getY() != 0 && !(vector.getY() < 0 && alwaysSendVelocity && entity.isOnGround())) { return; } - PacketContainer lookPacket = null; - PacketContainer selfLookPacket = null; - if (getType() == DisguiseType.WITHER_SKULL) { - lookPacket = new PacketContainer(Packets.Server.ENTITY_LOOK); - StructureModifier mods = lookPacket.getModifier(); - mods.write(0, entity.getEntityId()); - Location loc = entity.getLocation(); - mods.write( - 4, - PacketsManager.getYaw(getType(), DisguiseType.getType(entity.getType()), - (byte) Math.floor(loc.getYaw() * 256.0F / 360.0F))); - mods.write(5, (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F)); - selfLookPacket = lookPacket.shallowClone(); - } - for (EntityPlayer player : getPerverts()) { - PacketContainer packet = new PacketContainer(Packets.Server.ENTITY_VELOCITY); - StructureModifier mods = packet.getModifier(); - if (entity == player.getBukkitEntity()) { - if (!viewSelfDisguise()) - continue; - if (selfLookPacket != null) { - try { - ProtocolLibrary.getProtocolManager().sendServerPacket(player.getBukkitEntity(), - selfLookPacket, false); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - mods.write(0, DisguiseAPI.getFakeDisguise(entity.getEntityId())); - } else + if (getType() != DisguiseType.EXPERIENCE_ORB || !entity.isOnGround()) { + PacketContainer lookPacket = null; + PacketContainer selfLookPacket = null; + if (getType() == DisguiseType.WITHER_SKULL) { + lookPacket = new PacketContainer(Packets.Server.ENTITY_LOOK); + StructureModifier mods = lookPacket.getModifier(); mods.write(0, entity.getEntityId()); - mods.write(1, (int) (vector.getX() * 8000)); - mods.write(2, (int) (8000 * (vectorY * (double) player.ping * 0.069))); - mods.write(3, (int) (vector.getZ() * 8000)); - try { - if (lookPacket != null) - ProtocolLibrary.getProtocolManager().sendServerPacket(player.getBukkitEntity(), lookPacket, - false); - ProtocolLibrary.getProtocolManager().sendServerPacket(player.getBukkitEntity(), packet, false); - } catch (InvocationTargetException e) { - e.printStackTrace(); + Location loc = entity.getLocation(); + mods.write( + 4, + PacketsManager.getYaw(getType(), DisguiseType.getType(entity.getType()), + (byte) Math.floor(loc.getYaw() * 256.0F / 360.0F))); + mods.write(5, (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F)); + selfLookPacket = lookPacket.shallowClone(); + } + for (EntityPlayer player : getPerverts()) { + PacketContainer packet = new PacketContainer(Packets.Server.ENTITY_VELOCITY); + StructureModifier mods = packet.getModifier(); + if (entity == player.getBukkitEntity()) { + if (!viewSelfDisguise()) + continue; + if (selfLookPacket != null) { + try { + ProtocolLibrary.getProtocolManager().sendServerPacket(player.getBukkitEntity(), + selfLookPacket, false); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + mods.write(0, DisguiseAPI.getFakeDisguise(entity.getEntityId())); + } else + mods.write(0, entity.getEntityId()); + mods.write(1, (int) (vector.getX() * 8000)); + mods.write(2, (int) (8000 * (vectorY * (double) player.ping * 0.069))); + mods.write(3, (int) (vector.getZ() * 8000)); + try { + if (lookPacket != null) + ProtocolLibrary.getProtocolManager().sendServerPacket(player.getBukkitEntity(), + lookPacket, false); + ProtocolLibrary.getProtocolManager() + .sendServerPacket(player.getBukkitEntity(), packet, false); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } } } // If we need to send more packets because else it still 'sinks' diff --git a/src/me/libraryaddict/disguise/PacketsManager.java b/src/me/libraryaddict/disguise/PacketsManager.java index cb7ffe43..184b3f15 100644 --- a/src/me/libraryaddict/disguise/PacketsManager.java +++ b/src/me/libraryaddict/disguise/PacketsManager.java @@ -380,7 +380,6 @@ public class PacketsManager { case EGG: case ENDER_PEARL: case ENDER_SIGNAL: - case EXPERIENCE_ORB: case FIREWORK: case MINECART: case MINECART_CHEST: