Skip to content

Commit

Permalink
Fix falses due to marker armor stands
Browse files Browse the repository at this point in the history
  • Loading branch information
Axionize committed Nov 17, 2024
1 parent 2bc467a commit bfbde9d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@

public class PacketEntityArmorStand extends PacketEntity {

public static final int MARKER_FLAG = 16;

boolean isMarker;
public boolean isMarker = false;

public PacketEntityArmorStand(GrimPlayer player, UUID uuid, EntityType type, double x, double y, double z, int extraData) {
super(player, uuid, type, x, y, z);
isMarker = (extraData & MARKER_FLAG) != 0;
}

@Override
Expand Down
43 changes: 24 additions & 19 deletions src/main/java/ac/grim/grimac/utils/latency/CompensatedEntities.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,26 +169,24 @@ public void addEntity(int entityID, UUID uuid, EntityType entityType, Vector3d p
packetEntity = new PacketEntityHorse(player, uuid, entityType, position.getX(), position.getY(), position.getZ(), xRot);
} else if (entityType == EntityTypes.SLIME || entityType == EntityTypes.MAGMA_CUBE || entityType == EntityTypes.PHANTOM) {
packetEntity = new PacketEntitySizeable(player, uuid, entityType, position.getX(), position.getY(), position.getZ());
} else if (EntityTypes.PIG.equals(entityType)) {
packetEntity = new PacketEntityRideable(player, uuid, entityType, position.getX(), position.getY(), position.getZ());
} else if (EntityTypes.SHULKER.equals(entityType)) {
packetEntity = new PacketEntityShulker(player, uuid, entityType, position.getX(), position.getY(), position.getZ());
} else if (EntityTypes.STRIDER.equals(entityType)) {
packetEntity = new PacketEntityStrider(player, uuid, entityType, position.getX(), position.getY(), position.getZ());
} else if (EntityTypes.isTypeInstanceOf(entityType, EntityTypes.BOAT) || EntityTypes.CHICKEN.equals(entityType)) {
packetEntity = new PacketEntityTrackXRot(player, uuid, entityType, position.getX(), position.getY(), position.getZ(), xRot);
} else if (EntityTypes.FISHING_BOBBER.equals(entityType)) {
packetEntity = new PacketEntityHook(player, uuid, entityType, position.getX(), position.getY(), position.getZ(), data);
} else if (EntityTypes.ENDER_DRAGON.equals(entityType)) {
packetEntity = new PacketEntityEnderDragon(player, uuid, entityID, position.getX(), position.getY(), position.getZ());
} else if (EntityTypes.isTypeInstanceOf(entityType, EntityTypes.ABSTRACT_ARROW)) {
packetEntity = new PacketEntityArrow(player, uuid, entityType, position.getX(), position.getY(), position.getZ());
} else if (EntityTypes.ARMOR_STAND.equals(entityType)) {
packetEntity = new PacketEntityArmorStand(player, uuid, entityType, position.getX(), position.getY(), position.getZ(), data);
} else {
if (EntityTypes.PIG.equals(entityType)) {
packetEntity = new PacketEntityRideable(player, uuid, entityType, position.getX(), position.getY(), position.getZ());
} else if (EntityTypes.SHULKER.equals(entityType)) {
packetEntity = new PacketEntityShulker(player, uuid, entityType, position.getX(), position.getY(), position.getZ());
} else if (EntityTypes.STRIDER.equals(entityType)) {
packetEntity = new PacketEntityStrider(player, uuid, entityType, position.getX(), position.getY(), position.getZ());
} else if (EntityTypes.isTypeInstanceOf(entityType, EntityTypes.BOAT) || EntityTypes.CHICKEN.equals(entityType)) {
packetEntity = new PacketEntityTrackXRot(player, uuid, entityType, position.getX(), position.getY(), position.getZ(), xRot);
} else if (EntityTypes.FISHING_BOBBER.equals(entityType)) {
packetEntity = new PacketEntityHook(player, uuid, entityType, position.getX(), position.getY(), position.getZ(), data);
} else if (EntityTypes.ENDER_DRAGON.equals(entityType)) {
packetEntity = new PacketEntityEnderDragon(player, uuid, entityID, position.getX(), position.getY(), position.getZ());
} else if (EntityTypes.isTypeInstanceOf(entityType, EntityTypes.ABSTRACT_ARROW)) {
packetEntity = new PacketEntityArrow(player, uuid, entityType, position.getX(), position.getY(), position.getZ());
} else if (EntityTypes.ARMOR_STAND.equals(entityType)) {
packetEntity = new PacketEntityArmorStand(player, uuid, entityType, position.getX(), position.getY(), position.getZ(), data);
} else {
packetEntity = new PacketEntity(player, uuid, entityType, position.getX(), position.getY(), position.getZ());
}
packetEntity = new PacketEntity(player, uuid, entityType, position.getX(), position.getY(), position.getZ());
}

entityMap.put(entityID, packetEntity);
Expand Down Expand Up @@ -433,6 +431,13 @@ public void updateEntityMetadata(int entityID, List<EntityData> watchableObjects

Integer attachedEntityID = (Integer) hookWatchableObject.getValue();
((PacketEntityHook) entity).attached = attachedEntityID - 1; // the server adds 1 to the ID
} else if (entity instanceof PacketEntityArmorStand) {
EntityData armorStandByte = WatchableIndexUtil.getIndex(watchableObjects, 15);
if (armorStandByte != null) {
byte info = (Byte) armorStandByte.getValue();

((PacketEntityArmorStand) entity).isMarker = (info & 0x10) != 0;
}
}

if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9_4)) {
Expand Down

0 comments on commit bfbde9d

Please sign in to comment.