Moved .setBlockRel(...) implementation to GenericWritableChunk
This commit is contained in:
parent
e0a03cad1d
commit
a95bdf1efe
@ -28,7 +28,6 @@ import java.util.Objects;
|
||||
|
||||
import glm.vec._3.i.Vec3i;
|
||||
|
||||
import ru.windcorp.progressia.common.util.Vectors;
|
||||
import ru.windcorp.progressia.common.world.block.BlockData;
|
||||
import ru.windcorp.progressia.common.world.generic.GenericChunk;
|
||||
import ru.windcorp.progressia.common.world.generic.GenericWritableChunk;
|
||||
@ -94,14 +93,6 @@ public class ChunkData
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockRel(Vec3i relativeBlockInChunk, BlockData block, boolean notify) {
|
||||
Vec3i absoluteBlockInChunk = Vectors.grab3i();
|
||||
resolve(relativeBlockInChunk, absoluteBlockInChunk);
|
||||
setBlock(absoluteBlockInChunk, block, notify);
|
||||
Vectors.release(absoluteBlockInChunk);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileDataStack getTilesOrNull(Vec3i blockInChunk, BlockFace face) {
|
||||
|
@ -105,14 +105,14 @@ public interface GenericChunk<
|
||||
|
||||
boolean hasTiles(Vec3i blockInChunk, BlockFace face);
|
||||
|
||||
default Vec3i resolve(Vec3i relativeBlockInChunk, Vec3i output) {
|
||||
default Vec3i resolve(Vec3i relativeCoords, Vec3i output) {
|
||||
if (output == null) {
|
||||
output = new Vec3i();
|
||||
}
|
||||
|
||||
final int offset = BLOCKS_PER_CHUNK - 1;
|
||||
|
||||
output.set(relativeBlockInChunk.x, relativeBlockInChunk.y, relativeBlockInChunk.z);
|
||||
output.set(relativeCoords.x, relativeCoords.y, relativeCoords.z);
|
||||
output.mul(2).sub(offset);
|
||||
|
||||
AxisRotations.resolve(output, getUp(), output);
|
||||
|
@ -18,6 +18,7 @@
|
||||
package ru.windcorp.progressia.common.world.generic;
|
||||
|
||||
import glm.vec._3.i.Vec3i;
|
||||
import ru.windcorp.progressia.common.util.Vectors;
|
||||
|
||||
// @formatter:off
|
||||
public interface GenericWritableChunk<
|
||||
@ -32,6 +33,11 @@ public interface GenericWritableChunk<
|
||||
|
||||
void setBlock(Vec3i posInChunk, B block, boolean notify);
|
||||
|
||||
void setBlockRel(Vec3i relativeBlockInChunk, B block, boolean notify);
|
||||
default void setBlockRel(Vec3i relativeBlockInChunk, B block, boolean notify) {
|
||||
Vec3i absoluteBlockInChunk = Vectors.grab3i();
|
||||
resolve(relativeBlockInChunk, absoluteBlockInChunk);
|
||||
setBlock(absoluteBlockInChunk, block, notify);
|
||||
Vectors.release(absoluteBlockInChunk);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user