Résolu [1.7.10] Comment centrer un gui ?
-
C’est-à-dire que si je marque :
drawTexturedModalRect(width, height, 0, 0, guiWidth, guiHeight);
Le gui va apparaître aux coordonnées 512 et 232 ?
-
nan c’est bien le code mais aux zéros ajoute guiX et guiY(et suppr les zéros car tu vas le placer au tout debut (et ce que j’ai dit c’est si mc a une réso(taille) de 1280*720)
-
Ah ok, merci. Est-que par contre tu sais pourquoi lorsque j’ouvre mon gui des fois ça crash et des fois non ?
-
Sans rapport je ne peux t’aider
-
// Don't be sad. I'll do better next time, I promise! Time: 10/06/19 16:49 Description: Rendering screen java.lang.NullPointerException: Rendering screen at fr.kraniax.moreutilities.gui.CalculatorGui.drawScreen(CalculatorGui.java:26) at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1137) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1067) at net.minecraft.client.Minecraft.run(Minecraft.java:962) 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) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at fr.kraniax.moreutilities.gui.CalculatorGui.drawScreen(CalculatorGui.java:26) -- Screen render details -- Details: Screen name: fr.kraniax.moreutilities.gui.CalculatorGui Mouse location: Scaled: (149, 203). Absolute: (427, 240) Screen size: Scaled: (427, 240). Absolute: (854, 480). Scale factor of 2 -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityClientPlayerMP['Player231'/75, l='MpServer', x=-1154,06, y=6,64, z=1482,88]] Chunk stats: MultiplayerChunkCache: 169, 169 Level seed: 0 Level generator: ID 01 - flat, ver 0. Features enabled: false Level generator options: Level spawn location: World: (-1125,4,1419), Chunk: (at 11,0,11 in -71,88; contains blocks -1136,0,1408 to -1121,255,1423), Region: (-3,2; contains chunks -96,64 to -65,95, blocks -1536,0,1024 to -1025,255,1535) Level time: 205478 game time, 58552 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 26 total; [EntityClientPlayerMP['Player231'/75, l='MpServer', x=-1154,06, y=6,64, z=1482,88], EntitySheep['Sheep'/15, l='MpServer', x=-1221,63, y=4,00, z=1495,25], EntityCow['Cow'/16, l='MpServer', x=-1229,55, y=4,00, z=1501,60], EntityCow['Cow'/17, l='MpServer', x=-1222,13, y=4,00, z=1521,25], EntityChicken['Chicken'/20, l='MpServer', x=-1214,63, y=4,00, z=1472,59], EntityChicken['Chicken'/21, l='MpServer', x=-1204,47, y=4,00, z=1529,47], EntityChicken['Chicken'/22, l='MpServer', x=-1208,19, y=4,00, z=1522,19], EntityPig['Pig'/23, l='MpServer', x=-1213,22, y=4,00, z=1529,75], EntityChicken['Chicken'/24, l='MpServer', x=-1211,28, y=4,00, z=1555,44], EntityPig['Pig'/29, l='MpServer', x=-1186,59, y=4,00, z=1471,84], EntityChicken['Chicken'/30, l='MpServer', x=-1198,53, y=4,00, z=1517,59], EntityPig['Pig'/31, l='MpServer', x=-1187,97, y=4,00, z=1535,88], EntityCow['Cow'/32, l='MpServer', x=-1190,94, y=4,00, z=1542,59], EntityCow['Cow'/37, l='MpServer', x=-1170,69, y=4,00, z=1471,56], EntitySheep['Sheep'/38, l='MpServer', x=-1160,25, y=4,00, z=1502,31], EntityCow['Cow'/39, l='MpServer', x=-1159,25, y=4,00, z=1548,78], EntityPig['Pig'/42, l='MpServer', x=-1125,59, y=4,00, z=1544,28], EntityPig['Pig'/43, l='MpServer', x=-1108,06, y=4,00, z=1507,69], EntityChicken['Chicken'/44, l='MpServer', x=-1105,88, y=4,00, z=1510,78], EntityPig['Pig'/45, l='MpServer', x=-1112,56, y=4,00, z=1509,50], EntityCow['Cow'/47, l='MpServer', x=-1101,44, y=4,00, z=1501,31], EntityPig['Pig'/48, l='MpServer', x=-1093,50, y=4,00, z=1507,44], EntityChicken['Chicken'/51, l='MpServer', x=-1087,44, y=4,00, z=1459,34], EntityChicken['Chicken'/52, l='MpServer', x=-1079,38, y=4,00, z=1494,19], EntitySheep['Sheep'/53, l='MpServer', x=-1084,03, y=4,00, z=1492,94], EntityChicken['Chicken'/54, l='MpServer', x=-1080,06, y=4,00, z=1550,47]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2566) at net.minecraft.client.Minecraft.run(Minecraft.java:984) 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) -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_191, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 709261720 bytes (676 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCHIJAAAA Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCHIJAAAA moreutilities{1.0.0} [More Utilities] (bin) GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 398.11' Renderer: 'GeForce GTX 1050/PCIe/SSE2' Launched Version: 1.7.10 LWJGL: 2.9.1 OpenGL: GeForce GTX 1050/PCIe/SSE2 GL version 4.6.0 NVIDIA 398.11, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Anisotropic filtering is supported and maximum anisotropy is 16. Shaders are available because OpenGL 2.1 is supported. Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: [] Current Language: English (US) Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Anisotropic Filtering: Off (1)
-
J’ai l’impression qu’il aime pas trop la facon que tu fais les couleurs avec GL(il trouve une npe la dessus)
-
Ok, je vais l’enlever et voir si ça ne crash plus mais ce qui est bizarre c’est des fois ça crash et des fois non.
-
Non, ça crash toujours :
---- Minecraft Crash Report ---- // Sorry :( Time: 10/06/19 16:57 Description: Rendering screen java.lang.NullPointerException: Rendering screen at net.minecraft.client.gui.GuiScreen.drawWorldBackground(GuiScreen.java:396) at net.minecraft.client.gui.GuiScreen.drawDefaultBackground(GuiScreen.java:391) at fr.kraniax.moreutilities.gui.CalculatorGui.drawScreen(CalculatorGui.java:25) at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1137) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1067) at net.minecraft.client.Minecraft.run(Minecraft.java:962) 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) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at net.minecraft.client.gui.GuiScreen.drawWorldBackground(GuiScreen.java:396) at net.minecraft.client.gui.GuiScreen.drawDefaultBackground(GuiScreen.java:391) at fr.kraniax.moreutilities.gui.CalculatorGui.drawScreen(CalculatorGui.java:25) -- Screen render details -- Details: Screen name: fr.kraniax.moreutilities.gui.CalculatorGui Mouse location: Scaled: (216, 119). Absolute: (427, 240) Screen size: Scaled: (427, 240). Absolute: (854, 480). Scale factor of 2 -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityClientPlayerMP['Player892'/75, l='MpServer', x=-1124,45, y=5,62, z=1448,78]] Chunk stats: MultiplayerChunkCache: 135, 135 Level seed: 0 Level generator: ID 01 - flat, ver 0. Features enabled: false Level generator options: Level spawn location: World: (-1125,4,1419), Chunk: (at 11,0,11 in -71,88; contains blocks -1136,0,1408 to -1121,255,1423), Region: (-3,2; contains chunks -96,64 to -65,95, blocks -1536,0,1024 to -1025,255,1535) Level time: 206003 game time, 59077 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 22 total; [EntityHorse['Horse'/64, l='MpServer', x=-1051,59, y=4,00, z=1473,41], EntityPig['Pig'/65, l='MpServer', x=-1050,91, y=4,00, z=1486,09], EntityCow['Cow'/36, l='MpServer', x=-1170,69, y=4,00, z=1471,56], EntitySheep['Sheep'/37, l='MpServer', x=-1170,97, y=4,00, z=1499,06], EntityChicken['Chicken'/41, l='MpServer', x=-1128,06, y=4,00, z=1388,34], EntityPig['Pig'/42, l='MpServer', x=-1105,25, y=4,00, z=1504,13], EntityChicken['Chicken'/43, l='MpServer', x=-1105,44, y=4,00, z=1505,47], EntityPig['Pig'/44, l='MpServer', x=-1108,72, y=4,00, z=1512,22], EntityCow['Cow'/46, l='MpServer', x=-1100,63, y=4,00, z=1501,50], EntityPig['Pig'/47, l='MpServer', x=-1093,59, y=4,00, z=1501,19], EntityChicken['Chicken'/50, l='MpServer', x=-1087,44, y=4,00, z=1459,34], EntitySheep['Sheep'/51, l='MpServer', x=-1083,63, y=4,00, z=1487,19], EntityChicken['Chicken'/52, l='MpServer', x=-1079,38, y=4,00, z=1494,19], EntityChicken['Chicken'/21, l='MpServer', x=-1201,47, y=4,00, z=1515,53], EntitySheep['Sheep'/56, l='MpServer', x=-1064,41, y=4,00, z=1393,88], EntityHorse['Donkey'/57, l='MpServer', x=-1056,88, y=4,00, z=1427,53], EntitySheep['Sheep'/58, l='MpServer', x=-1061,03, y=4,00, z=1487,84], EntitySheep['Sheep'/59, l='MpServer', x=-1061,94, y=4,00, z=1496,97], EntityPig['Pig'/60, l='MpServer', x=-1067,01, y=4,00, z=1519,97], EntityClientPlayerMP['Player892'/75, l='MpServer', x=-1124,45, y=5,62, z=1448,78], EntityHorse['Horse'/61, l='MpServer', x=-1062,72, y=4,00, z=1521,06], EntityPig['Pig'/30, l='MpServer', x=-1195,04, y=4,00, z=1477,19]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2566) at net.minecraft.client.Minecraft.run(Minecraft.java:984) 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) -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_191, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 733266912 bytes (699 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCHIJAAAA Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCHIJAAAA moreutilities{1.0.0} [More Utilities] (bin) GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 398.11' Renderer: 'GeForce GTX 1050/PCIe/SSE2' Launched Version: 1.7.10 LWJGL: 2.9.1 OpenGL: GeForce GTX 1050/PCIe/SSE2 GL version 4.6.0 NVIDIA 398.11, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Anisotropic filtering is supported and maximum anisotropy is 16. Shaders are available because OpenGL 2.1 is supported. Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: [] Current Language: English (US) Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Anisotropic Filtering: Off (1)
-
ok il est contre la ligne 25 de ton gui(actuel)
-
Ouais, la ligne 25, j’ai écrit ça :
this.drawDefaultBackground();
-
Att ce truc il est pas pour une gui de taille normale(256*256)(et il fait pas un field avec la ressource)?
-
Bah mon gui à une taille de 256x256. Je sais pas au pire je vais l’enlever et je vais voir si ça ne crash pas.
-
Regarde le message modifié
-
Oui j’ai vu mais j’ai été voir le code dans la classe “GuiScreen” et je ne pense pas qu’il cause un problème. J’ai retesté sans ce code et ça crash toujours.
-
@kraniax a dit dans [1.7.10] Comment centrer un gui ? :
Oui j’ai vu mais j’ai été voir le code dans la classe “GuiScreen” et je ne pense pas qu’il cause un problème. J’ai retesté sans ce code et ça crash toujours.
Message pas code!
-
Oui mais j’ai pas compris, c’est-à-dire un field avec la ressource ?
-
yep un field avec la ressource loc
-
Ah et comment on fais alors ?
-
un truc comme ca
public ResourceLocation mareccource = new ResourceLocation("modid:ressource");
et a l’interieur(de this.draw…) tu mets mareccource.
-
Ah c’est bon ça ne crash plus j’ai l’impression, j’ai remplacé :
mc.renderEngine.bindTexture(new ResourceLocation(Reference.MODID + ":textures/gui/background.png"));
par
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(Reference.MODID, "textures/gui/background.png"));
Merci.