Jump to content

[SOLVED] [1.16.4] random values not sync between client and server


theagente00g

Recommended Posts

I was trying to make a food with a chance to play a sound then give potions effects when eaten.

I was using event.getEntity().world.rand.nextInt(2) to generate the random number, but the values from client and server are different.

How do I make them be the same?

Also, there is a way to the server side call a function in the client side?

Edited by theagente00g
Link to comment
Share on other sites

5 minutes ago, theagente00g said:

I was trying to make a food with a chance to play a sound then give potions effects when eaten.

I was using event.getEntity().world.rand.nextInt(2) to generate the random number, but the values from client and server are different.

How do I make them be the same?

do you need to run this on the client? runninng only on the server should be fine

 

6 minutes ago, theagente00g said:

Also, there is a way to the server side call a function in the client side?

what's the context?

Link to comment
Share on other sites

 

7 minutes ago, kiou.23 said:

do you need to run this on the client? runninng only on the server should be fine

Probably since if I just run It in the server, I cant play the sound, and the potions for some reason stay at 0:00 time and never disappear.

 

9 minutes ago, kiou.23 said:

what's the context?

For example, in a event such as LivingEntityUseItemEvent.Finish the server side call a function which would play a sound in the client side

Link to comment
Share on other sites

16 minutes ago, theagente00g said:

 

Probably since if I just run It in the server, I cant play the sound

you can play sounds from the server using ServerWorld#playSound

 

16 minutes ago, theagente00g said:

and the potions for some reason stay at 0:00 time and never disappear.

I haven't done anything with potion effects, so I'm not sure I could help you with this. but post some code nevertheless

  • Like 1
Link to comment
Share on other sites

  • theagente00g changed the title to [SOLVED] [1.16.4] random values not sync between client and server

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.