mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-26 05:50:08 +00:00
store cache between same column instances with different clamps
This commit is contained in:
1 parent
46c03438b3
commit
21ec335db9
1 file changed
+7
-3
+7
-3
@@ -30,16 +30,20 @@ public class Column<T extends WritableWorld> {
|
|||||||
private final BlockState[] cache;
|
private final BlockState[] cache;
|
||||||
|
|
||||||
public Column(int x, int z, T world) {
|
public Column(int x, int z, T world) {
|
||||||
this(x, z, world, world.getMinHeight(), world.getMaxHeight());
|
this(x, z, world, world.getMinHeight(), world.getMaxHeight(), new BlockState[world.getMaxHeight() - world.getMinHeight()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Column(int x, int z, T world, int min, int max) {
|
public Column(int x, int z, T world, int min, int max) {
|
||||||
|
this(x, z, world, min, max, new BlockState[world.getMaxHeight() - world.getMinHeight()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Column(int x, int z, T world, int min, int max, BlockState[] cache) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.cache = new BlockState[world.getMaxHeight() - world.getMinHeight()];
|
this.cache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getX() {
|
public int getX() {
|
||||||
@@ -80,7 +84,7 @@ public class Column<T extends WritableWorld> {
|
|||||||
|
|
||||||
public Column<T> clamp(int min, int max) {
|
public Column<T> clamp(int min, int max) {
|
||||||
if(min >= max) throw new IllegalArgumentException("Min greater than or equal to max: " + min + ", " + max);
|
if(min >= max) throw new IllegalArgumentException("Min greater than or equal to max: " + min + ", " + max);
|
||||||
return new Column<>(x, z, world, min, max);
|
return new Column<>(x, z, world, min, max, cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BinaryColumn newBinaryColumn(IntToBooleanFunction function) {
|
public BinaryColumn newBinaryColumn(IntToBooleanFunction function) {
|
||||||
|
|||||||
Reference in new issue
Block a user