Started by
Fresfries
on
Topic category: Help with Minecraft modding (Java Edition)
So my mod works perfectly if you run it in singleplayer but as soon as you run it on a server and open a gui it crashes.
I know it's because the server is trying to execute code that is client side, or something like that.
Minecraft version: 1.17.1
MCreator version: 2021.3 EAP (47317)
Crash log:
The part that crashes the server:
@SubscribeEvent
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
Player entity = event.player;
if (event.phase == TickEvent.Phase.END && entity.containerMenu instanceof ScreenMenu) {
Level world = entity.level;
double x = entity.getX();
double y = entity.getY();
double z = entity.getZ();
HashMap<String, Object> guistate = ChiselScreen.guistate;
CloseGuiProcedure.execute(entity);
}
}
Edited by Fresfries on Sun, 11/21/2021 - 15:12
You are calling client side procedure from server side, you can't do that
Is there a easy solution on fixing this? Because I don't think I can fix it through MCreator if I understand correctly.
The part of code I posted is this tick event.
Or is it the procedure itself?
But even if I comment it out it still crashes, so it can't be this part.
I still just can't get it to work/not crash.
If I do this, it crashes on the server
And if I put this at the beginning
or this
it doesn't crash, but also doesn't run the procedure on the server.