Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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?

  • Author

 

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

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

  • Author

Hey, everything is working, thanks : ).


About the potions effects, probably I was inverting the world.isRemote(), haha, whoops.

  • 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...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.