Falling block can place directional block state at invalid position
The bug
Falling block entities can place directional block states at invalid positions. For example a lever attached to the ceiling is placed without ceiling.
How to reproduce
Use the following command while standing on a block a lever can be placed on, like for example stone
/summon falling_block ~ ~ ~ {Time:1,BlockState:{Name:"minecraft:lever"}}
Code analysis
Based on 1.11.2 decompiled using MCP 9.35 rc1
The method net.minecraft.entity.item.EntityFallingBlock.onUpdate() calls the method net.minecraft.world.World.mayPlace(Block, BlockPos, boolean, EnumFacing, Entity) always with EnumFacing.UP but places the stored block state which is not necessarily facing upwards.
This could maybe be solved by adding a general method boolean isStateValidForPosition(World world, IBlockState blockState, BlockPos position) since many blocks currently have a method similar to this anyways which is called when they are updated.
2017-03-22, 10:07 PM
2020-06-04, 02:03 PM
2020-06-04, 02:03 PM
1
2
block, blockstate, button, directional, falling_block, lever, position
-