Convert ChunkUtils.ChunkData into a record

This commit is contained in:
Camotoy 2021-10-11 21:21:21 -04:00
parent 682e4b3edd
commit 52ef3d392a
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
2 changed files with 4 additions and 8 deletions

View file

@ -69,7 +69,7 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
return;
}
ChunkUtils.ChunkData chunkData = ChunkUtils.translateToBedrock(session, column, yOffset);
ChunkSection[] sections = chunkData.getSections();
ChunkSection[] sections = chunkData.sections();
// Find highest section
int sectionCount = sections.length - 1;
@ -91,7 +91,7 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
}
size += 1; // Border blocks
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
ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer(size);
@ -129,7 +129,7 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
// Encode tile entities into buffer
NBTOutputStream nbtStream = NbtUtils.createNetworkWriter(new ByteBufOutputStream(byteBuf));
for (NbtMap blockEntity : chunkData.getBlockEntities()) {
for (NbtMap blockEntity : chunkData.blockEntities()) {
nbtStream.writeTag(blockEntity);
}

View file

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