mojira.dev
MC-116877

Collision checking during Block placement only uses default state

The bug

When placing blocks, the default state of the block is used to check for collision with entities when deciding if it should be allowed to be placed.

This can lead to some strange valid placement conditions for certain blocks that have different collision boxes depending on state.
Blocks that I've found so far that are affected include Ladders, Fence Gates, Slabs, Anvils, End Rods, and Trapdoors.

Examples

  • Placing Ladders on any side of a Block always succeeds unless an Entity is in the southern part of the Block that the Ladder will occupy, which is the location of the collision box of a north-facing Ladder, which is the default state.

  • You can place upper Slabs intersecting an Entity's collision box if it is standing on a slab and partially intersecting the top of the Block you want to place the Slab in, assuming that Block doesn't have a bottom Slab already.

Code analysis

Based on 1.11.2 decompiled using MCP 9.37
The method net.minecraft.world.World.mayPlace(Block, BlockPos, boolean, EnumFacing, Entity) calls blockIn.getDefaultState().getCollisionBoundingBox(this, pos) and checks if this box intersects with the collision boxes of any Entities at the BlockPos parameter. Replacing the Block parameter with an IBlockState and using it instead of the default state to get the collision box may fix the problem.

Related issues

Comments

Virtuoel

Fixed in 17w47a and up.

Virtuoel

(Unassigned)

Confirmed

anvil, block, blockstate, bounding-box, collision, collision-box, end_rod, entity, fence_gate, ladder, place, placement, slab, trapdoor

Minecraft 1.11.2, Minecraft 17w17b

Minecraft 18w21a

Retrieved