Skip to content

ItemStack not passed to BlockItemUseContext when attempting to place BlockItem #158

@Frinn38

Description

@Frinn38

When this method is called (by the builder from RFTools Builder for example) the BlockItemUseContext never receive the ItemStack being placed.
So when BlockItem#place is called the BlockItem has no way to know exactly what ItemStack is being placed, this cause issues when the placed block depends on the nbt of the ItemStack.

public static BlockState placeStackAt(PlayerEntity player, ItemStack blockStack, World world, BlockPos pos, @Nullable BlockState origState) {
BlockRayTraceResult trace = new BlockRayTraceResult(new Vector3d(0, 0, 0), Direction.UP, pos, false);
BlockItemUseContext context = new BlockItemUseContext(new ItemUseContext(player, Hand.MAIN_HAND, trace));
if (blockStack.getItem() instanceof BlockItem) {
BlockItem itemBlock = (BlockItem) blockStack.getItem();
if (origState == null) {
origState = itemBlock.getBlock().getStateForPlacement(context);
if (origState == null) {
// Cannot place!
return null;
}
}
if (itemBlock.place(context).consumesAction()) {
blockStack.shrink(1);
}
return origState;
} else {

Suggested fix : Pass the ItemStack to the BlockItemUseContext or at least set it to the Player's main hand. (or both)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions