diff --git a/src/main/java/net/minestom/server/collision/BlockCollision.java b/src/main/java/net/minestom/server/collision/BlockCollision.java index 6221b9bc4..001cd90c1 100644 --- a/src/main/java/net/minestom/server/collision/BlockCollision.java +++ b/src/main/java/net/minestom/server/collision/BlockCollision.java @@ -344,9 +344,9 @@ final class BlockCollision { // If player is at block 40 we cannot place a block at block 39 with side length 1 because the block will be in [39, 40] // For this reason we subtract a small amount from the player position Point playerPos = entity.getPosition().add(entity.getPosition().sub(blockPos).mul(0.0000001)); - intersects = b.registry().shape().intersectBox(playerPos.sub(blockPos), entity.getBoundingBox()); + intersects = b.registry().collisionShape().intersectBox(playerPos.sub(blockPos), entity.getBoundingBox()); } else { - intersects = b.registry().shape().intersectBox(entity.getPosition().sub(blockPos), entity.getBoundingBox()); + intersects = b.registry().collisionShape().intersectBox(entity.getPosition().sub(blockPos), entity.getBoundingBox()); } if (intersects) return entity; } @@ -374,7 +374,7 @@ final class BlockCollision { boolean hitBlock = false; if (checkBlock.isSolid()) { final Vec blockPos = new Vec(blockX, blockY, blockZ); - hitBlock = checkBlock.registry().shape().intersectBoxSwept(entityPosition, entityVelocity, blockPos, boundingBox, finalResult); + hitBlock = checkBlock.registry().collisionShape().intersectBoxSwept(entityPosition, entityVelocity, blockPos, boundingBox, finalResult); } return hitBlock; } diff --git a/src/main/java/net/minestom/server/entity/Entity.java b/src/main/java/net/minestom/server/entity/Entity.java index 00cc6f35e..e43fb831b 100644 --- a/src/main/java/net/minestom/server/entity/Entity.java +++ b/src/main/java/net/minestom/server/entity/Entity.java @@ -666,7 +666,7 @@ public class Entity implements Viewable, Tickable, Schedulable, Snapshotable, Ev // Move a small amount towards the entity. If the entity is within 0.01 blocks of the block, touch will trigger Vec blockPos = new Vec(x, y, z); Point blockEntityVector = (blockPos.sub(position)).normalize().mul(0.01); - if (block.registry().shape().intersectBox(position.sub(blockPos).add(blockEntityVector), boundingBox)) { + if (block.registry().collisionShape().intersectBox(position.sub(blockPos).add(blockEntityVector), boundingBox)) { handler.onTouch(new BlockHandler.Touch(block, instance, new Vec(x, y, z), this)); } } diff --git a/src/main/java/net/minestom/server/instance/light/BlockLightCompute.java b/src/main/java/net/minestom/server/instance/light/BlockLightCompute.java index 560598d58..d21602e9d 100644 --- a/src/main/java/net/minestom/server/instance/light/BlockLightCompute.java +++ b/src/main/java/net/minestom/server/instance/light/BlockLightCompute.java @@ -65,7 +65,7 @@ final class BlockLightCompute { final int newIndex = xO | (zO << 4) | (yO << 8); final Block currentBlock = Objects.requireNonNullElse(blocks[x | (z << 4) | (y << 8)], Block.AIR); final Block propagatedBlock = Objects.requireNonNullElse(blocks[newIndex], Block.AIR); - if (currentBlock.registry().shape().isOccluded(propagatedBlock.registry().shape(), face)) + if (currentBlock.registry().collisionShape().isOccluded(propagatedBlock.registry().collisionShape(), face)) continue; if (getLight(lightArray, newIndex) + 2 <= lightLevel) { placeLight(lightArray, newIndex, newLightLevel); diff --git a/src/main/java/net/minestom/server/registry/Registry.java b/src/main/java/net/minestom/server/registry/Registry.java index 9b21ccc13..1d09ec128 100644 --- a/src/main/java/net/minestom/server/registry/Registry.java +++ b/src/main/java/net/minestom/server/registry/Registry.java @@ -275,7 +275,7 @@ public final class Registry { return materialSupplier.get(); } - public Shape shape() { + public Shape collisionShape() { return shape; } diff --git a/src/test/java/net/minestom/server/instance/BlockTest.java b/src/test/java/net/minestom/server/instance/BlockTest.java index aa70bff72..5fa43d523 100644 --- a/src/test/java/net/minestom/server/instance/BlockTest.java +++ b/src/test/java/net/minestom/server/instance/BlockTest.java @@ -79,8 +79,8 @@ public class BlockTest { @Test public void testShape() { - Point start = Block.LANTERN.registry().shape().relativeStart(); - Point end = Block.LANTERN.registry().shape().relativeEnd(); + Point start = Block.LANTERN.registry().collisionShape().relativeStart(); + Point end = Block.LANTERN.registry().collisionShape().relativeEnd(); assertEquals(start, new Vec(0.312, 0, 0.312)); assertEquals(end, new Vec(0.687, 0.562, 0.687)); diff --git a/src/test/java/net/minestom/server/instance/light/BlockIsOccludedTest.java b/src/test/java/net/minestom/server/instance/light/BlockIsOccludedTest.java index 055065bd5..0b3c79853 100644 --- a/src/test/java/net/minestom/server/instance/light/BlockIsOccludedTest.java +++ b/src/test/java/net/minestom/server/instance/light/BlockIsOccludedTest.java @@ -13,7 +13,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class BlockIsOccludedTest { @Test public void blockAir() { - Shape airBlock = Block.AIR.registry().shape(); + Shape airBlock = Block.AIR.registry().collisionShape(); for (BlockFace face : BlockFace.values()) { assertFalse(airBlock.isOccluded(airBlock, face)); @@ -22,8 +22,8 @@ public class BlockIsOccludedTest { @Test public void blockLantern() { - Shape shape = Block.LANTERN.registry().shape(); - Shape airBlock = Block.AIR.registry().shape(); + Shape shape = Block.LANTERN.registry().collisionShape(); + Shape airBlock = Block.AIR.registry().collisionShape(); for (BlockFace face : BlockFace.values()) { assertFalse(shape.isOccluded(airBlock, face)); @@ -32,8 +32,8 @@ public class BlockIsOccludedTest { @Test public void blockCauldron() { - Shape shape = Block.CAULDRON.registry().shape(); - Shape airBlock = Block.AIR.registry().shape(); + Shape shape = Block.CAULDRON.registry().collisionShape(); + Shape airBlock = Block.AIR.registry().collisionShape(); for (BlockFace face : BlockFace.values()) { assertFalse(shape.isOccluded(airBlock, face)); @@ -42,8 +42,8 @@ public class BlockIsOccludedTest { @Test public void blockSlabBottomAir() { - Shape shape = Block.SANDSTONE_SLAB.registry().shape(); - Shape airBlock = Block.AIR.registry().shape(); + Shape shape = Block.SANDSTONE_SLAB.registry().collisionShape(); + Shape airBlock = Block.AIR.registry().collisionShape(); assertTrue(shape.isOccluded(airBlock, BlockFace.BOTTOM)); @@ -56,8 +56,8 @@ public class BlockIsOccludedTest { @Test public void blockSlabTopEnchantingTable() { - Shape shape1 = Block.SANDSTONE_SLAB.withProperty("type", "top").registry().shape(); - Shape shape2 = Block.ENCHANTING_TABLE.registry().shape(); + Shape shape1 = Block.SANDSTONE_SLAB.withProperty("type", "top").registry().collisionShape(); + Shape shape2 = Block.ENCHANTING_TABLE.registry().collisionShape(); assertFalse(shape1.isOccluded(shape2, BlockFace.BOTTOM)); @@ -73,9 +73,9 @@ public class BlockIsOccludedTest { Shape shape = Block.SANDSTONE_STAIRS.withProperties(Map.of( "facing", "west", "half", "bottom", - "shape", "straight")).registry().shape(); + "shape", "straight")).registry().collisionShape(); - Shape airBlock = Block.AIR.registry().shape(); + Shape airBlock = Block.AIR.registry().collisionShape(); assertTrue(shape.isOccluded(airBlock, BlockFace.WEST)); assertTrue(shape.isOccluded(airBlock, BlockFace.BOTTOM)); @@ -88,8 +88,8 @@ public class BlockIsOccludedTest { @Test public void blockSlabBottomStone() { - Shape shape = Block.SANDSTONE_SLAB.registry().shape(); - Shape stoneBlock = Block.STONE.registry().shape(); + Shape shape = Block.SANDSTONE_SLAB.registry().collisionShape(); + Shape stoneBlock = Block.STONE.registry().collisionShape(); assertTrue(shape.isOccluded(stoneBlock, BlockFace.BOTTOM)); assertTrue(shape.isOccluded(stoneBlock, BlockFace.NORTH)); @@ -101,8 +101,8 @@ public class BlockIsOccludedTest { @Test public void blockStone() { - Shape shape = Block.STONE.registry().shape(); - Shape airBlock = Block.AIR.registry().shape(); + Shape shape = Block.STONE.registry().collisionShape(); + Shape airBlock = Block.AIR.registry().collisionShape(); for (BlockFace face : BlockFace.values()) { assertTrue(shape.isOccluded(airBlock, face)); @@ -111,8 +111,8 @@ public class BlockIsOccludedTest { @Test public void blockStair() { - Shape shape = Block.SANDSTONE_STAIRS.registry().shape(); - Shape airBlock = Block.AIR.registry().shape(); + Shape shape = Block.SANDSTONE_STAIRS.registry().collisionShape(); + Shape airBlock = Block.AIR.registry().collisionShape(); assertTrue(shape.isOccluded(airBlock, BlockFace.NORTH)); assertTrue(shape.isOccluded(airBlock, BlockFace.BOTTOM)); @@ -125,8 +125,8 @@ public class BlockIsOccludedTest { @Test public void blockSlab() { - Shape shape = Block.SANDSTONE_SLAB.registry().shape(); - Shape airBlock = Block.AIR.registry().shape(); + Shape shape = Block.SANDSTONE_SLAB.registry().collisionShape(); + Shape airBlock = Block.AIR.registry().collisionShape(); assertTrue(shape.isOccluded(airBlock, BlockFace.BOTTOM)); @@ -139,8 +139,8 @@ public class BlockIsOccludedTest { @Test public void blockSlabBottomAndSlabTop() { - Shape shape1 = Block.SANDSTONE_SLAB.registry().shape(); - Shape shape2 = Block.SANDSTONE_SLAB.withProperty("type", "top").registry().shape(); + Shape shape1 = Block.SANDSTONE_SLAB.registry().collisionShape(); + Shape shape2 = Block.SANDSTONE_SLAB.withProperty("type", "top").registry().collisionShape(); assertFalse(shape1.isOccluded(shape2, BlockFace.TOP)); @@ -153,7 +153,7 @@ public class BlockIsOccludedTest { @Test public void blockSlabBottomAndSlabBottom() { - Shape shape = Block.SANDSTONE_SLAB.registry().shape(); + Shape shape = Block.SANDSTONE_SLAB.registry().collisionShape(); assertTrue(shape.isOccluded(shape, BlockFace.BOTTOM)); assertTrue(shape.isOccluded(shape, BlockFace.TOP)); @@ -166,8 +166,8 @@ public class BlockIsOccludedTest { @Test public void blockStairAndSlabBottom() { - Shape shape1 = Block.STONE_STAIRS.registry().shape(); - Shape shape2 = Block.SANDSTONE_SLAB.registry().shape(); + Shape shape1 = Block.STONE_STAIRS.registry().collisionShape(); + Shape shape2 = Block.SANDSTONE_SLAB.registry().collisionShape(); assertTrue(shape1.isOccluded(shape2, BlockFace.BOTTOM)); assertTrue(shape1.isOccluded(shape2, BlockFace.NORTH)); @@ -180,8 +180,8 @@ public class BlockIsOccludedTest { @Test public void blockStairAndSlabTop() { - Shape shape1 = Block.STONE_STAIRS.registry().shape(); - Shape shape2 = Block.SANDSTONE_SLAB.withProperty("type", "top").registry().shape(); + Shape shape1 = Block.STONE_STAIRS.registry().collisionShape(); + Shape shape2 = Block.SANDSTONE_SLAB.withProperty("type", "top").registry().collisionShape(); assertTrue(shape1.isOccluded(shape2, BlockFace.NORTH)); assertTrue(shape1.isOccluded(shape2, BlockFace.BOTTOM));