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'm trying to add a capability to entities (specific mobs) that gives them a certain level. I've got the capability working, everything works fine server-side, I just have to get this information to the player to render it on the screen whenever the player looks at the mob. The problem I'm having is getting this information to the player.

 

From what I can tell, the AttachCapabilitiesEvent is fired both client and server. Changing this to fire only on one side doesn't work, because the capability doesn't seem attached on the other side (or am I wrong because if I am this would likely fix my issue). I originally set the value of the level when attaching the capability, but I don't think I can do that because that's where I would need to send my packet. I've tried setting the level using EntityJoinWorldEvent and sending the packet from there, but the client doesn't get notified (according to the RenderGameOverlayEvent), yet the packet prints out the correct level on the client-side. This leads me to believe that the way I'm accessing the capability from RenderGameOverlayEvent isn't correct (I'm almost certain this is the problem now). In the end, I'm kind of just stuck, so any help is appreciated.

 

- AttachCapabilitiesEvent

- EntityJoinWorldEvent

- RenderGameOverlayEvent

 

If you need more code, everything should be accessible from GitHub.

Developer of Levels and Lost Eclipse

PacketEnemyLevel

does absolutely nothing when it's received by the client, so the client-side

IEnemyLevel

instance is never updated.

 

You need to send the entity ID and the level in the packet, then retrieve the

Entity

with that ID from the client

World

and update its

IEnemyLevel

instance.

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

That makes sense - I tried updating the capability from inside the packet but I couldn't ever get it to work, must have did it wrong then. I'll see if I can get it to work this time.

Developer of Levels and Lost Eclipse

Note that you don't need to send the entity ID unless you also plan to send this packet to players other than the one updating the capability, i.e. if you are going to display this information to other players. Otherwise, the packet is already sent to the player which you can retrieve using the message context, so the entity ID is superfluous.

Note that you don't need to send the entity ID unless you also plan to send this packet to players other than the one updating the capability, i.e. if you are going to display this information to other players. Otherwise, the packet is already sent to the player which you can retrieve using the message context, so the entity ID is superfluous.

 

The capability is for arbitrary mobs in the world, not players. The entity ID is required to determine which mob to update the data for.

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

So something like this should work properly?

 

Edit: the entity here is getting passed as null, possibly because the entity hasn't joined the world yet? (as that is where the packet is being fired)

Developer of Levels and Lost Eclipse

PlayerEvent.StartTracking

is probably a better event to use here. This will be fired when a player starts tracking the entity, after the entity's spawn packet has been sent to the client; so the entity will likely exist by the time your packet is received.

 

The entity will only exist on the clients of players close enough to it. If they're too far away or in another dimension, their clients won't know anything about it.

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.