mirror of
https://github.com/ViaVersion/ViaLegacy.git
synced 2025-01-02 18:28:57 +01:00
Correctly handle unknown entity types
This commit is contained in:
parent
f2a7c74ee5
commit
71484d45bb
@ -270,7 +270,9 @@ public class Protocolr1_2_4_5Tor1_3_1_2 extends StatelessProtocol<ClientboundPac
|
||||
wrapper.write(Types.SHORT, speedZ);
|
||||
}
|
||||
|
||||
entityTracker.getTrackedEntities().put(entityId, new TrackedEntity(entityId, location, type));
|
||||
if (type != null) {
|
||||
entityTracker.getTrackedEntities().put(entityId, new TrackedEntity(entityId, location, type));
|
||||
}
|
||||
final EntityTypes1_8.ObjectType objectType = EntityTypes1_8.ObjectType.findById(typeId);
|
||||
if (objectType == null) return;
|
||||
|
||||
@ -312,6 +314,10 @@ public class Protocolr1_2_4_5Tor1_3_1_2 extends StatelessProtocol<ClientboundPac
|
||||
final double z = wrapper.get(Types.INT, 3) / 32.0D;
|
||||
final List<EntityData> entityDataList = wrapper.get(Types1_3_1.ENTITY_DATA_LIST, 0);
|
||||
final EntityTypes1_8.EntityType entityType = EntityTypes1_8.getTypeFromId(type, false);
|
||||
if (entityType == null) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
final EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
tracker.getTrackedEntities().put(entityId, new TrackedLivingEntity(entityId, new Location(x, y, z), entityType));
|
||||
tracker.updateEntityDataList(entityId, entityDataList);
|
||||
|
@ -133,7 +133,10 @@ public class Protocolr1_5_2Tor1_6_1 extends StatelessProtocol<ClientboundPackets
|
||||
handler(wrapper -> {
|
||||
final int entityID = wrapper.get(Types.INT, 0);
|
||||
final int typeID = wrapper.get(Types.BYTE, 0);
|
||||
wrapper.user().get(EntityTracker.class).getTrackedEntities().put(entityID, EntityTypes1_8.getTypeFromId(typeID, true));
|
||||
final EntityTypes1_8.EntityType entityType = EntityTypes1_8.getTypeFromId(typeID, true);
|
||||
if (entityType != null) {
|
||||
wrapper.user().get(EntityTracker.class).getTrackedEntities().put(entityID, entityType);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -156,6 +159,10 @@ public class Protocolr1_5_2Tor1_6_1 extends StatelessProtocol<ClientboundPackets
|
||||
final int entityID = wrapper.get(Types.INT, 0);
|
||||
final int typeID = wrapper.get(Types.UNSIGNED_BYTE, 0);
|
||||
final EntityTypes1_8.EntityType entityType = EntityTypes1_8.getTypeFromId(typeID, false);
|
||||
if (entityType == null) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
final List<EntityData> entityDataList = wrapper.get(Types1_6_4.ENTITY_DATA_LIST, 0);
|
||||
wrapper.user().get(EntityTracker.class).getTrackedEntities().put(entityID, entityType);
|
||||
EntityDataRewriter.transform(entityType, entityDataList);
|
||||
|
@ -305,6 +305,9 @@ public class Protocolr1_7_6_10Tor1_8 extends AbstractProtocol<ClientboundPackets
|
||||
byte yaw = wrapper.get(Types.BYTE, 2);
|
||||
int data = wrapper.get(Types.INT, 3);
|
||||
final EntityTypes1_8.EntityType type = EntityTypes1_8.getTypeFromId(typeID, true);
|
||||
if (type == null) {
|
||||
return;
|
||||
}
|
||||
tracker.trackEntity(entityID, type);
|
||||
tracker.updateEntityLocation(entityID, x, y, z, false);
|
||||
|
||||
@ -370,6 +373,10 @@ public class Protocolr1_7_6_10Tor1_8 extends AbstractProtocol<ClientboundPackets
|
||||
final int z = wrapper.get(Types.INT, 2);
|
||||
final List<EntityData> entityDataList = wrapper.get(Types1_8.ENTITY_DATA_LIST, 0);
|
||||
final EntityTypes1_8.EntityType entityType = EntityTypes1_8.getTypeFromId(typeID, false);
|
||||
if (entityType == null) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
tracker.trackEntity(entityID, entityType);
|
||||
tracker.updateEntityLocation(entityID, x, y, z, false);
|
||||
tracker.updateEntityData(entityID, entityDataList);
|
||||
|
Loading…
Reference in New Issue
Block a user