Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Frinn38 opened this issue Jun 22, 2023 · 0 comments

Comments

@Frinn38
Copy link

Frinn38 commented Jun 22, 2023

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)

@Frinn38 Frinn38 changed the title ItemStack not passed to BlockItemUseContext when attempting to place block ItemStack not passed to BlockItemUseContext when attempting to place BlockItem Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant