Use absolute coordinates

This commit is contained in:
LeoDog896 2021-09-11 17:08:03 -04:00
parent 888405c54c
commit 332a8536be
2 changed files with 9 additions and 20 deletions

View File

@ -93,11 +93,11 @@ public class DynamicChunk extends Chunk {
final Block block = entry.getValue();
final BlockHandler handler = block.handler();
if (handler == null) return;
final int x = ChunkUtils.blockIndexToChunkPositionX(index);
final int y = ChunkUtils.blockIndexToChunkPositionY(index);
final int z = ChunkUtils.blockIndexToChunkPositionZ(index);
final int x = ChunkUtils.blockIndexToPositionX(index, chunkX);
final int y = ChunkUtils.blockIndexToPositionY(index);
final int z = ChunkUtils.blockIndexToPositionZ(index, chunkZ);
final Vec blockPosition = new Vec(x, y, z);
handler.tick(new BlockHandler.Tick(block, instance, blockPosition, this));
handler.tick(new BlockHandler.Tick(block, instance, blockPosition));
});
}

View File

@ -271,15 +271,13 @@ public interface BlockHandler {
class Tick {
private final Block block;
private final Instance instance;
private final Point relativeBlockPosition;
private final DynamicChunk chunk;
private final Point blockPosition;
@ApiStatus.Internal
public Tick(Block block, Instance instance, Point relativeBlockPosition, DynamicChunk chunk) {
public Tick(Block block, Instance instance, Point blockPosition) {
this.block = block;
this.instance = instance;
this.relativeBlockPosition = relativeBlockPosition;
this.chunk = chunk;
this.blockPosition = blockPosition;
}
public @NotNull Block getBlock() {
@ -290,17 +288,8 @@ public interface BlockHandler {
return instance;
}
/**
* Gets the block position relative to this {@link Tick}'s {@link DynamicChunk}
*
* @return The relative block position to this Chunk
*/
public @NotNull Point getRelativeBlockPosition() {
return relativeBlockPosition;
}
public @NotNull DynamicChunk getChunk() {
return chunk;
public @NotNull Point getBlockPosition() {
return blockPosition;
}
}