3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 16:40:10 +01:00

Remove entity metadata buffering in 1.8->1.9 (#3766)

Dieser Commit ist enthalten in:
EnZaXD 2024-03-30 22:27:40 +01:00 committet von GitHub
Ursprung 0a2fd8f296
Commit abd58399cd
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
3 geänderte Dateien mit 0 neuen und 43 gelöschten Zeilen

Datei anzeigen

@ -204,8 +204,6 @@ public class EntityPackets {
if (tracker.hasEntity(entityId)) { if (tracker.hasEntity(entityId)) {
protocol.get(MetadataRewriter1_9To1_8.class).handleMetadata(entityId, metadataList, wrapper.user()); protocol.get(MetadataRewriter1_9To1_8.class).handleMetadata(entityId, metadataList, wrapper.user());
} else { } else {
// Buffer
tracker.addMetadataToBuffer(entityId, metadataList);
wrapper.cancel(); wrapper.cancel();
} }
}); });

Datei anzeigen

@ -67,7 +67,6 @@ public class SpawnPackets {
int typeID = wrapper.get(Type.BYTE, 0); int typeID = wrapper.get(Type.BYTE, 0);
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
tracker.addEntity(entityID, EntityTypes1_10.getTypeFromId(typeID, true)); tracker.addEntity(entityID, EntityTypes1_10.getTypeFromId(typeID, true));
tracker.sendMetadataBuffer(entityID);
}); });
map(Type.INT, toNewDouble); // 3 - X - Needs to be divided by 32 map(Type.INT, toNewDouble); // 3 - X - Needs to be divided by 32
@ -134,7 +133,6 @@ public class SpawnPackets {
int entityID = wrapper.get(Type.VAR_INT, 0); int entityID = wrapper.get(Type.VAR_INT, 0);
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
tracker.addEntity(entityID, EntityTypes1_10.EntityType.EXPERIENCE_ORB); tracker.addEntity(entityID, EntityTypes1_10.EntityType.EXPERIENCE_ORB);
tracker.sendMetadataBuffer(entityID);
}); });
map(Type.INT, toNewDouble); // 1 - X - Needs to be divided by 32 map(Type.INT, toNewDouble); // 1 - X - Needs to be divided by 32
@ -156,7 +154,6 @@ public class SpawnPackets {
int entityID = wrapper.get(Type.VAR_INT, 0); int entityID = wrapper.get(Type.VAR_INT, 0);
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
tracker.addEntity(entityID, EntityTypes1_10.EntityType.LIGHTNING); tracker.addEntity(entityID, EntityTypes1_10.EntityType.LIGHTNING);
tracker.sendMetadataBuffer(entityID);
}); });
map(Type.INT, toNewDouble); // 2 - X - Needs to be divided by 32 map(Type.INT, toNewDouble); // 2 - X - Needs to be divided by 32
@ -183,7 +180,6 @@ public class SpawnPackets {
int typeID = wrapper.get(Type.UNSIGNED_BYTE, 0); int typeID = wrapper.get(Type.UNSIGNED_BYTE, 0);
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
tracker.addEntity(entityID, EntityTypes1_10.getTypeFromId(typeID, false)); tracker.addEntity(entityID, EntityTypes1_10.getTypeFromId(typeID, false));
tracker.sendMetadataBuffer(entityID);
}); });
map(Type.INT, toNewDouble); // 3 - X - Needs to be divided by 32 map(Type.INT, toNewDouble); // 3 - X - Needs to be divided by 32
@ -230,7 +226,6 @@ public class SpawnPackets {
int entityID = wrapper.get(Type.VAR_INT, 0); int entityID = wrapper.get(Type.VAR_INT, 0);
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
tracker.addEntity(entityID, EntityTypes1_10.EntityType.PAINTING); tracker.addEntity(entityID, EntityTypes1_10.EntityType.PAINTING);
tracker.sendMetadataBuffer(entityID);
}); });
handler(wrapper -> { handler(wrapper -> {
int entityID = wrapper.get(Type.VAR_INT, 0); int entityID = wrapper.get(Type.VAR_INT, 0);
@ -255,7 +250,6 @@ public class SpawnPackets {
int entityID = wrapper.get(Type.VAR_INT, 0); int entityID = wrapper.get(Type.VAR_INT, 0);
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class); EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
tracker.addEntity(entityID, EntityTypes1_10.EntityType.PLAYER); tracker.addEntity(entityID, EntityTypes1_10.EntityType.PLAYER);
tracker.sendMetadataBuffer(entityID);
}); });
map(Type.INT, toNewDouble); // 2 - X - Needs to be divided by 32 map(Type.INT, toNewDouble); // 2 - X - Needs to be divided by 32

