mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-08-29 13:20:32 +00:00
fix Column erroneously caching
This commit is contained in:
+4
-16
@@ -27,24 +27,18 @@ public class Column<T extends WritableWorld> {
|
|||||||
private final int max;
|
private final int max;
|
||||||
private final T world;
|
private final T world;
|
||||||
|
|
||||||
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(), new BlockState[world.getMaxHeight() - world.getMinHeight()]);
|
this(x, z, world, world.getMinHeight(), world.getMaxHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = cache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getX() {
|
public int getX() {
|
||||||
return x;
|
return x;
|
||||||
@@ -55,13 +49,7 @@ public class Column<T extends WritableWorld> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BlockState getBlock(int y) {
|
public BlockState getBlock(int y) {
|
||||||
int i = y - world.getMinHeight();
|
return world.getBlockState(x, y, z);
|
||||||
BlockState state = cache[i];
|
|
||||||
if(state == null) {
|
|
||||||
state = world.getBlockState(x, y, z);
|
|
||||||
cache[i] = state;
|
|
||||||
}
|
|
||||||
return state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public T getWorld() {
|
public T getWorld() {
|
||||||
@@ -84,7 +72,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, cache);
|
return new Column<>(x, z, world, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BinaryColumn newBinaryColumn(IntToBooleanFunction function) {
|
public BinaryColumn newBinaryColumn(IntToBooleanFunction function) {
|
||||||
|
|||||||
Reference in New Issue
Block a user