Skip to content

Commit

Permalink
Also explicitly map entity data list type in 1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytv committed Aug 24, 2024
1 parent 24f67ff commit d627975
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,30 +92,6 @@ public void register() {
});
}

@Override
public void registerSetEntityData(C packetType, Type<List<EntityData>> dataType, Type<List<EntityData>> mappedDataType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity ID
if (dataType != null) {
map(dataType, mappedDataType);
} else {
map(mappedDataType);
}
handler(wrapper -> {
List<EntityData> entityDataList = wrapper.get(mappedDataType, 0);
handleEntityData(wrapper.get(Types.VAR_INT, 0), entityDataList, wrapper.user());
});
}
});
}

@Override
public void registerSetEntityData(C packetType, Type<List<EntityData>> dataType) {
registerSetEntityData(packetType, null, dataType);
}

protected PacketHandler getMobSpawnRewriter(Type<List<EntityData>> dataType, IdSetter idSetter) {
return wrapper -> {
int entityId = wrapper.get(Types.VAR_INT, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_12;
import com.viaversion.viaversion.api.type.types.version.Types1_9;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
Expand Down Expand Up @@ -83,13 +84,13 @@ public void register() {
map(Types.SHORT); // 9 - Velocity X
map(Types.SHORT); // 10 - Velocity Y
map(Types.SHORT); // 11 - Velocity Z
map(Types1_12.ENTITY_DATA_LIST); // 12 - Entity data
map(Types1_12.ENTITY_DATA_LIST, Types1_9.ENTITY_DATA_LIST); // 12 - Entity data

// Track entity
handler(getTrackerHandler());

// Rewrite entity type / data
handler(getMobSpawnRewriter1_11(Types1_12.ENTITY_DATA_LIST));
handler(getMobSpawnRewriter1_11(Types1_9.ENTITY_DATA_LIST));
}
});

Expand All @@ -105,9 +106,9 @@ public void register() {
map(Types.DOUBLE); // 4 - Z
map(Types.BYTE); // 5 - Yaw
map(Types.BYTE); // 6 - Pitch
map(Types1_12.ENTITY_DATA_LIST); // 7 - Entity data list
map(Types1_12.ENTITY_DATA_LIST, Types1_9.ENTITY_DATA_LIST); // 7 - Entity data list

handler(getTrackerAndDataHandler(Types1_12.ENTITY_DATA_LIST, EntityTypes1_12.EntityType.PLAYER));
handler(getTrackerAndDataHandler(Types1_9.ENTITY_DATA_LIST, EntityTypes1_12.EntityType.PLAYER));
}
});

Expand Down Expand Up @@ -142,7 +143,7 @@ public void register() {

registerRespawn(ClientboundPackets1_12.RESPAWN);
registerRemoveEntities(ClientboundPackets1_12.REMOVE_ENTITIES);
registerSetEntityData(ClientboundPackets1_12.SET_ENTITY_DATA, Types1_12.ENTITY_DATA_LIST);
registerSetEntityData(ClientboundPackets1_12.SET_ENTITY_DATA, Types1_12.ENTITY_DATA_LIST, Types1_9.ENTITY_DATA_LIST);

protocol.registerClientbound(ClientboundPackets1_12.UPDATE_ATTRIBUTES, new PacketHandlers() {
@Override
Expand Down

0 comments on commit d627975

Please sign in to comment.