Posted March 31, 20214 yr 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 March 31, 20214 yr by theagente00g
March 31, 20214 yr 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?
March 31, 20214 yr 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
March 31, 20214 yr 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
March 31, 20214 yr Author Hey, everything is working, thanks : ). About the potions effects, probably I was inverting the world.isRemote(), haha, whoops.
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.