-
Ce bout de code devrait t’aider.
public static ByteBuffer createIcon(String path) { BufferedImage image = null; try { // System.out.print(ClientProxy.class.getResource(path).getPath().replaceAll("%20", // " ") + "\n"); image = ImageIO.read(ClientProxy.class.getResource(path)); return imageToByteBuffer(image); } catch(IOException e) { e.printStackTrace(); } return null; } private static ByteBuffer imageToByteBuffer(BufferedImage image) { if(image.getType() != BufferedImage.TYPE_INT_ARGB_PRE) { BufferedImage convertedImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE); Graphics2D g = convertedImage.createGraphics(); double width = image.getWidth() * (double)1; double height = image.getHeight() * (double)1; g.drawImage(image, (int)((convertedImage.getWidth() - width) / 2), (int)((convertedImage.getHeight() - height) / 2), (int)width, (int)height, null); g.dispose(); image = convertedImage; } byte[] imageBuffer = new byte[image.getWidth() * image.getHeight() * 4]; int counter = 0; for(int i = 0; i < image.getHeight(); i++) for(int j = 0; j < image.getWidth(); j++) { int colorSpace = image.getRGB(j, i); imageBuffer[counter + 0] = (byte)(colorSpace << 8 >> 24); imageBuffer[counter + 1] = (byte)(colorSpace << 16 >> 24); imageBuffer[counter + 2] = (byte)(colorSpace << 24 >> 24); imageBuffer[counter + 3] = (byte)(colorSpace >> 24); counter += 4; } return ByteBuffer.wrap(imageBuffer); }Dans le client proxy
public static ByteBuffer[] icons = new ByteBuffer[2]; ClientProxy.icons[0] = createIcon("/assets/" + Utils.MODID_CORE + "/textures/icons/icon16.png"); // 16 ClientProxy.icons[1] = createIcon("/assets/" + Utils.MODID_CORE + "/textures/icons/icon32.png"); // 32 Display.setIcon(ClientProxy.icons);Après, c’est à toi d’y arriver seul.
N’oublie pas qu’une bonne recherche google et en anglais de préférence, te donnera la réponse. -
Merci Ama !
Un tout dernier truc
pour le nom dde la fenetre c’est a mettre ou ?
et ton premier bout de code c’est bien a mettre dans la classe principal ? -
Dans le client proxy pour les deux, sinon tu vas faire crasher ton serveur.
-
Mon jeu crash :
[09:37:45] [Client thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization [09:37:45] [Client thread/INFO] [FML]: MinecraftForge v10.13.4.1558 Initialized [09:37:45] [Client thread/INFO] [FML]: Replaced 183 ore recipies [09:37:46] [Client thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization [09:37:48] [Client thread/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer [09:37:48] [Client thread/INFO] [FML]: Searching C:\Users\Rajo\Desktop\Eno\Dev\forge-directory 3.0\eclipse\mods for mods [09:38:48] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load [09:38:50] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, MC56] at CLIENT [09:38:50] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, MC56] at SERVER [09:38:55] [Client thread/ERROR] [FML]: Attempted to load a proxy type fr.eno.mc56.proxy.ClientProxy into fr.eno.mc56.BaseMod.proxy, but the types don't match [09:38:55] [Client thread/ERROR] [FML]: An error occured trying to load a proxy into {serverSide=fr.eno.mc56.proxy.CommonProxy, clientSide=fr.eno.mc56.proxy.ClientProxy}.fr.eno.mc56.BaseMod cpw.mods.fml.common.LoaderException: Attempted to load a proxy type fr.eno.mc56.proxy.ClientProxy into fr.eno.mc56.BaseMod.proxy, but the types don't match at cpw.mods.fml.common.ProxyInjector.inject(ProxyInjector.java:69) [ProxyInjector.class:?] at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:512) [FMLModContainer.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181] 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_181] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181] 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.loadMods(Loader.java:513) [Loader.class:?] at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:208) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:522) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:942) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] [09:38:55] [Client thread/ERROR] [FML]: Fatal errors were detected during the transition from CONSTRUCTING to PREINITIALIZATION. Loading cannot continue [09:38:55] [Client thread/ERROR] [FML]: States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UC mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UC FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UC Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UE MC56{1.0.0} [Mod Minecraft 5.6] (bin) [09:38:55] [Client thread/ERROR] [FML]: The following problems were captured during this phase [09:38:55] [Client thread/ERROR] [FML]: Caught exception from MC56 cpw.mods.fml.common.LoaderException: cpw.mods.fml.common.LoaderException: Attempted to load a proxy type fr.eno.mc56.proxy.ClientProxy into fr.eno.mc56.BaseMod.proxy, but the types don't match at cpw.mods.fml.common.ProxyInjector.inject(ProxyInjector.java:76) ~[forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar:?] at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:512) ~[forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181] 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) ~[forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar:?] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181] 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.loadMods(Loader.java:513) [Loader.class:?] at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:208) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:522) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:942) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] Caused by: cpw.mods.fml.common.LoaderException: Attempted to load a proxy type fr.eno.mc56.proxy.ClientProxy into fr.eno.mc56.BaseMod.proxy, but the types don't match at cpw.mods.fml.common.ProxyInjector.inject(ProxyInjector.java:69) ~[forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar:?] ... 35 more [09:38:55] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ---- // Quite honestly, I wouldn't worry myself about that. Time: 04/12/18 09:38 Description: There was a severe problem during mod loading that has caused the game to fail cpw.mods.fml.common.LoaderException: cpw.mods.fml.common.LoaderException: Attempted to load a proxy type fr.eno.mc56.proxy.ClientProxy into fr.eno.mc56.BaseMod.proxy, but the types don't match at cpw.mods.fml.common.ProxyInjector.inject(ProxyInjector.java:76) at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:512) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) at cpw.mods.fml.common.Loader.loadMods(Loader.java:513) at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:208) at net.minecraft.client.Minecraft.startGame(Minecraft.java:522) at net.minecraft.client.Minecraft.run(Minecraft.java:942) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) Caused by: cpw.mods.fml.common.LoaderException: Attempted to load a proxy type fr.eno.mc56.proxy.ClientProxy into fr.eno.mc56.BaseMod.proxy, but the types don't match at cpw.mods.fml.common.ProxyInjector.inject(ProxyInjector.java:69) ... 35 morele client Proxy :
package fr.eno.mc56.proxy; import fr.eno.mc56.BaseMod; import fr.eno.mc56.Reference; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.IOException; import java.nio.ByteBuffer; import javax.imageio.ImageIO; import org.jcp.xml.dsig.internal.dom.Utils; import org.lwjgl.opengl.Display; public class ClientProxy { public void registerRender() { System.out.println("méthode côté client"); Display.setTitle("minecraft 5.6"); }; public static ByteBuffer[] icons = new ByteBuffer[2]; { ClientProxy.icons[0] = createIcon("/assets/" + Reference.MOD_ID + "/textures/icons/icon16.png"); // 16 ClientProxy.icons[1] = createIcon("/assets/" + Reference.MOD_ID + "/textures/icons/icon32.png"); // 32 Display.setIcon(ClientProxy.icons); } public static ByteBuffer createIcon(String path) { BufferedImage image = null; try { // System.out.print(ClientProxy.class.getResource(path).getPath().replaceAll("%20", // " ") + "\n"); image = ImageIO.read(ClientProxy.class.getResource(path)); return imageToByteBuffer(image); } catch(IOException e) { e.printStackTrace(); } return null; } private static ByteBuffer imageToByteBuffer(BufferedImage image) { if(image.getType() != BufferedImage.TYPE_INT_ARGB_PRE) { BufferedImage convertedImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE); Graphics2D g = convertedImage.createGraphics(); double width = image.getWidth() * (double)1; double height = image.getHeight() * (double)1; g.drawImage(image, (int)((convertedImage.getWidth() - width) / 2), (int)((convertedImage.getHeight() - height) / 2), (int)width, (int)height, null); g.dispose(); image = convertedImage; } byte[] imageBuffer = new byte[image.getWidth() * image.getHeight() * 4]; int counter = 0; for(int i = 0; i < image.getHeight(); i++) for(int j = 0; j < image.getWidth(); j++) { int colorSpace = image.getRGB(j, i); imageBuffer[counter + 0] = (byte)(colorSpace << 8 >> 24); imageBuffer[counter + 1] = (byte)(colorSpace << 16 >> 24); imageBuffer[counter + 2] = (byte)(colorSpace << 24 >> 24); imageBuffer[counter + 3] = (byte)(colorSpace >> 24); counter += 4; } return ByteBuffer.wrap(imageBuffer); } }
-
Tes paramètres de proxy sur la classe principale ne sont pas bon.
-
D’accord mais comment je fais alors ? :
public class BaseMod { @Instance(Reference.MOD_ID) public static BaseMod instance; @SidedProxy(clientSide = "fr.eno.mc56.proxy.ClientProxy", serverSide = "fr.eno.mc56.proxy.CommonProxy") public static CommonProxy proxy; @EventHandler public void preinit(FMLPreInitializationEvent event) { proxy.registerRender(); }; @EventHandler public void init(FMLInitializationEvent event) { }; @EventHandler public void postInit(FMLPostInitializationEvent event) { }; } -
Ah autant pour moi j’ai mal lu le message d’erreur, le soucis c’est que ton client proxy d’extends par le proxy common.
-
@Pharko
Pourquoi tu met un ; à preInit init et postInit ? -
le
;est useless ca marque une fin de d’instruction qui n’en n’est pas une -
MERCI @robin4002, @Superloup10, @SpyMan, @Ama et @arinonia pour vos réponse !
vous ètes super sympa !

-
Ce message a été supprimé !