Hi!
I am new to Forge modding (not java), and I am trying to build a statistics mod to keep track of things like how many blocks of X type has a player mined, how many times the player have received damage and how much damage has been received, xp obtained...
But I am constantly finding the problem of things working on a single player mode but not on multiplayer. Events like PlayerXpEvent.PickupXp are firing only when the server is hosted by the client.
I understand this is because this events are handled server side, and I have found workarounds like using the players inventory to keep track of the blocks, but this is very limiting.
I was wondering if there was a way to listen to those events also in the client side. I have searched and searched this forum and Google but I only find outdated or dead posts.
My code (Really simple):
@Mod.EventBusSubscriber(modid = Minestats.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public class Events {
@SubscribeEvent
public static void onItemPickup(final PlayerXpEvent.PickupXp event) {
Minestats.saveNewXpValue(event.getOrb().getValue(), new Timestamp(System.currentTimeMillis())); // This just saves it in a JSON file
}
}