Null check entity type in LegacyEntityRewriter#getObjectTrackerHandler (#935)

This commit is contained in:
EnZaXD 2024-12-16 01:23:05 +01:00 committed by GitHub
parent e0430c0f45
commit f0def507fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View File

@ -140,6 +140,7 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
if (entityType == null) {
return null;
}
tracker(wrapper.user()).addEntity(wrapper.get(Types.VAR_INT, 0), entityType);
int mappedTypeId = newEntityId(entityType.getId());

View File

@ -124,7 +124,14 @@ public abstract class LegacyEntityRewriter<C extends ClientboundPacketType, T ex
}
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) {

View File

@ -138,6 +138,7 @@ public class EntityPacketRewriter1_13 extends LegacyEntityRewriter<ClientboundPa
if (entityType == null) {
return;
}
tracker(wrapper.user()).addEntity(wrapper.get(Types.VAR_INT, 0), entityType);
int oldId = EntityIdMappings1_12_2.getOldId(type);