Résolu Mon mod crash sur serveur depuis l'ajout d'une GUI
-
Bonjour comme dit dans le titre mon mod crash sur serveur après l’ajout d’une GUI simple. Je viens de commencer donc il me faut des infos assez précises. Je vous remercie.
-
world.isRemote
est vrai si le monde actuel est distant, donc si c’est le client.
Avec!world.isRemote
la condition n’est que vrai si tu es le serveur.Ouvrir un gui côté serveur ça ne fonctionne pas très bien. Enfin le fait d’avoir une référence à un gui sur un serveur le fait tout simplement planter.
Ajoutes un
@SideOnly(Side.CLIENT)
au-dessus de la fonctiononItemRightClick
pour que le serveur ne charge pas la classe de ton gui.
Et retires la conditionif(!world.isRemote)
qui ne fait aucun sens. -
Bonsoir,
Nous aussi il nous faut des info précise pour pouvoir t’aider, à commencer par le rapport de crash et le code cité dans le rapport. On ne va pas deviner d’où vient ton problème.
-
GUI DE LA “Stone Tablet”
public class GuiStoneTablet extends GuiScreen { int guiWidth = 145; int guiHeight = 179; public String currentLanguage; public String getCurrentLanguage() { return this.currentLanguage; } @Override public void drawScreen(int x, int y, float ticks) { int guiX = (width - guiWidth) / 2; int guiY = (height - guiHeight) / 2; GL11.glColor4f(1, 1, 1, 1); drawDefaultBackground(); mc.renderEngine.bindTexture(new ResourceLocation(Reference.MODID, "textures/gui/stone_tablet/stone_tablet.png")); drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight); fontRendererObj.drawString("An indescribable sentence is written on this tablet", guiWidth / 2, guiY - 15, 0xFF0019); super.drawScreen(x, y, ticks); } @Override public boolean doesGuiPauseGame() { return false; } }
FONCTION QUI OUVRE LA GUI
@Override public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { if(!world.isRemote) { Minecraft.getMinecraft().displayGuiScreen(new GuiStoneTablet()); } return super.onItemRightClick(item, world, player); }
ET LE JOLI CRASH
[21:52:29] [Server thread/ERROR] [FML]: Fatal errors were detected during the transition from PREINITIALIZATION to INITIALIZATION. Loading cannot continue [21:52:29] [Server thread/ERROR] [FML]: States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCH mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCH FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCH Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCE bettermc{1.0} [Better Minecraft] (bin) [21:52:29] [Server thread/ERROR] [FML]: The following problems were captured during this phase [21:52:29] [Server thread/ERROR] [FML]: Caught exception from bettermc java.lang.NoClassDefFoundError: net/minecraft/client/gui/GuiScreen at fr.mod.bettermc.init.ItemMod.init(ItemMod.java:14) ~[ItemMod.class:?] at fr.mod.bettermc.BetterMC.preInit(BetterMC.java:33) ~[BetterMC.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_221] at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532) ~[FMLModContainer.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_221] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[LoadController.class:?] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[LoadController.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_221] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [LoadController.class:?] at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556) [Loader.class:?] at cpw.mods.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:88) [FMLServerHandler.class:?] at cpw.mods.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:314) [FMLCommonHandler.class:?] at net.minecraft.server.dedicated.DedicatedServer.startServer(DedicatedServer.java:120) [DedicatedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:445) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.ClassNotFoundException: net.minecraft.client.gui.GuiScreen at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_221] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_221] ... 34 more Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/gui/GuiScreen for invalid side SERVER at cpw.mods.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:50) ~[forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_221] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_221] ... 34 more [21:52:29] [Server thread/ERROR]: Encountered an unexpected exception cpw.mods.fml.common.LoaderException: java.lang.NoClassDefFoundError: net/minecraft/client/gui/GuiScreen at cpw.mods.fml.common.LoadController.transition(LoadController.java:163) ~[LoadController.class:?] at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:559) ~[Loader.class:?] at cpw.mods.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:88) ~[FMLServerHandler.class:?] at cpw.mods.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:314) ~[FMLCommonHandler.class:?] at net.minecraft.server.dedicated.DedicatedServer.startServer(DedicatedServer.java:120) ~[DedicatedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:445) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/gui/GuiScreen at fr.mod.bettermc.init.ItemMod.init(ItemMod.java:14) ~[ItemMod.class:?] at fr.mod.bettermc.BetterMC.preInit(BetterMC.java:33) ~[BetterMC.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_221] at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532) ~[FMLModContainer.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_221] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[LoadController.class:?] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[LoadController.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_221] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) ~[LoadController.class:?] at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556) ~[Loader.class:?] ... 5 more Caused by: java.lang.ClassNotFoundException: net.minecraft.client.gui.GuiScreen at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_221] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_221] at fr.mod.bettermc.init.ItemMod.init(ItemMod.java:14) ~[ItemMod.class:?] at fr.mod.bettermc.BetterMC.preInit(BetterMC.java:33) ~[BetterMC.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_221] at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532) ~[FMLModContainer.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_221] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[LoadController.class:?] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[LoadController.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_221] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) ~[LoadController.class:?] at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556) ~[Loader.class:?] ... 5 more Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/gui/GuiScreen for invalid side SERVER at cpw.mods.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:50) ~[forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_221] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_221] at fr.mod.bettermc.init.ItemMod.init(ItemMod.java:14) ~[ItemMod.class:?] at fr.mod.bettermc.BetterMC.preInit(BetterMC.java:33) ~[BetterMC.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_221] at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532) ~[FMLModContainer.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_221] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[LoadController.class:?] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[LoadController.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_221] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) ~[LoadController.class:?] at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556) ~[Loader.class:?] ... 5 more
-
world.isRemote
est vrai si le monde actuel est distant, donc si c’est le client.
Avec!world.isRemote
la condition n’est que vrai si tu es le serveur.Ouvrir un gui côté serveur ça ne fonctionne pas très bien. Enfin le fait d’avoir une référence à un gui sur un serveur le fait tout simplement planter.
Ajoutes un
@SideOnly(Side.CLIENT)
au-dessus de la fonctiononItemRightClick
pour que le serveur ne charge pas la classe de ton gui.
Et retires la conditionif(!world.isRemote)
qui ne fait aucun sens. -
@robin4002 a dit dans Mon mod crash sur serveur depuis l'ajout d'une GUI :
@SideOnly(Side.CLIENT)
Ca marche merci beaucoup à vous. Merci de votre rapidité et de votre efficacité.
-
Merci de mettre la discussion en résolu dans ce cas (je viens de le faire, à l’avenir il faudra y penser).