Fix block placement

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2021-11-29 20:12:11 +01:00
parent 9e37ed6815
commit f7d7b383ba

View File

@ -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);
}