Posted August 11, 20169 yr 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.
August 11, 20169 yr 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.
August 11, 20169 yr Author 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.
August 11, 20169 yr Author 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.
August 11, 20169 yr just print the name in the log. you will see if the event is fired and what name is used. Or print the UUID, but for printig maybe the name is better. catch(Exception e) { } Yay, Pokémon exception handling, gotta catch 'em all (and then do nothing with 'em).
August 11, 20169 yr Author I did what something similar to what mcenderdragon suggested and the event doesn't seem to fire at all. Specifically when I'm on servers* Here's what my eventhandler: https://gist.github.com/hjongh/efe1e2c9bf82d14bb96b16e991f554c6 and main classes: https://gist.github.com/hjongh/52c4937088a466ac15ec7776a6553614 look like at the moment.
August 11, 20169 yr Author LivingDeathEvent only fires on the server. It does not fire on the client. awwwwwwwwwwwwwwwwwwwwwwwwwww darn ok Any other way I can accomplish this then?
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.