Jump to content

[1.7.10] how do I know when I need the world to be client or server?


kauan99

Recommended Posts

some methods get invoked by both client and server. The ones I'm struggling with at the moment is ItemSword.onUpdate and ArmorItem.onArmorTick.

 

I want to add potion effects to the player while he's holding/wearing an item. But I don't want to do that every tick so I set the potion effect to last a fixed amount of ticks and I perform the check again after that same amount of ticks. Basically, I do entity.addPotionEffect for every Potion on every armor item the player is wearing and also the weapon they're holding, setting the duration of the effect to the next time I will tick the item. Is this supposed to be done server side or client side? If I do it on both sides I get a few weird behaviors like effects lasting longer than they should. I'm currently doing it only when world.isRemote == false (i.e. server side). Is this right?

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Link to comment
Share on other sites

Most things should either be done only on the server (if a packet is automatically sent to the clients) or on both sides (if a packet isn't automatically sent).

 

In this case, the server will automatically send a packet to the clients when you add, change or remove a potion effect; so you only need to do it on the server.

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.

Link to comment
Share on other sites

I see. sometimes the client displays the effect ran out, even though it's probably there, because I'm adding it before it can run out. that's because the client haven't received the packet yet right? in those cases, is the potion effect actually active? if such effect was to reduce damage amount from a specific source during OnLivingHurt event, then it would, no matter what the client would think, since that event is only fired on server side. is this correct?

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Link to comment
Share on other sites

Yes, the server is the authority on pretty much any calculation; including damage. As long as the potion is active on the server, its effects should work.

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.

Link to comment
Share on other sites

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.