Skip to content

Commit

Permalink
Fixup hologram handling 1.8->1.7
Browse files Browse the repository at this point in the history
Closes #509
  • Loading branch information
FlorianMichael committed Jun 6, 2024
1 parent 5df933f commit 780b981
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public void sendSpawnPacket(final EntityPacketRewriter1_8 entityRewriter) {
deleteEntity();
}
if (currentState == State.ZOMBIE) {
spawnEntity(entityId, 54, locX, locY, locZ);
spawnEntity(entityId, EntityTypes1_8.EntityType.ZOMBIE.getId(), locX, locY, locZ);

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

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

this.entityIds = entityIds;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,15 @@ public void register() {
map(Types.VAR_INT, Types.INT); // Entity id
map(Types1_8.ENTITY_DATA_LIST, Types1_7_6_10.ENTITY_DATA_LIST); // Entity data
handler(wrapper -> {
final EntityTracker1_8 tracker = tracker(wrapper.user());
final int entityId = wrapper.get(Types.INT, 0);
final List<EntityData> entityData = wrapper.get(Types1_7_6_10.ENTITY_DATA_LIST, 0);
handleEntityData(entityId, entityData, wrapper.user());
if (tracker.getHolograms().containsKey(entityId)) {
wrapper.cancel();
tracker.getHolograms().get(entityId).syncState(EntityPacketRewriter1_8.this, entityData);
} else {
handleEntityData(entityId, entityData, wrapper.user());
}
});
}
});
Expand Down Expand Up @@ -249,7 +255,6 @@ public void register() {
map(Types1_8.ENTITY_DATA_LIST, Types1_7_6_10.ENTITY_DATA_LIST); // Entity data

handler(getTrackerHandler(Types.UNSIGNED_BYTE, 0));
handler(getMobSpawnRewriter(Types1_7_6_10.ENTITY_DATA_LIST));

// Handle holograms
handler(wrapper -> {
Expand All @@ -276,6 +281,7 @@ public void register() {
hologram.syncState(protocol().getEntityRewriter(), wrapper.get(Types1_7_6_10.ENTITY_DATA_LIST, 0));
}
});
handler(getMobSpawnRewriter(Types1_7_6_10.ENTITY_DATA_LIST));
}
});
protocol.registerClientbound(ClientboundPackets1_8.ADD_PLAYER, new PacketHandlers() {
Expand Down Expand Up @@ -618,13 +624,6 @@ protected void registerRewrites() {
}

public void handleEntityData(EntityDataHandlerEvent event, EntityData entityData) {
if (event.entityType() == EntityType.ARMOR_STAND) {
final EntityTracker1_8 tracker = tracker(event.user());
tracker.getHolograms().get(event.entityId()).syncState(this, event.dataList());
event.cancel(); // We are rewriting entityData manually
return;
}

final EntityDataIndex1_7_6_10 metaIndex = EntityDataIndex1_7_6_10.searchIndex(event.entityType(), entityData.id());
if (metaIndex == null) {
// Almost certainly bad data, remove it
Expand Down

0 comments on commit 780b981

Please sign in to comment.