Jump to content

replace a block onItemUse


JoppeGames3

Recommended Posts

 

how to check what block gets right clicked by your item, and then replace it to another block, but with the same blockstate as the first block?

 

I know I have to use the "onItemUse" method but don't know what to put after the 'if'

 

this is what I got so far....

public ActionResultType onItemUse(ItemUseContext context) {
World world = context.getWorld();
    BlockPos blockpos = context.getPos();
    BlockState blockstate = world.getBlockState(blockpos);
    BlockState block = blockstate.getBlockState();
    if (block != null) {

 

Link to comment
Share on other sites

1 minute ago, diesieben07 said:

What do you mean by this? The blockstate includes the block, so if you want the same blockstate that also means its the same block.

I meant same rotation..

2 minutes ago, diesieben07 said:

This check is pointless.

what do I have to check

and how to replace it with another block

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.