change biome packet

This commit is contained in:
Sen 2025-05-24 18:49:24 +02:00
parent 88c43d0824
commit ffca1f62e5
7 changed files with 50 additions and 80 deletions

View file

@ -2,34 +2,36 @@ package common.packet;
import java.io.IOException;
import common.biome.Biome;
import common.network.IClientPlayer;
import common.network.Packet;
import common.network.PacketBuffer;
import common.util.BlockPos;
public class SPacketBiomes implements Packet<IClientPlayer> {
private int chunkX;
private int chunkZ;
private byte[] biomes;
private int posX;
private int posZ;
private Biome biome;
public SPacketBiomes() {
}
public SPacketBiomes(int chunkX, int chunkZ, byte[] biomes) {
this.chunkX = chunkX;
this.chunkZ = chunkZ;
this.biomes = biomes;
public SPacketBiomes(BlockPos pos, Biome biome) {
this.posX = pos.getX();
this.posZ = pos.getZ();
this.biome = biome;
}
public void readPacketData(PacketBuffer buf) throws IOException {
this.chunkX = buf.readInt();
this.chunkZ = buf.readInt();
buf.readBytes(this.biomes = new byte[256]);
this.posX = buf.readInt();
this.posZ = buf.readInt();
this.biome = buf.readEnumValue(Biome.class);
}
public void writePacketData(PacketBuffer buf) throws IOException {
buf.writeInt(this.chunkX);
buf.writeInt(this.chunkZ);
buf.writeBytes(this.biomes);
buf.writeInt(this.posX);
buf.writeInt(this.posZ);
buf.writeEnumValue(this.biome);
}
public void processPacket(IClientPlayer handler) {
@ -37,14 +39,18 @@ public class SPacketBiomes implements Packet<IClientPlayer> {
}
public int getChunkX() {
return this.chunkX;
return this.posX >> 4;
}
public int getChunkZ() {
return this.chunkZ;
return this.posZ >> 4;
}
public BlockPos getPos() {
return new BlockPos(this.posX, 0, this.posZ);
}
public byte[] getBiomes() {
return this.biomes;
public Biome getBiome() {
return this.biome;
}
}

View file

@ -686,17 +686,6 @@ public abstract class Chunk {
return this.updated && this.populated && this.lightInit;
}
public void setBiomes(byte[] biomes) {
if(this.biomes.length != biomes.length) {
Log.JNI.warn("Konnte Biome des Chunks nicht setzen, Länge des Arrays ist " + biomes.length + " statt " + this.biomes.length);
}
else {
for(int n = 0; n < this.biomes.length; ++n) {
this.biomes[n] = biomes[n];
}
}
}
public void resetRelight() {
this.lightChecks = 0;
}