Don't send pose to the client entity

This commit is contained in:
creeper123123321 2019-04-27 17:39:45 -03:00
parent 61b5c90aa7
commit 6d8a763f4c
No known key found for this signature in database
GPG Key ID: 0AC57D54786721D1
4 changed files with 24 additions and 12 deletions

View File

@ -54,15 +54,17 @@ public class MetadataRewriter {
}
if (type.isOrHasParent(Entity1_14Types.EntityType.PLAYER)) {
if (metadata.getId() == 0) {
byte flags = ((Number) metadata.getValue()).byteValue();
// Mojang overrides the client-side pose updater, see OtherPlayerEntity#updateSize
tracker.setEntityFlags(entityId, flags);
} else if (metadata.getId() == 7) {
tracker.setRiptide(entityId, (((Number) metadata.getValue()).byteValue() & 0x4) != 0);
}
if (metadata.getId() == 0 || metadata.getId() == 7) {
metadatas.add(new Metadata(6, MetaType1_14.Pose, recalculatePlayerPose(entityId, tracker)));
if (entityId != tracker.getClientEntityId()) {
if (metadata.getId() == 0) {
byte flags = ((Number) metadata.getValue()).byteValue();
// Mojang overrides the client-side pose updater, see OtherPlayerEntity#updateSize
tracker.setEntityFlags(entityId, flags);
} else if (metadata.getId() == 7) {
tracker.setRiptide(entityId, (((Number) metadata.getValue()).byteValue() & 0x4) != 0);
}
if (metadata.getId() == 0 || metadata.getId() == 7) {
metadatas.add(new Metadata(6, MetaType1_14.Pose, recalculatePlayerPose(entityId, tracker)));
}
}
} else if (type.isOrHasParent(Entity1_14Types.EntityType.ZOMBIE)) {
if (metadata.getId() == 16) {

View File

@ -202,7 +202,9 @@ public class EntityPackets {
PacketWrapper metadataPacket = wrapper.create(0x43);
metadataPacket.write(Type.VAR_INT, entityId);
List<Metadata> metadataList = new LinkedList<>();
metadataList.add(new Metadata(6, MetaType1_14.Pose, MetadataRewriter.recalculatePlayerPose(entityId, tracker)));
if (tracker.getClientEntityId() != entityId) {
metadataList.add(new Metadata(6, MetaType1_14.Pose, MetadataRewriter.recalculatePlayerPose(entityId, tracker)));
}
metadataList.add(new Metadata(12, MetaType1_14.OptPosition, null));
metadataPacket.write(Types1_14.METADATA_LIST, metadataList);
metadataPacket.send(Protocol1_14To1_13_2.class);
@ -227,7 +229,9 @@ public class EntityPackets {
Position position = wrapper.read(Type.POSITION);
List<Metadata> metadataList = new LinkedList<>();
metadataList.add(new Metadata(12, MetaType1_14.OptPosition, position));
metadataList.add(new Metadata(6, MetaType1_14.Pose, MetadataRewriter.recalculatePlayerPose(entityId, tracker)));
if (tracker.getClientEntityId() != entityId) {
metadataList.add(new Metadata(6, MetaType1_14.Pose, MetadataRewriter.recalculatePlayerPose(entityId, tracker)));
}
wrapper.write(Types1_14.METADATA_LIST, metadataList);
}
});

View File

@ -302,7 +302,9 @@ public class WorldPackets {
Entity1_14Types.EntityType entType = Entity1_14Types.EntityType.PLAYER;
// Register Type ID
wrapper.user().get(EntityTracker.class).addEntity(entityId, entType);
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
tracker.addEntity(entityId, entType);
tracker.setClientEntityId(entityId);
}
});

View File

@ -22,6 +22,9 @@ public class EntityTracker extends StoredObject implements ExternalJoinGameListe
private int latestTradeWindowId;
@Getter
@Setter
private int clientEntityId;
@Getter
@Setter
private boolean forceSendCenterChunk = true;
@Getter
@Setter
@ -92,6 +95,7 @@ public class EntityTracker extends StoredObject implements ExternalJoinGameListe
@Override
public void onExternalJoinGame(int playerEntityId) {
clientEntityId = playerEntityId;
clientEntityTypes.put(playerEntityId, Entity1_14Types.EntityType.PLAYER);
}