Jump to content

LivingDeathEvent not firing on servers?


Jongh

Recommended Posts

So I'm trying to make a little stat indicator that shows kills and deaths stats in the corner.

 

But it doesn't work on servers, only on singleplayer.

 

I have some other listeners registered and they are all working on the server.

 

Here is the eventhandler class, I have it subscribed to Forge event bus and everything: https://gist.github.com/hjongh/6271c57ad26a4940f92714f0ff51cb9c

 

I was thinking that maybe this LivingDeathEvent is done only on server and client cannot access or something? For security/privacy reasons.

 

 

Link to comment
Share on other sites

Minecraft

is a client-only class, you can't access it from common code.

 

There is no "the player" on the server, there are multiple players. Which one are you tracking the stats of?

 

Don't compare players by name, compare them by UUID.

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 now pass the eventhandler class a reference to Minecraft from the Main class in its Constructor.

 

Also I should have said but this is a mod, not a plugin.

 

I tested it and it still doesn't work. The functionality works in singleplayer. I also have other listeners that are functioning in both singleplayer and on a server. But just this listener's code doesn't work on a server.

Link to comment
Share on other sites

Ok so I tried hardcoding the player checking, just to test it, and it still doesn't work.

 

https://gist.github.com/hjongh/b7139e7d016b3737a08effb810bc0e05

 

The mod functionality works when I'm in Singleplayer, so there isn't an issue with the player's name being returned in some weird format. It just doesn't work when I go on a server.

 

Also I'm testing it by building it each time and running it with my actual Minecraft.

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.