Blocks can't be placed into mobs and other building blockers (Level.isUnobstructed)

BlockItem.canPlace now checks every entity whose blocksBuilding is set: mobs,
armor stands (not markers), boats, minecarts, end crystals, primed TNT and
falling blocks, not only players.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-21 16:14:33 +02:00
parent 8186baba8b
commit 403fead15d
4 changed files with 126 additions and 22 deletions
@@ -232,7 +232,9 @@ public final class VanillaBlockUpdateOracle {
@Override public boolean isRaining() { return raining; }
@Override public boolean isThundering() { return thundering; }
@Override public boolean isRainingAt(BlockPos p) { return raining; }
@Override public boolean isUnobstructed(BlockState state, BlockPos pos, net.minecraft.world.phys.shapes.CollisionContext c) { return true; }
// With entities (a harness opted in) vanilla's own check runs on them
// (CollisionGetter.isUnobstructed, then EntityGetter's blocksBuilding test).
@Override public boolean isUnobstructed(BlockState state, BlockPos pos, net.minecraft.world.phys.shapes.CollisionContext c) { return entities == null || super.isUnobstructed(state, pos, c); }
@Override public boolean isUnobstructed(Entity entity) { return true; }
// Entities exist only when a harness opts in (the dispenser oracle);
// they are searched in the order they were added, as within one entity section.