Résolu Crash de creative tabs | Texture d'un GuiOverlay buggé
-
Bonjour,
J’ai aujourd’hui 2 problèmes, un de creative tabs, et un de texture d’un overlay.Creative tabs qui font crash
Donc, mon problème c’est que quand j’appuie sur la flèche pour voir la deuxieme page des creative tabs, je crash.
Le crash report :–-- Minecraft Crash Report ---- // Ooh. Shiny. Time: 14/11/15 15:12 Description: Rendering item java.lang.NullPointerException: Rendering item at net.minecraft.item.ItemStack.getMetadata(ItemStack.java:280) at net.minecraft.client.renderer.ItemModelMesher.getMetadata(ItemModelMesher.java:70) at net.minecraft.client.renderer.ItemModelMesher.getItemModel(ItemModelMesher.java:43) at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:363) at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:414) at net.minecraft.client.gui.inventory.GuiContainerCreative.func_147051_a(GuiContainerCreative.java:956) at net.minecraft.client.gui.inventory.GuiContainerCreative.drawGuiContainerBackgroundLayer(GuiContainerCreative.java:783) at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:95) at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:53) at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:659) at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:462) at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1134) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1114) at net.minecraft.client.Minecraft.run(Minecraft.java:376) at net.minecraft.client.main.Main.main(Main.java:117) 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.item.ItemStack.getMetadata(ItemStack.java:280) at net.minecraft.client.renderer.ItemModelMesher.getMetadata(ItemModelMesher.java:70) at net.minecraft.client.renderer.ItemModelMesher.getItemModel(ItemModelMesher.java:43) at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:363) -- Item being rendered -- Details: Item Type: null Item Aux: ~~ERROR~~ NullPointerException: null Item NBT: null Item Foil: ~~ERROR~~ NullPointerException: null Stacktrace: at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:414) at net.minecraft.client.gui.inventory.GuiContainerCreative.func_147051_a(GuiContainerCreative.java:956) at net.minecraft.client.gui.inventory.GuiContainerCreative.drawGuiContainerBackgroundLayer(GuiContainerCreative.java:783) at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:95) at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:53) at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:659) at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:462) -- Screen render details -- Details: Screen name: net.minecraft.client.gui.inventory.GuiContainerCreative Mouse location: Scaled: (300, 10). Absolute: (600, 458) Screen size: Scaled: (427, 240). Absolute: (854, 480). Scale factor of 2 -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['Snowy_1803'/66, l='MpServer', x=645,26, y=68,15, z=169,64]] Chunk stats: MultiplayerChunkCache: 121, 121 Level seed: 0 Level generator: ID 01 - flat, ver 0\. Features enabled: false Level generator options: Level spawn location: 668,00,4,00,207,00 - World: (668,4,207), Chunk: (at 12,0,15 in 41,12; contains blocks 656,0,192 to 671,255,207), Region: (1,0; contains chunks 32,0 to 63,31, blocks 512,0,0 to 1023,255,511) Level time: 471830 game time, 28430 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: 8 total; [EntityItem['item.item.bone'/1988536, l='MpServer', x=609,69, y=63,00, z=132,41], EntitySkeleton['Squelette'/1596838, l='MpServer', x=643,19, y=60,00, z=173,16], EntityItem['item.item.bone'/1988535, l='MpServer', x=609,94, y=63,00, z=130,97], EntityPlayerSP['Snowy_1803'/66, l='MpServer', x=645,26, y=68,15, z=169,64], EntitySpider['Araignée'/1520470, l='MpServer', x=640,69, y=61,09, z=170,00], EntityCow['Vache'/50, l='MpServer', x=708,97, y=63,00, z=216,88], EntitySkeleton['Squelette'/2284816, l='MpServer', x=668,50, y=63,00, z=205,50], EntityCreeper['Creeper'/1516629, l='MpServer', x=648,91, y=60,00, z=197,38]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:392) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2614) at net.minecraft.client.Minecraft.run(Minecraft.java:398) at net.minecraft.client.main.Main.main(Main.java:117) 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.8 Operating System: Windows 8.1 (amd64) version 6.3 Java Version: 1.7.0_79, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 566523368 bytes (540 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.3.1450 5 mods loaded, 5 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{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.3.1450.jar) UCHIJAAAA Forge{11.14.3.1450} [Minecraft Forge] (forgeSrc-1.8-11.14.3.1450.jar) UCHIJAAAA examplemod{1.0} [examplemod] (bin) UCHIJAAAA elementalmod{0.1} [Elemental Mod] (bin) Loaded coremods (and transformers): GL info: ' Vendor: 'Intel' Version: '4.0.0 - Build 10.18.10.3408' Renderer: 'Intel(R) HD Graphics' Launched Version: 1.8 LWJGL: 2.9.1 OpenGL: Intel(R) HD Graphics GL version 4.0.0 - Build 10.18.10.3408, Intel GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: [] Current Language: Français (France) Profiler Position: N/A (disabled)
La déclaration des tabs (dans la classe principale) :
public static ElementalCreativeTab etypes = new ElementalCreativeTab("elementalTypes", itemTypeSwitcher); public static ElementalCreativeTab eTools = new ElementalCreativeTab("elementalTools", swordOldSnow); public static ElementalCreativeTab eUtils = new ElementalCreativeTab("elementalUtils", Item.getItemFromBlock(blockPurifier));
Et la classe ElementalCreativeTab.java :
public class ElementalCreativeTab extends CreativeTabs { private Item icon; public ElementalCreativeTab(String label, Item icon) { super(label); this.icon = icon; } @SideOnly(Side.CLIENT) public Item getTabIconItem() { return icon; } }
Problème d’overlay
J’ai donc aussi un problème d’overlay. J’ai une texture de barre de progression verticale mais cela affiche un truc bizarre à la place.
Screens :
Ma classe d’overlay :public class PowerOverlay extends Gui { public static PowerOverlay instance; private boolean showing = true; public PowerOverlay() { instance = this; } @SubscribeEvent public void renderElementalPower(RenderGameOverlayEvent e) { if(e.isCancelable() || e.type != ElementType.EXPERIENCE || !showing) { return; } int xSize = 16; int ySize = 128; int x = e.resolution.getScaledWidth() - 24; int y = e.resolution.getScaledHeight() / 2 - 64; int ytext = e.resolution.getScaledHeight() / 2 + 72; Minecraft mc = Minecraft.getMinecraft(); ResourceLocation texture = new ResourceLocation("elementalmod", "textures/gui/elementalpower.png"); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.getTextureManager().bindTexture(texture); drawTexturedModalRect(x, y, 0, 0, xSize, ySize); int power = ElementalExtendedProperties.get(mc.thePlayer).getMana(); int maxpower = ElementalExtendedProperties.get(mc.thePlayer).getMaxMana(); String type = types[ElementalExtendedProperties.get(mc.thePlayer).getType()]; int i = (int) power / maxpower * ySize; //drawTexturedModalRect(x, y, 16, 0, xSize, i); drawCenteredString(mc.fontRendererObj, type, x + xSize / 2, ytext, new Color(200, 200, 200).getRGB()); } public boolean isShowing() { return showing; } public void setShowing(boolean show) { showing = show; } }
Merci d’avance pour votre aide !
-
- tu as un npe, à mon avis c’est l’item qui doit être utilisé pour l’affichage qui est null.
- ta texture devrait faire 256x256 et ensuite dans la méthode draw tu dois spécifier à quel endroit elle se trouve dans le fichier.