fix: allow placing at min y level

(cherry picked from commit 1554487748)
This commit is contained in:
mworzala 2023-12-08 22:19:44 +02:00 committed by Matt Worzala
parent 6d229a0601
commit 1c141e34c1
2 changed files with 18 additions and 1 deletions

View File

@ -115,7 +115,7 @@ public class BlockPlacementListener {
}
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.
if (!instance.getWorldBorder().isInside(placementPosition)) {

View File

@ -40,4 +40,21 @@ public class BlockPlaceIntegrationTest {
var placedBlock = instance.getBlock(3, 40, 0);
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);
}
}