mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-29 03:21:34 +01:00
Static import and fix negative y value
This commit is contained in:
parent
83d751ecf2
commit
fc1ee640b2
@ -26,6 +26,8 @@ import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static net.minestom.server.utils.chunk.ChunkUtils.toSectionRelativeCoordinate;
|
||||
|
||||
/**
|
||||
* Represents a {@link Chunk} which store each individual block in memory.
|
||||
* <p>
|
||||
@ -66,7 +68,7 @@ public class DynamicChunk extends Chunk {
|
||||
}
|
||||
Section section = getSectionAt(y);
|
||||
section.blockPalette()
|
||||
.set(ChunkUtils.toSectionRelativeCoordinate(x), ChunkUtils.toSectionRelativeCoordinate(y), ChunkUtils.toSectionRelativeCoordinate(z), block.stateId());
|
||||
.set(toSectionRelativeCoordinate(x), toSectionRelativeCoordinate(y), toSectionRelativeCoordinate(z), block.stateId());
|
||||
|
||||
final int index = ChunkUtils.getBlockIndex(x, y, z);
|
||||
// Handler
|
||||
@ -89,9 +91,9 @@ public class DynamicChunk extends Chunk {
|
||||
this.chunkCache.invalidate();
|
||||
Section section = getSectionAt(y);
|
||||
section.biomePalette().set(
|
||||
ChunkUtils.toSectionRelativeCoordinate(x) / 4,
|
||||
ChunkUtils.toSectionRelativeCoordinate(y) / 4,
|
||||
ChunkUtils.toSectionRelativeCoordinate(z) / 4, biome.id());
|
||||
toSectionRelativeCoordinate(x) / 4,
|
||||
toSectionRelativeCoordinate(y) / 4,
|
||||
toSectionRelativeCoordinate(z) / 4, biome.id());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -130,7 +132,7 @@ public class DynamicChunk extends Chunk {
|
||||
// Retrieve the block from state id
|
||||
final Section section = getSectionAt(y);
|
||||
final int blockStateId = section.blockPalette()
|
||||
.get(ChunkUtils.toSectionRelativeCoordinate(x), y, ChunkUtils.toSectionRelativeCoordinate(z));
|
||||
.get(toSectionRelativeCoordinate(x), toSectionRelativeCoordinate(y), toSectionRelativeCoordinate(z));
|
||||
return Objects.requireNonNullElse(Block.fromStateId((short) blockStateId), Block.AIR);
|
||||
}
|
||||
|
||||
@ -138,7 +140,7 @@ public class DynamicChunk extends Chunk {
|
||||
public @NotNull Biome getBiome(int x, int y, int z) {
|
||||
final Section section = getSectionAt(y);
|
||||
final int id = section.biomePalette()
|
||||
.get(ChunkUtils.toSectionRelativeCoordinate(x) / 4, y / 4, ChunkUtils.toSectionRelativeCoordinate(z) / 4);
|
||||
.get(toSectionRelativeCoordinate(x) / 4, y / 4, toSectionRelativeCoordinate(z) / 4);
|
||||
return MinecraftServer.getBiomeManager().getById(id);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user