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

So, this is more of a brainstorm - I have some general idea about how I could accomplish some implementation of this. However, I am always keen to hear what people think and if they have any better/more sophisticated methods!

 

Item: A token which applies the swiftness potion buff when in close proximity (4 blocks) from a Mob.

 

player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 50, 1));

 

Issues: The event I was going to use onPlayerUpdate(PlayerTickEvent event) is @SideOnly(Side.CLIENT)

 

My initial thought would be to just do the logic client-side and send a flag to the server (via a packet?) to apply the potion effect?

 

Or, maybe have an event which runs server-side? I can't seem to find a 'tick event' from the forge bus, but some research shows there may be one on the FML Bus (however most of this info is from around 2012, so it could be out-dated).

 

So my real question is - Do you think this is the right approach? Is sending a packet potentially tens of times every tick an issue? Or is there some other way I have completely missed?

 

Thanks in advance! 

 

Edit: Upon reflection, I realise that the title is pretty poor - my apologies.

  • Author

That certainly would make things a lot easier!

 

I came to this conclusion since the server was throwing errors when I tried to remove it. Ill do some digging...

If this "token" is your own item, override

Item#onUpdate

. This is called once every tick while the item is in a player's inventory.

 

Otherwise

PlayerTickEvent

is the correct event to use. It's fired on both sides and not annotated with

@SideOnly

, I'm not sure why you thought it was.

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.

  • Author

I removed the restriction and received an error, seems I interpreted it wrong! Thanks for the help.

 

The reason I cannot just use the onUpdate method is that the item has to also work from inside a 'token pouch'.

(I could always just write a bunch of if statements inside of the pouch code, but I thought this approach might be cleaner.)

 

EDIT:

 

Error = "java.lang.NoClassDefFoundError: net/minecraft/client/multiplayer/WorldClient"

The reason I cannot just use the onUpdate method is that the item has to also work from inside a 'token pouch'.

(I could always just write a bunch of if statements inside of the pouch code, but I thought this approach might be cleaner.)

 

The pouch could simply propagate the update to its contents and still have each individual token handle its own effects.

 

This may be slightly cheaper than scanning the player's inventory from

PlayerTickEvent

.

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.

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.