mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-27 19:47:44 +01:00
Fix block placement
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
9e37ed6815
commit
f7d7b383ba
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user