From f7d7b383ba7dac79e3ca9dc2bcb7caf2ec4e6dc2 Mon Sep 17 00:00:00 2001 From: TheMode Date: Mon, 29 Nov 2021 20:12:11 +0100 Subject: [PATCH] Fix block placement Signed-off-by: TheMode --- .../net/minestom/server/instance/DynamicChunk.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/minestom/server/instance/DynamicChunk.java b/src/main/java/net/minestom/server/instance/DynamicChunk.java index d339916cb..050a9a0b8 100644 --- a/src/main/java/net/minestom/server/instance/DynamicChunk.java +++ b/src/main/java/net/minestom/server/instance/DynamicChunk.java @@ -64,7 +64,8 @@ public class DynamicChunk extends Chunk { columnarOcclusionFieldList.onBlockChanged(x, y, z, blockDescription, 0); } Section section = getSectionAt(y); - section.blockPalette().set(toChunkRelativeCoordinate(x), y / 16, toChunkRelativeCoordinate(z), block.stateId()); + section.blockPalette() + .set(toChunkRelativeCoordinate(x), y, toChunkRelativeCoordinate(z), block.stateId()); final int index = ChunkUtils.getBlockIndex(x, y, z); // Handler @@ -86,7 +87,8 @@ public class DynamicChunk extends Chunk { public void setBiome(int x, int y, int z, @NotNull Biome biome) { this.chunkCache.invalidate(); Section section = getSectionAt(y); - section.biomePalette().set(toChunkRelativeCoordinate(x) / 4, y / 4 / 16, toChunkRelativeCoordinate(z) / 4, biome.id()); + section.biomePalette() + .set(toChunkRelativeCoordinate(x) / 4, y / 4, toChunkRelativeCoordinate(z) / 4, biome.id()); } @Override @@ -123,7 +125,8 @@ public class DynamicChunk extends Chunk { // Retrieve the block from state id final Section section = sections[ChunkUtils.getSectionAt(y) + minSection]; if (section == null) return Block.AIR; // Section is unloaded - final int blockStateId = section.blockPalette().get(toChunkRelativeCoordinate(x), y / 16, toChunkRelativeCoordinate(z)); + final int blockStateId = section.blockPalette() + .get(toChunkRelativeCoordinate(x), y, toChunkRelativeCoordinate(z)); if (blockStateId == -1) return Block.AIR; // Section is empty return Objects.requireNonNullElse(Block.fromStateId((short) blockStateId), Block.AIR); } @@ -132,7 +135,8 @@ public class DynamicChunk extends Chunk { public @NotNull Biome getBiome(int x, int y, int z) { final Section section = sections[ChunkUtils.getSectionAt(y) + minSection]; if (section == null) return Biome.PLAINS; // Section is unloaded - final int id = section.biomePalette().get(toChunkRelativeCoordinate(x) / 4, y / 4 / 16, toChunkRelativeCoordinate(z) / 4); + final int id = section.biomePalette() + .get(toChunkRelativeCoordinate(x) / 4, y / 4, toChunkRelativeCoordinate(z) / 4); return MinecraftServer.getBiomeManager().getById(id); }