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

Convert ChunkUtils.ChunkData into a record

Dieser Commit ist enthalten in:
Camotoy 2021-10-11 21:21:21 -04:00
Ursprung 682e4b3edd
Commit 52ef3d392a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
2 geänderte Dateien mit 4 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -69,7 +69,7 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
return; return;
} }
ChunkUtils.ChunkData chunkData = ChunkUtils.translateToBedrock(session, column, yOffset); ChunkUtils.ChunkData chunkData = ChunkUtils.translateToBedrock(session, column, yOffset);
ChunkSection[] sections = chunkData.getSections(); ChunkSection[] sections = chunkData.sections();
// Find highest section // Find highest section
int sectionCount = sections.length - 1; int sectionCount = sections.length - 1;
@ -91,7 +91,7 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
} }
size += 1; // Border blocks size += 1; // Border blocks
size += 1; // Extra data length (always 0) size += 1; // Extra data length (always 0)
size += chunkData.getBlockEntities().length * 64; // Conservative estimate of 64 bytes per tile entity size += chunkData.blockEntities().length * 64; // Conservative estimate of 64 bytes per tile entity
// Allocate output buffer // Allocate output buffer
ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer(size); ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer(size);
@ -129,7 +129,7 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
// Encode tile entities into buffer // Encode tile entities into buffer
NBTOutputStream nbtStream = NbtUtils.createNetworkWriter(new ByteBufOutputStream(byteBuf)); NBTOutputStream nbtStream = NbtUtils.createNetworkWriter(new ByteBufOutputStream(byteBuf));
for (NbtMap blockEntity : chunkData.getBlockEntities()) { for (NbtMap blockEntity : chunkData.blockEntities()) {
nbtStream.writeTag(blockEntity); nbtStream.writeTag(blockEntity);
} }

Datei anzeigen

@ -42,7 +42,6 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
import lombok.Data;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.entity.ItemFrameEntity; import org.geysermc.connector.entity.ItemFrameEntity;
@ -470,9 +469,6 @@ public class ChunkUtils {
session.getWorldBorder().setWorldCoordinateScale(coordinateScale); session.getWorldBorder().setWorldCoordinateScale(coordinateScale);
} }
@Data public record ChunkData(ChunkSection[] sections, NbtMap[] blockEntities) {
public static final class ChunkData {
private final ChunkSection[] sections;
private final NbtMap[] blockEntities;
} }
} }