Skip to content

Commit

Permalink
Null check entity type in LegacyEntityRewriter#getObjectTrackerHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Dec 16, 2024
1 parent e0430c0 commit a3ec8c8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ protected EntityType trackAndMapEntity(PacketWrapper wrapper) {
if (entityType == null) {
return null;
}

tracker(wrapper.user()).addEntity(wrapper.get(Types.VAR_INT, 0), entityType);

int mappedTypeId = newEntityId(entityType.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,14 @@ public PacketHandler getMobSpawnRewriter1_11(Type<List<EntityData>> dataType) {
}

protected PacketHandler getObjectTrackerHandler() {
return wrapper -> addTrackedEntity(wrapper, wrapper.get(Types.VAR_INT, 0), objectTypeFromId(wrapper.get(Types.BYTE, 0)));
return wrapper -> {
EntityType type = objectTypeFromId(wrapper.get(Types.BYTE, 0));
if (type == null) {
return;
}

addTrackedEntity(wrapper, wrapper.get(Types.VAR_INT, 0), type);
};
}

protected PacketHandler getTrackerAndDataHandler(Type<List<EntityData>> dataType, EntityType entityType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public void register() {
if (entityType == null) {
return;
}

tracker(wrapper.user()).addEntity(wrapper.get(Types.VAR_INT, 0), entityType);

int oldId = EntityIdMappings1_12_2.getOldId(type);
Expand Down

0 comments on commit a3ec8c8

Please sign in to comment.