Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 00:22:51 +01:00
Remove entity metadata buffering in 1.8->1.9 (#3766)
Dieser Commit ist enthalten in:
Ursprung
0a2fd8f296
Commit
abd58399cd
@ -204,8 +204,6 @@ public class EntityPackets {
|
||||
if (tracker.hasEntity(entityId)) {
|
||||
protocol.get(MetadataRewriter1_9To1_8.class).handleMetadata(entityId, metadataList, wrapper.user());
|
||||
} else {
|
||||
// Buffer
|
||||
tracker.addMetadataToBuffer(entityId, metadataList);
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
|
@ -67,7 +67,6 @@ public class SpawnPackets {
|
||||
int typeID = wrapper.get(Type.BYTE, 0);
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addEntity(entityID, EntityTypes1_10.getTypeFromId(typeID, true));
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
});
|
||||
|
||||
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);
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addEntity(entityID, EntityTypes1_10.EntityType.EXPERIENCE_ORB);
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
});
|
||||
|
||||
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);
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addEntity(entityID, EntityTypes1_10.EntityType.LIGHTNING);
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
});
|
||||
|
||||
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);
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addEntity(entityID, EntityTypes1_10.getTypeFromId(typeID, false));
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
});
|
||||
|
||||
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);
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addEntity(entityID, EntityTypes1_10.EntityType.PAINTING);
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
});
|
||||
handler(wrapper -> {
|
||||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||
@ -255,7 +250,6 @@ public class SpawnPackets {
|
||||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addEntity(entityID, EntityTypes1_10.EntityType.PLAYER);
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
});
|
||||
|
||||
map(Type.INT, toNewDouble); // 2 - X - Needs to be divided by 32
|
||||
|
@ -57,7 +57,6 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
||||
public static final String WITHER_TRANSLATABLE = "{\"translate\":\"entity.WitherBoss.name\"}";
|
||||
public static final String DRAGON_TRANSLATABLE = "{\"translate\":\"entity.EnderDragon.name\"}";
|
||||
private final Int2ObjectMap<UUID> uuidMap = new Int2ObjectOpenHashMap<>();
|
||||
private final Int2ObjectMap<List<Metadata>> metadataBuffer = new Int2ObjectOpenHashMap<>();
|
||||
private final Int2IntMap vehicleMap = new Int2IntOpenHashMap();
|
||||
private final Int2ObjectMap<BossBar> bossBarMap = new Int2ObjectOpenHashMap<>();
|
||||
private final IntSet validBlocking = new IntOpenHashSet();
|
||||
@ -148,7 +147,6 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
||||
uuidMap.remove(entityId);
|
||||
validBlocking.remove(entityId);
|
||||
knownHolograms.remove(entityId);
|
||||
metadataBuffer.remove(entityId);
|
||||
|
||||
BossBar bar = bossBarMap.remove(entityId);
|
||||
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() {
|
||||
try {
|
||||
return Via.getManager().getProviders().get(EntityIdProvider.class).getEntityId(user());
|
||||
@ -375,10 +344,6 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
||||
return uuidMap;
|
||||
}
|
||||
|
||||
public Int2ObjectMap<List<Metadata>> getMetadataBuffer() {
|
||||
return metadataBuffer;
|
||||
}
|
||||
|
||||
public Int2IntMap getVehicleMap() {
|
||||
return vehicleMap;
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren