3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-04 23:30:17 +01:00

remove global palette bits, fix nullable block entity tags

Dieser Commit ist enthalten in:
onebeastchris 2024-04-21 22:54:54 +02:00 committet von Camotoy
Ursprung 57ce5706ee
Commit b73f23de0f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
4 geänderte Dateien mit 4 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -263,11 +263,6 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
@Setter
private ItemMappings itemMappings;
/**
* Required to decode biomes correctly.
*/
@Setter
private int biomeGlobalPalette;
/**
* Stores the map between Java and Bedrock biome network IDs.
*/

Datei anzeigen

@ -31,7 +31,6 @@ import com.github.steveice10.mc.protocol.data.game.chunk.DataPalette;
import com.github.steveice10.mc.protocol.data.game.chunk.palette.GlobalPalette;
import com.github.steveice10.mc.protocol.data.game.chunk.palette.Palette;
import com.github.steveice10.mc.protocol.data.game.chunk.palette.SingletonPalette;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import it.unimi.dsi.fastutil.ints.*;
import org.geysermc.geyser.level.chunk.BlockStorage;
import org.geysermc.geyser.level.chunk.bitarray.BitArray;
@ -39,7 +38,6 @@ import org.geysermc.geyser.level.chunk.bitarray.BitArrayVersion;
import org.geysermc.geyser.level.chunk.bitarray.SingletonBitArray;
import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.MathUtils;
import java.util.List;
@ -49,8 +47,6 @@ public class BiomeTranslator {
public static void loadServerBiomes(GeyserSession session, List<RegistryEntry> entries) {
Int2IntMap biomeTranslations = new Int2IntOpenHashMap();
session.setBiomeGlobalPalette(MathUtils.getGlobalPaletteForSize(entries.size()));
int greatestBiomeId = 0;
for (int i = 0; i < entries.size(); i++) {
RegistryEntry entry = entries.get(i);

Datei anzeigen

@ -98,7 +98,6 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
// Ensure that, if the player is using lower world heights, the position is not offset
int yOffset = session.getChunkCache().getChunkMinY();
int chunkSize = session.getChunkCache().getChunkHeightY();
int biomeGlobalPalette = session.getBiomeGlobalPalette();
DataPalette[] javaChunks = new DataPalette[chunkSize];
DataPalette[] javaBiomes = new DataPalette[chunkSize];
@ -122,7 +121,7 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
ByteBuf in = Unpooled.wrappedBuffer(packet.getChunkData());
boolean extendedCollisionNextSection = false;
for (int sectionY = 0; sectionY < chunkSize; sectionY++) {
ChunkSection javaSection = session.getDownstream().getCodecHelper().readChunkSection(in, biomeGlobalPalette);
ChunkSection javaSection = session.getDownstream().getCodecHelper().readChunkSection(in);
javaChunks[sectionY] = javaSection.getChunkData();
javaBiomes[sectionY] = javaSection.getBiomeData();
boolean extendedCollision = extendedCollisionNextSection;
@ -393,12 +392,13 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
final int chunkBlockZ = packet.getZ() << 4;
for (BlockEntityInfo blockEntity : blockEntities) {
BlockEntityType type = blockEntity.getType();
if (type == null) {
CompoundTag tag = blockEntity.getNbt();
if (type == null || tag == null) {
// As an example: ViaVersion will send -1 if it cannot find the block entity type
// Vanilla Minecraft gracefully handles this
// Since 1.20.5: tags sent here can be null, at which point the block entity is not translated
continue;
}
CompoundTag tag = blockEntity.getNbt();
int x = blockEntity.getX(); // Relative to chunk
int y = blockEntity.getY();
int z = blockEntity.getZ(); // Relative to chunk

Datei anzeigen

@ -189,11 +189,4 @@ public class MathUtils {
public static long chunkPositionToLong(int x, int z) {
return ((x & 0xFFFFFFFFL) << 32L) | (z & 0xFFFFFFFFL);
}
/**
* @return the bits per entry used when this number is the maximum amount of entries.
*/
public static int getGlobalPaletteForSize(int size) {
return 32 - Integer.numberOfLeadingZeros(size - 1);
}
}