Skip to content

Commit

Permalink
fix errors with attach_to
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Dec 2, 2019
1 parent d5c2043 commit f00ccbf
Showing 1 changed file with 14 additions and 13 deletions.
Expand Up @@ -151,9 +151,9 @@ public void sendPacket(Packet<?> packet, GenericFutureListener<? extends Future<
oldManager.sendPacket(packet, genericfuturelistener);
}

public boolean isAttached(Entity e) {
public boolean shouldSendAttachOriginal(Entity e) {
UUID attached = NMSHandler.getInstance().attachmentsA.get(e.getUniqueID());
return attached != null && attached.equals(player.getUniqueID());
return attached != null && !attached.equals(player.getUniqueID());
}

public boolean processAttachToForPacket(Packet<?> packet) {
Expand Down Expand Up @@ -198,17 +198,20 @@ public boolean processAttachToForPacket(Packet<?> packet) {
POS_Y_PACKTELENT.setDouble(newTeleportPacket, goalPosition.getY());
POS_Z_PACKTELENT.setDouble(newTeleportPacket, goalPosition.getZ());
oldManager.sendPacket(newTeleportPacket);
return true;
}
POS_X_PACKENT.setInt(pNew, MathHelper.clamp(offX, Short.MIN_VALUE, Short.MAX_VALUE));
POS_Y_PACKENT.setInt(pNew, MathHelper.clamp(offY, Short.MIN_VALUE, Short.MAX_VALUE));
POS_Z_PACKENT.setInt(pNew, MathHelper.clamp(offZ, Short.MIN_VALUE, Short.MAX_VALUE));
else {
POS_X_PACKENT.setShort(pNew, (short) MathHelper.clamp(offX, Short.MIN_VALUE, Short.MAX_VALUE));
POS_Y_PACKENT.setShort(pNew, (short) MathHelper.clamp(offY, Short.MIN_VALUE, Short.MAX_VALUE));
POS_Z_PACKENT.setShort(pNew, (short) MathHelper.clamp(offZ, Short.MIN_VALUE, Short.MAX_VALUE));
oldManager.sendPacket(pNew);
}
}
else {
oldManager.sendPacket(pNew);
}
oldManager.sendPacket(pNew);
return true;
}
}
return isAttached(e);
return shouldSendAttachOriginal(e);
}
else if (packet instanceof PacketPlayOutEntityVelocity) {
int ider = ENTITY_ID_PACKVELENT.getInt(packet);
Expand All @@ -223,10 +226,9 @@ else if (packet instanceof PacketPlayOutEntityVelocity) {
Packet pNew = (Packet) duplo(packet);
ENTITY_ID_PACKVELENT.setInt(pNew, target.getEntityId());
oldManager.sendPacket(pNew);
return true;
}
}
return isAttached(e);
return shouldSendAttachOriginal(e);
}
else if (packet instanceof PacketPlayOutEntityTeleport) {
int ider = ENTITY_ID_PACKTELENT.getInt(packet);
Expand Down Expand Up @@ -258,10 +260,9 @@ else if (packet instanceof PacketPlayOutEntityTeleport) {
}
NMSHandler.getInstance().visiblePositions.put(target.getUniqueId(), resultPos);
oldManager.sendPacket(pNew);
return true;
}
}
return isAttached(e);
return shouldSendAttachOriginal(e);
}
}
catch (Exception ex) {
Expand Down

0 comments on commit f00ccbf

Please sign in to comment.