Skip to content

Commit

Permalink
Cleaned entity tracker code
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Oct 29, 2023
1 parent 784a444 commit d8b3666
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,13 @@ public boolean isReplaced(final EntityTypes1_10.EntityType type) {
return ENTITY_REPLACEMENTS.containsKey(type);
}

public void updateMetadata(final int entityId, final List<Metadata> metadata) {
public void updateMetadata(final int entityId, final List<Metadata> metadata) throws Exception {
final String name = ENTITY_REPLACEMENTS.get(entityMap.get(entityId)).value();

metadata.add(new Metadata(MetaIndex1_7_6_10To1_8.ENTITY_LIVING_NAME_TAG_VISIBILITY.getNewIndex(), MetaType1_7_6_10.Byte, (byte) 1)); // TODO: Make this definable for 1.8 -> 1.9 ?
metadata.add(new Metadata(MetaIndex1_7_6_10To1_8.ENTITY_LIVING_NAME_TAG.getNewIndex(), MetaType1_7_6_10.String, name));
}

public void setPlayerId(int playerId) {
this.playerId = playerId;
}

@Override
public void setClientEntityId(int entityId) {
removeEntity(this.playerId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void register() {
}

final EntityTracker1_7_6_10 tracker = wrapper.user().get(EntityTracker1_7_6_10.class);
tracker.setPlayerId(wrapper.get(Type.INT, 0));
tracker.setClientEntityId(wrapper.get(Type.INT, 0));
tracker.addPlayer(wrapper.get(Type.INT, 0), wrapper.user().getProtocolInfo().getUuid());

wrapper.user().get(PlayerSessionStorage.class).gameMode = wrapper.get(Type.UNSIGNED_BYTE, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void trackHologram(final int entityId, final VirtualHologramEntity hologr
}

@Override
public void updateMetadata(int entityId, List<Metadata> metadata) {
public void updateMetadata(int entityId, List<Metadata> metadata) throws Exception {
if (virtualHologramMap.containsKey(entityId)) {
virtualHologramMap.get(entityId).updateMetadata(metadata);
return;
Expand Down Expand Up @@ -86,12 +86,6 @@ public void setClientEntityId(int entityId) {
super.setClientEntityId(entityId);
}

@Override
public void setPlayerId(int playerId) {
super.setPlayerId(playerId);
this.spectatingPlayerId = playerId;
}

public void addPlayer(final Integer entityId, final UUID uuid) {
playersByUniqueId.put(uuid, entityId);
playersByEntityId.put(entityId, uuid);
Expand Down Expand Up @@ -134,6 +128,7 @@ protected void startSneaking() {
public void setPassenger(int vehicleId, int passengerId) {
if (vehicleId == this.spectatingPlayerId && this.spectatingPlayerId != this.getPlayerId()) {
startSneaking();
setSpectating(this.getPlayerId());
}

if (vehicleId == -1) {
Expand Down

0 comments on commit d8b3666

Please sign in to comment.