From 332a8536be384c309b4a8f59801c8681ddd6245d Mon Sep 17 00:00:00 2001 From: LeoDog896 Date: Sat, 11 Sep 2021 17:08:03 -0400 Subject: [PATCH] Use absolute coordinates --- .../server/instance/DynamicChunk.java | 8 +++---- .../server/instance/block/BlockHandler.java | 21 +++++-------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/main/java/net/minestom/server/instance/DynamicChunk.java b/src/main/java/net/minestom/server/instance/DynamicChunk.java index c575e2211..af20f9c25 100644 --- a/src/main/java/net/minestom/server/instance/DynamicChunk.java +++ b/src/main/java/net/minestom/server/instance/DynamicChunk.java @@ -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)); }); } diff --git a/src/main/java/net/minestom/server/instance/block/BlockHandler.java b/src/main/java/net/minestom/server/instance/block/BlockHandler.java index 7cfb4c1d9..34d6967c1 100644 --- a/src/main/java/net/minestom/server/instance/block/BlockHandler.java +++ b/src/main/java/net/minestom/server/instance/block/BlockHandler.java @@ -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; } }