fix buffered world offset

This commit is contained in:
dfsek
2022-01-05 13:51:52 -07:00
parent 7b9891150d
commit 5e77878427
2 changed files with 11 additions and 7 deletions

View File

@@ -44,7 +44,7 @@ public class BufferedWorld implements WritableWorld {
@Override
public BlockState getBlockState(int x, int y, int z) {
return readInterceptor.read(x, y, z, delegate);
return readInterceptor.read(x + offsetX, y + offsetY, z + offsetZ, delegate);
}
@Override
@@ -84,7 +84,7 @@ public class BufferedWorld implements WritableWorld {
@Override
public void setBlockState(int x, int y, int z, BlockState data, boolean physics) {
writeInterceptor.write(x, y, z, data, delegate, physics);
writeInterceptor.write(x + offsetX, y + offsetY, z + offsetZ, data, delegate, physics);
}
@Override
@@ -148,9 +148,9 @@ public class BufferedWorld implements WritableWorld {
public BufferedWorld build() {
return new BufferedWorld(delegate,
x,
y,
z,
this.x,
this.y,
this.z,
Objects.requireNonNullElse(readInterceptor, Interceptors.readThrough()),
Objects.requireNonNullElse(writeInterceptor, Interceptors.writeThrough()));
}

View File

@@ -6,7 +6,6 @@ import com.dfsek.terra.api.entity.EntityType;
import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.util.vector.Vector3Int;
import com.dfsek.terra.api.world.chunk.generation.util.Column;
import com.dfsek.terra.api.world.util.Interceptors;
public interface WritableWorld extends ReadableWorld {
@@ -56,7 +55,12 @@ public interface WritableWorld extends ReadableWorld {
Entity spawnEntity(double x, double y, double z, EntityType entityType);
default BufferedWorld buffer(int offsetX, int offsetY, int offsetZ) {
return BufferedWorld.builder(this).offsetX(offsetX).offsetY(offsetY).offsetZ(offsetZ).build();
return BufferedWorld
.builder(this)
.offsetX(offsetX)
.offsetY(offsetY)
.offsetZ(offsetZ)
.build();
}
default BufferedWorld.Builder buffer() {