Jump to content

Item right clicked on block function only partially works, only 1 out of 2 blockstates is updated at a time


Guest

Recommended Posts

PasteBin Code

Item PasteBin Code

 

So I have an item that when right clicked on a block (when shift is held) sets it's NBTdata up by one, and loops back around to 0 when the max value is reached. It works fine.

When I right click any block (not shift held down) it places a default state Road Marking block.

 

My intended behavior is to grab the item's NBTdata and player facing position and apply it to the Road Marking block in the world when it is placed.

 

My code partially works, but only 1 of the 2 blockstates is ever updated on the block that is placed. If the "type" blockstate is changed first, only the "facing" blockstate is changed based on which way the player is facing, but if "type" is second, the "facing" blockstate is overwritten by the "type" blockstate, causing the block to only face it's default direction.

I'm using the method setBlock() from the LevelAccessor to do this behavior.

 

I'm not sure what I'm doing wrong here, because both blockstates are setup properly. I've included the function in a pastebin link. The pastebin code shows the code if "type" is applied to the block at the current block location after the "facing" blockstate is applied.

Also, there is a pastebin for the Item that does the right click actions.

Edited by CreativeMasterBonin
Link to comment
Share on other sites

I understand that part, I get the position and states of the block from the Level... and that only 1 state can be changed at a time... but...

The main problem is that I want the block to not only face the player when placed, but also be the correct state based on the Item's NBTdata.

 

I want the setBlock() method to basically Place a block that faces the player and make's it's 'TYPE' property correspond to the Item's 'marking_type' nbt data.

 

I've looked through Level & Block methods and none seem to really do what I want them to do.

If I cannot change 2 properties of a block at the same time, without resetting one of the blockstates, then I'm stumped.

Edited by CreativeMasterBonin
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.