Jump to content

Recommended Posts

Posted

Distilling the crux of another, ignored thread:

 

If my mod changes a blockstate on the server (authoritative) thread, then how / when / where does that updated state get transmitted to the client? Is the client expected / trusted to calculate the same state-change at the same time? Is there a packet sent?

 

The problem I'm having is that my custom pressure plate is not rendering the stepped-on state. Oddly, the bounding box changes height, but the rendering remains high, and the state value remains at the default value. Vanilla p-plates receive the "powered" state client-side, but my custom p-plates do not.

 

If curious, see p-plates thread

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted
World#setBlockState(BlockPos pos, IBlockState newState, int flags)

will send the change to the client if flag 2 is present (i.e.

(flags & 2) != 0

).

World#setBlockState(BlockPos, IBlockState)

calls the other overload with 3 as the

flags

argument, which means flag 1 (notify neighbours) + flag 2 (send change to client).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

I've checked your code in the other thread and one thing that I could say is that you should keep getStateFromMeta / getMetaFromState in sync with each other (A set of states give you A metadata value and A metadata value give you A set of states) and have them working only with states that will get saved on world data files.

 

You should handle states that are computed at runtime (like your POWERED state) by overriding getActualState for your block. So in your particular case you should let the base class handle getStateFromMeta / getMetaFromState and inject your POWERED state using getActualState

 

I don't know if you use it elsewere in your code but also keep in mind that world.getBlockState return an IBlockState based on actual data saved in the chunk, ie the ones rappresented by the metadata so if you also need to check for your POWERED state, you should pass the IBlockState returned by getBlockState to your implementation of getActualState (or relay only to the SIGNAL state to compute the POWERED state locally)

 

Z

 

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.