Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 09:00:09 +01:00
Uncache biome data on world change, process multi block change
Dieser Commit ist enthalten in:
Ursprung
88a1a42625
Commit
424e855d72
@ -19,7 +19,7 @@ public class WorldPackets {
|
||||
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_16_2.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_16_2.BLOCK_CHANGE);
|
||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_16_2.MULTI_BLOCK_CHANGE);
|
||||
blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_16_2.MULTI_BLOCK_CHANGE);
|
||||
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16_2.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.UPDATE_LIGHT, new PacketRemapper() {
|
||||
@ -55,7 +55,7 @@ public class WorldPackets {
|
||||
chunk.setBiomeData(biomes);
|
||||
} else {
|
||||
Via.getPlatform().getLogger().warning("Biome data not found for chunk at " + chunk.getX() + ", " + chunk.getZ());
|
||||
chunk.setBiomeData(new int[0]);
|
||||
chunk.setBiomeData(new int[1024]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,6 +71,39 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
map(Type.BOOLEAN);
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.BYTE);
|
||||
map(Type.STRING_ARRAY);
|
||||
map(Type.NBT);
|
||||
map(Type.NBT);
|
||||
handler(wrapper -> {
|
||||
String world = wrapper.passthrough(Type.STRING);
|
||||
wrapper.user().get(BiomeStorage.class).setWorld(world);
|
||||
});
|
||||
}
|
||||
});
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.NBT);
|
||||
String world = wrapper.passthrough(Type.STRING);
|
||||
BiomeStorage biomeStorage = wrapper.user().get(BiomeStorage.class);
|
||||
if (!world.equals(biomeStorage.getWorld())) {
|
||||
biomeStorage.clearBiomes();
|
||||
}
|
||||
|
||||
biomeStorage.setWorld(world);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.UNLOAD_CHUNK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -10,11 +10,21 @@ import java.util.Map;
|
||||
public class BiomeStorage extends StoredObject {
|
||||
|
||||
private final Map<Long, int[]> chunkBiomes = new HashMap<>();
|
||||
private String world;
|
||||
|
||||
public BiomeStorage(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public void setWorld(String world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public int[] getBiomes(int x, int z) {
|
||||
return chunkBiomes.get(getChunkSectionIndex(x, z));
|
||||
@ -28,6 +38,10 @@ public class BiomeStorage extends StoredObject {
|
||||
chunkBiomes.remove(getChunkSectionIndex(x, z));
|
||||
}
|
||||
|
||||
public void clearBiomes() {
|
||||
chunkBiomes.clear();
|
||||
}
|
||||
|
||||
private long getChunkSectionIndex(int x, int z) {
|
||||
return ((x & 0x3FFFFFFL) << 38) | (z & 0x3FFFFFFL);
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren