The bug
Decorative heads, end rods, and shulker boxes sometimes don't place properly on grass and ferns, or the side of snow (the thin kind, not block, and this isn't shown in the video).
How to reproduce
Video demonstrating the issue.
Code analysis
Code analysis by @unknown can be found in this comment.
List of affected blocks
shulker box
end rod
lightning rod
grindstone
heads
(stripped) logs/wood/hyphae/stems
(polished) basalt
bone block
hay block
chain
purpur pillar
quartz pillar
amethyst cluster
amethyst bud
deepslate
Linked issues
is duplicated by 6
relates to 2
Attachments
Comments 25

Confirmed for
1.10.2

Please link to this comment in the description
The following is based on a decompiled version of Minecraft 1.10 using MCP 9.30.
The reason for this is that the method net.minecraft.item.ItemSkull.onItemUse(ItemStack, EntityPlayer, World, BlockPos, EnumHand, EnumFacing, float, float, float)
still uses the direction the placer is clicking on a block even if the block is replaced.
Suggested fix
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
if (facing == EnumFacing.DOWN)
{
return EnumActionResult.FAIL;
}
else
{
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
boolean flag = block.isReplaceable(worldIn, pos);
if (!flag)
{
if (!worldIn.getBlockState(pos).getMaterial().isSolid())
{
return EnumActionResult.FAIL;
}
pos = pos.offset(facing);
}
// Added this
else
{
if (!worldIn.getBlockState(pos.down()).getMaterial().isSolid())
{
return EnumActionResult.FAIL;
}
else {
facing = EnumFacing.UP;
}
}
//...
}
}
Same situations also for the ItemBlock
class.
Suggested fix
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
if (!block.isReplaceable(worldIn, pos))
{
pos = pos.offset(facing);
}
// Added this
else {
facing = EnumFacing.UP;
}
//...
}
Note: There might be more directonal blocks of which the item places the block if the method onItemUse
is called instead of the general ItemBlock
class.

Affects 18w20c

@unknown, ticket is yours now.
Can confirm in 1.17.1.
Can confirm in 1.18.1.
Can confirm in 1.18.2.
Can confirm in 1.19.
Can confirm in 1.19.2.
Confirmed for 15w46a