Jump to content

[1.18.2] How to get the clicked side of horizontal facing block


J3ramy

Recommended Posts

Hey guys,

I hope you can help me.

 

Currently, I am creating a block and open a gui inside the use()-method. Now, I want to add a side check - So, that always the front side opens the gui.

I looked at the parameters but I wasn't able to find the side attribute anymore (which was available in older versions). Does it still exists or is it replaced by a new one?

My block has a horizontal facing property, so this has to be included as well

 

Thanks for your help,

J3ramy

Link to comment
Share on other sites

@MistaOmegathanks for your suggestion!

 

I looked at what you said. For now I use the current block direction and the hit result direction.

So, my method for recognizing the front face is this:

private boolean isFrontFace(Direction blockDirection, Direction hitDirection){
        return blockDirection == hitDirection;
    }

And in my use()-method I call it:

if(this.isFrontFace(pState.getValue(HORIZONTAL_FACING), pHit.getDirection()))
  ...

 

Maybe there are different ways to check it, but this works for me :)

 

Thank you!

Edited by J3ramy
  • Like 1
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.