3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-26 16:12:46 +01:00

Remove obsolete chunk writing code

Dieser Commit ist enthalten in:
Camotoy 2022-05-29 20:39:14 -04:00
Ursprung 7a0a6795d0
Commit e43a143bf4
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F

Datei anzeigen

@ -43,7 +43,6 @@ import com.nukkitx.nbt.NbtMap;
import com.nukkitx.nbt.NbtUtils;
import com.nukkitx.network.VarInts;
import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket;
import com.nukkitx.protocol.bedrock.v503.Bedrock_v503;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ByteBufOutputStream;
@ -52,6 +51,7 @@ import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntLists;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import org.geysermc.geyser.entity.type.ItemFrameEntity;
import org.geysermc.geyser.level.BedrockDimension;
import org.geysermc.geyser.level.block.BlockStateValues;
import org.geysermc.geyser.level.chunk.BlockStorage;
import org.geysermc.geyser.level.chunk.GeyserChunkSection;
@ -60,7 +60,6 @@ import org.geysermc.geyser.level.chunk.bitarray.BitArrayVersion;
import org.geysermc.geyser.level.chunk.bitarray.SingletonBitArray;
import org.geysermc.geyser.registry.BlockRegistries;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.level.BedrockDimension;
import org.geysermc.geyser.translator.level.BiomeTranslator;
import org.geysermc.geyser.translator.level.block.entity.BedrockOnlyBlockEntity;
import org.geysermc.geyser.translator.level.block.entity.BlockEntityTranslator;
@ -76,7 +75,8 @@ import java.util.BitSet;
import java.util.List;
import java.util.Map;
import static org.geysermc.geyser.util.ChunkUtils.*;
import static org.geysermc.geyser.util.ChunkUtils.SERIALIZED_CHUNK_DATA;
import static org.geysermc.geyser.util.ChunkUtils.indexYZXtoXZY;
@Translator(packet = ClientboundLevelChunkWithLightPacket.class)
public class JavaLevelChunkWithLightTranslator extends PacketTranslator<ClientboundLevelChunkWithLightPacket> {
@ -312,10 +312,8 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
}
}
// As of 1.18.0, Bedrock hardcodes to always read 25 biome sections
// As of 1.18.30, the hardcode may now be tied to the dimension definition
boolean isNewVersion = session.getUpstream().getProtocolVersion() >= Bedrock_v503.V503_CODEC.getProtocolVersion();
int biomeCount = isNewVersion ? bedrockDimension.height() >> 4 : 25;
// As of 1.18.30, the amount of biomes read is dependent on how high Bedrock thinks the dimension is
int biomeCount = bedrockDimension.height() >> 4;
int dimensionOffset = bedrockDimension.minY() >> 4;
for (int i = 0; i < biomeCount; i++) {
int biomeYOffset = dimensionOffset + i;
@ -326,13 +324,8 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
}
if (biomeYOffset >= (chunkSize + yOffset)) {
// This biome section goes above the height of the Java world
if (isNewVersion) {
// A header that says to carry on the biome data from the previous chunk
// This notably fixes biomes in the End
byteBuf.writeByte((127 << 1) | 1);
} else {
byteBuf.writeBytes(ChunkUtils.EMPTY_BIOME_DATA);
}
// The byte written here is a header that says to carry on the biome data from the previous chunk
byteBuf.writeByte((127 << 1) | 1);
continue;
}