Skip to content

Commit 780b981

Browse files
Fixup hologram handling 1.8->1.7
Closes #509
1 parent 5df933f commit 780b981

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

common/src/main/java/com/viaversion/viarewind/protocol/v1_8to1_7_6_10/data/VirtualHologramEntity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public void sendSpawnPacket(final EntityPacketRewriter1_8 entityRewriter) {
266266
deleteEntity();
267267
}
268268
if (currentState == State.ZOMBIE) {
269-
spawnEntity(entityId, 54, locX, locY, locZ);
269+
spawnEntity(entityId, EntityTypes1_8.EntityType.ZOMBIE.getId(), locX, locY, locZ);
270270

271271
entityIds = new int[]{entityId};
272272
} else if (currentState == State.HOLOGRAM) {
@@ -283,7 +283,7 @@ public void sendSpawnPacket(final EntityPacketRewriter1_8 entityRewriter) {
283283
spawnSkull.write(Types.INT, 0);
284284
spawnSkull.send(Protocol1_8To1_7_6_10.class);
285285

286-
spawnEntity(entityIds[1], 100, locX, locY, locZ); // Horse
286+
spawnEntity(entityIds[1], EntityTypes1_8.EntityType.HORSE.getId(), locX, locY, locZ); // Horse
287287

288288
this.entityIds = entityIds;
289289
}

common/src/main/java/com/viaversion/viarewind/protocol/v1_8to1_7_6_10/rewriter/EntityPacketRewriter1_8.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,15 @@ public void register() {
111111
map(Types.VAR_INT, Types.INT); // Entity id
112112
map(Types1_8.ENTITY_DATA_LIST, Types1_7_6_10.ENTITY_DATA_LIST); // Entity data
113113
handler(wrapper -> {
114+
final EntityTracker1_8 tracker = tracker(wrapper.user());
114115
final int entityId = wrapper.get(Types.INT, 0);
115116
final List<EntityData> entityData = wrapper.get(Types1_7_6_10.ENTITY_DATA_LIST, 0);
116-
handleEntityData(entityId, entityData, wrapper.user());
117+
if (tracker.getHolograms().containsKey(entityId)) {
118+
wrapper.cancel();
119+
tracker.getHolograms().get(entityId).syncState(EntityPacketRewriter1_8.this, entityData);
120+
} else {
121+
handleEntityData(entityId, entityData, wrapper.user());
122+
}
117123
});
118124
}
119125
});
@@ -249,7 +255,6 @@ public void register() {
249255
map(Types1_8.ENTITY_DATA_LIST, Types1_7_6_10.ENTITY_DATA_LIST); // Entity data
250256

251257
handler(getTrackerHandler(Types.UNSIGNED_BYTE, 0));
252-
handler(getMobSpawnRewriter(Types1_7_6_10.ENTITY_DATA_LIST));
253258

254259
// Handle holograms
255260
handler(wrapper -> {
@@ -276,6 +281,7 @@ public void register() {
276281
hologram.syncState(protocol().getEntityRewriter(), wrapper.get(Types1_7_6_10.ENTITY_DATA_LIST, 0));
277282
}
278283
});
284+
handler(getMobSpawnRewriter(Types1_7_6_10.ENTITY_DATA_LIST));
279285
}
280286
});
281287
protocol.registerClientbound(ClientboundPackets1_8.ADD_PLAYER, new PacketHandlers() {
@@ -618,13 +624,6 @@ protected void registerRewrites() {
618624
}
619625

620626
public void handleEntityData(EntityDataHandlerEvent event, EntityData entityData) {
621-
if (event.entityType() == EntityType.ARMOR_STAND) {
622-
final EntityTracker1_8 tracker = tracker(event.user());
623-
tracker.getHolograms().get(event.entityId()).syncState(this, event.dataList());
624-
event.cancel(); // We are rewriting entityData manually
625-
return;
626-
}
627-
628627
final EntityDataIndex1_7_6_10 metaIndex = EntityDataIndex1_7_6_10.searchIndex(event.entityType(), entityData.id());
629628
if (metaIndex == null) {
630629
// Almost certainly bad data, remove it

0 commit comments

Comments
 (0)