From 269a5c3aef5789218f41558ba16718daf9bc2d76 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sat, 4 Apr 2020 14:58:37 +1300 Subject: [PATCH] Fix item disguises trying to fly off, fixes #439 --- .../packethandlers/PacketHandlerAttributes.java | 2 -- .../packets/packethandlers/PacketHandlerSpawn.java | 11 +++++++++-- .../packets/packethandlers/PacketHandlerVelocity.java | 8 +++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttributes.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttributes.java index c5e282ed..7dc87922 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttributes.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttributes.java @@ -54,8 +54,6 @@ public class PacketHandlerAttributes implements IPacketHandler { return; } - packets.clear(); - List attributes = new ArrayList<>(); PacketContainer updateAttributes = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java index 092064ae..421abeb1 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java @@ -158,8 +158,8 @@ public class PacketHandlerSpawn implements IPacketHandler { boolean visibleOrNewCompat = playerDisguise.isNameVisible() || DisguiseConfig.isScoreboardDisguiseNames(); WrappedGameProfile spawnProfile = visibleOrNewCompat ? playerDisguise.getGameProfile() : ReflectionManager - .getGameProfileWithThisSkin(UUID.randomUUID(), visibleOrNewCompat ? playerDisguise.getProfileName() : "", - playerDisguise.getGameProfile()); + .getGameProfileWithThisSkin(UUID.randomUUID(), + visibleOrNewCompat ? playerDisguise.getProfileName() : "", playerDisguise.getGameProfile()); int entityId = disguisedEntity.getEntityId(); @@ -378,6 +378,13 @@ public class PacketHandlerSpawn implements IPacketHandler { ints.write(1, 0); ints.write(2, 0); ints.write(3, 0); + + if (disguise.getType() == DisguiseType.DROPPED_ITEM) { + PacketContainer velocity = new PacketContainer(PacketType.Play.Server.ENTITY_VELOCITY); + velocity.getIntegers().write(0, disguisedEntity.getEntityId()); + + packets.addPacket(velocity); + } } spawnEntity.getModifier().write(8, pitch); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerVelocity.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerVelocity.java index 9ba65f94..fcc6f5c6 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerVelocity.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerVelocity.java @@ -21,9 +21,11 @@ public class PacketHandlerVelocity implements IPacketHandler { @Override public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) { - // If the disguise is a misc and the disguised is not the same type - if (disguise.getType().isMisc() && DisguiseType.getType(entity) != disguise.getType()) { - packets.clear(); + // If the disguise isnt a misc or the disguised is the same type + if (!disguise.getType().isMisc() || DisguiseType.getType(entity) == disguise.getType()) { + return; } + + packets.clear(); } }