Posted July 8, 20169 yr 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
July 8, 20169 yr 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.
July 8, 20169 yr 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
July 8, 20169 yr 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. http://i.imgur.com/NdrFdld.png[/img]
July 8, 20169 yr 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.
July 8, 20169 yr Heh, yeah, so it is. That's what I get for replying to threads right after I get out of bed http://i.imgur.com/NdrFdld.png[/img]
July 8, 20169 yr 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
July 8, 20169 yr 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.
July 8, 20169 yr Author Awesome it's working properly now. I appreciate all the help. Developer of Levels and Lost Eclipse
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.