mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
fix: allow placing at min y level
This commit is contained in:
parent
a22d769740
commit
1554487748
@ -115,7 +115,7 @@ public class BlockPlacementListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (placementPosition.y() >= instance.getDimensionType().getMaxY()
|
if (placementPosition.y() >= instance.getDimensionType().getMaxY()
|
||||||
|| placementPosition.y() <= instance.getDimensionType().getMinY()) return;
|
|| placementPosition.y() < instance.getDimensionType().getMinY()) return;
|
||||||
|
|
||||||
// Ensure that the final placement position is inside the world border.
|
// Ensure that the final placement position is inside the world border.
|
||||||
if (!instance.getWorldBorder().isInside(placementPosition)) {
|
if (!instance.getWorldBorder().isInside(placementPosition)) {
|
||||||
|
@ -40,4 +40,21 @@ public class BlockPlaceIntegrationTest {
|
|||||||
var placedBlock = instance.getBlock(3, 40, 0);
|
var placedBlock = instance.getBlock(3, 40, 0);
|
||||||
assertEquals(Block.AIR, placedBlock);
|
assertEquals(Block.AIR, placedBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testPlacementAtMinus64(Env env) {
|
||||||
|
Instance instance = env.createFlatInstance();
|
||||||
|
var player = env.createPlayer(instance, new Pos(0, -64, 0));
|
||||||
|
player.setItemInHand(Player.Hand.MAIN, ItemStack.of(Material.STONE, 5));
|
||||||
|
env.tick(); // World border tick to update distance
|
||||||
|
|
||||||
|
// Should be air, then we place
|
||||||
|
assertEquals(Block.AIR, instance.getBlock(3, -64, 0));
|
||||||
|
var placePacket = new ClientPlayerBlockPlacementPacket(Player.Hand.MAIN, new Pos(3, -64, 0), BlockFace.TOP, 0.5f, 0.5f, 0.5f, false, 1);
|
||||||
|
BlockPlacementListener.listener(placePacket, player);
|
||||||
|
|
||||||
|
// Should be stone.
|
||||||
|
var placedBlock = instance.getBlock(3, -64, 0);
|
||||||
|
assertEquals(Block.STONE, placedBlock);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user