I'm attempting to implement a very simple mod for use (by myself) on a multiplayer server.
It's purpose: Keep a count of specific blocks I've acquired, render that information on the screen.
Event: Player has picked up a block
Check if the block is a nether quartz (I'm using silk touch).
Add it to a totalNetherQuartz variable, which is later rendered to the screen.
Simple, right?
The problem: Runs fine on single-player; doesn't run on multiplayer.
I understand server-side vs. client-side; however, I am unable to find a way to avoid using the server-side.
Yes, I have looked at the docs and tutorials. The docs are sparse; tutorials are outdated (MC modding seems to have changed quite significantly in 1.13).
The code:
ExampleMod.java
@Mod("Profit Counter")
public class ExampleMod
{
public ExampleMod() {
MinecraftForge.EVENT_BUS.register(this);
// Register my custom event handler.
EventHandler handler = new EventHandler();
MinecraftForge.EVENT_BUS.register(handler);
}
}
EventHandler.java
public class EventHandler {
private int totalNetherQuartz = 0;
@SubscribeEvent
public void onPlayerPickup(EntityItemPickupEvent event) {
EntityItem item = event.getItem();
if (item.getName().toString().contains("nether_quartz_ore")) { // I'm sure there's a better way to check for this, but this functions.
totalNetherQuartz += 1;
}
}
@SubscribeEvent
public void onRender(TickEvent.RenderTickEvent event) {
if (Minecraft.getInstance().isGameFocused()) {
Minecraft.getInstance().fontRenderer.drawStringWithShadow("Testing", 5, 5, 0xffFFFFFF); // This runs client-side, before even connecting.
Minecraft.getInstance().fontRenderer.drawStringWithShadow(Integer.toString(totalNetherQuartz), 15, 5, 0xffFFFFFF); // Changes in single-player; does not work in multiplayer.
}
}
}
What steps must I take in order to get this working on a multiplayer server?
Before you scream "client-side proxy" at me - please explain (or show me where I can find) how to set this up, since the tutorials for doing this in 1.12 no longer work, and the docs explain absolutely nothing other than the fact that you need one.