Skip to content

Commit d8b3666

Browse files
Cleaned entity tracker code
1 parent 784a444 commit d8b3666

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

common/src/main/java/com/viaversion/viarewind/api/rewriter/ReplacementEntityTracker.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,13 @@ public boolean isReplaced(final EntityTypes1_10.EntityType type) {
5757
return ENTITY_REPLACEMENTS.containsKey(type);
5858
}
5959

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

6363
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 ?
6464
metadata.add(new Metadata(MetaIndex1_7_6_10To1_8.ENTITY_LIVING_NAME_TAG.getNewIndex(), MetaType1_7_6_10.String, name));
6565
}
6666

67-
public void setPlayerId(int playerId) {
68-
this.playerId = playerId;
69-
}
70-
7167
@Override
7268
public void setClientEntityId(int entityId) {
7369
removeEntity(this.playerId);

common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/PlayerPackets.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void register() {
7272
}
7373

7474
final EntityTracker1_7_6_10 tracker = wrapper.user().get(EntityTracker1_7_6_10.class);
75-
tracker.setPlayerId(wrapper.get(Type.INT, 0));
75+
tracker.setClientEntityId(wrapper.get(Type.INT, 0));
7676
tracker.addPlayer(wrapper.get(Type.INT, 0), wrapper.user().getProtocolInfo().getUuid());
7777

7878
wrapper.user().get(PlayerSessionStorage.class).gameMode = wrapper.get(Type.UNSIGNED_BYTE, 0);

common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/EntityTracker1_7_6_10.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void trackHologram(final int entityId, final VirtualHologramEntity hologr
5050
}
5151

5252
@Override
53-
public void updateMetadata(int entityId, List<Metadata> metadata) {
53+
public void updateMetadata(int entityId, List<Metadata> metadata) throws Exception {
5454
if (virtualHologramMap.containsKey(entityId)) {
5555
virtualHologramMap.get(entityId).updateMetadata(metadata);
5656
return;
@@ -86,12 +86,6 @@ public void setClientEntityId(int entityId) {
8686
super.setClientEntityId(entityId);
8787
}
8888

89-
@Override
90-
public void setPlayerId(int playerId) {
91-
super.setPlayerId(playerId);
92-
this.spectatingPlayerId = playerId;
93-
}
94-
9589
public void addPlayer(final Integer entityId, final UUID uuid) {
9690
playersByUniqueId.put(uuid, entityId);
9791
playersByEntityId.put(entityId, uuid);
@@ -134,6 +128,7 @@ protected void startSneaking() {
134128
public void setPassenger(int vehicleId, int passengerId) {
135129
if (vehicleId == this.spectatingPlayerId && this.spectatingPlayerId != this.getPlayerId()) {
136130
startSneaking();
131+
setSpectating(this.getPlayerId());
137132
}
138133

139134
if (vehicleId == -1) {

0 commit comments

Comments
 (0)