Datei anzeigen

@ -57,7 +57,6 @@ public class EntityTracker1_9 extends EntityTrackerBase {
public static final String WITHER_TRANSLATABLE = "{\"translate\":\"entity.WitherBoss.name\"}"; public static final String WITHER_TRANSLATABLE = "{\"translate\":\"entity.WitherBoss.name\"}";
public static final String DRAGON_TRANSLATABLE = "{\"translate\":\"entity.EnderDragon.name\"}"; public static final String DRAGON_TRANSLATABLE = "{\"translate\":\"entity.EnderDragon.name\"}";
private final Int2ObjectMap<UUID> uuidMap = new Int2ObjectOpenHashMap<>(); private final Int2ObjectMap<UUID> uuidMap = new Int2ObjectOpenHashMap<>();
private final Int2ObjectMap<List<Metadata>> metadataBuffer = new Int2ObjectOpenHashMap<>();
private final Int2IntMap vehicleMap = new Int2IntOpenHashMap(); private final Int2IntMap vehicleMap = new Int2IntOpenHashMap();
private final Int2ObjectMap<BossBar> bossBarMap = new Int2ObjectOpenHashMap<>(); private final Int2ObjectMap<BossBar> bossBarMap = new Int2ObjectOpenHashMap<>();
private final IntSet validBlocking = new IntOpenHashSet(); private final IntSet validBlocking = new IntOpenHashSet();
@ -148,7 +147,6 @@ public class EntityTracker1_9 extends EntityTrackerBase {
uuidMap.remove(entityId); uuidMap.remove(entityId);
validBlocking.remove(entityId); validBlocking.remove(entityId);
knownHolograms.remove(entityId); knownHolograms.remove(entityId);
metadataBuffer.remove(entityId);
BossBar bar = bossBarMap.remove(entityId); BossBar bar = bossBarMap.remove(entityId);
if (bar != null) { if (bar != null) {
@ -334,35 +332,6 @@ public class EntityTracker1_9 extends EntityTrackerBase {
} }
} }
public void addMetadataToBuffer(int entityID, List<Metadata> metadataList) {
final List<Metadata> metadata = metadataBuffer.get(entityID);
if (metadata != null) {
metadata.addAll(metadataList);
} else {
metadataBuffer.put(entityID, metadataList);
}
}
public void sendMetadataBuffer(int entityId) {
List<Metadata> metadataList = metadataBuffer.get(entityId);
if (metadataList != null) {
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.ENTITY_METADATA, null, user());
wrapper.write(Type.VAR_INT, entityId);
wrapper.write(Types1_9.METADATA_LIST, metadataList);
Via.getManager().getProtocolManager().getProtocol(Protocol1_9To1_8.class).get(MetadataRewriter1_9To1_8.class)
.handleMetadata(entityId, metadataList, user());
handleMetadata(entityId, metadataList);
if (!metadataList.isEmpty()) {
try {
wrapper.scheduleSend(Protocol1_9To1_8.class);
} catch (Exception e) {
Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to send metadata", e);
}
}
metadataBuffer.remove(entityId);
}
}
public int getProvidedEntityId() { public int getProvidedEntityId() {
try { try {
return Via.getManager().getProviders().get(EntityIdProvider.class).getEntityId(user()); return Via.getManager().getProviders().get(EntityIdProvider.class).getEntityId(user());
@ -375,10 +344,6 @@ public class EntityTracker1_9 extends EntityTrackerBase {
return uuidMap; return uuidMap;
} }
public Int2ObjectMap<List<Metadata>> getMetadataBuffer() {
return metadataBuffer;
}
public Int2IntMap getVehicleMap() { public Int2IntMap getVehicleMap() {
return vehicleMap; return vehicleMap;
} }