Skip to content

Block model change if block on top #1924

Discussion options

You must be logged in to vote

But it seems to be completely wrong :D

You shouldn't be setting the block state directly. You return it to the caller.

The caller will:

  • check if the state has actually changed which avoids unnecessary updates and even potentially infinite loops
  • set the update flags to do the correct processing/notifications
  • other book keeping stuff (like dropping the block item if you change the block state to "air")

If you want a simple example, look at how the repeater block sets its (un)locked state.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@tenDeeZed
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by tenDeeZed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants