mirror of
https://github.com/Minestom/Minestom.git
synced 2024-06-23 04:54:59 +02:00
Remove magic -1 return
This commit is contained in:
parent
f6db75b9aa
commit
200c94c59e
|
@ -124,7 +124,6 @@ public class DynamicChunk extends Chunk {
|
|||
final Section section = sections[ChunkUtils.getChunkCoordinate(y) - minSection];
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,8 +58,8 @@ final class PaletteImpl implements Palette, Cloneable {
|
|||
throw new IllegalArgumentException("Coordinates must be positive");
|
||||
}
|
||||
if (values.length == 0) {
|
||||
// Section is not loaded, can only be air
|
||||
return -1;
|
||||
// Section is not loaded, return default value
|
||||
return 0;
|
||||
}
|
||||
x %= dimension;
|
||||
y %= dimension;
|
||||
|
|
|
@ -24,7 +24,7 @@ public class PaletteTest {
|
|||
public void testPlacement() {
|
||||
for (Palette palette : palettes) {
|
||||
final int dimension = palette.dimension();
|
||||
assertEquals(-1, palette.get(0, 0, 0), "Empty section should return -1");
|
||||
assertEquals(0, palette.get(0, 0, 0), "Default value should be 0");
|
||||
palette.set(0, 0, 0, 64);
|
||||
assertEquals(64, palette.get(0, 0, 0));
|
||||
assertEquals(64, palette.get(dimension, 0, 0), "Coordinate must be rounded to the palette dimension");
|
||||
|
|
Loading…
Reference in New Issue
Block a user