Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-116877

Collision checking during Block placement only uses default state

XMLWordPrintable

    • Confirmed

      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.

            Unassigned Unassigned
            Virtuoel Virtuoel
            Votes:
            5 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: