Bug NBTTag pour Item avec craft
-
la méthode matches te demande de verifier si le craft est bon, si tu mets return true, n’importe quoi donnera ton craft. Ici j’utilise une boucle for pour me s’implifier la vie avec les matrix que j’ai mis plus bas : ce sont des array d’Item (ou extended item pour les metadatas). çà rend les choses plus simple.
-
Désolé de devoir réouvrir ce sujet mais ça évitera d’en recréer un qui traite le même problème. Je voudrai que si mon Item passé en argument du constructeur, soit inutile si il possède déjà un Tag. En gros on ne peut pas réaliser le craft si par-exemple ma batte de baseball possède déjà le NBT Boolean “wasImprovedInClouMode”. Déjà soit je n’ai toujrous rien compris soit je sais pas , mon premier println n’est même pas appelé (celui de la méthode matches()) alors que mon item possède bien un tag, donc logiquement le stackTagCompound ne devrait pas être null, or c’est le second println qui est appelé.
Voici mon codepackage fr.mrplaigon.dyingcraft.common.customrecipe; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import fr.mrplaigon.dyingcraft.common.handler.ItemHandler; import fr.mrplaigon.dyingcraft.common.item.DyingCraftItemSword; public class ImprovementsRecipe implements IRecipe { private DyingCraftItemSword itemImproved; private byte statut; public ImprovementsRecipe(DyingCraftItemSword itemImproved) { this.itemImproved = itemImproved; statut = 0; } @Override public boolean matches(InventoryCrafting craftingTable, World world) { ItemStack itemstack = new ItemStack(itemImproved, 1); if(itemstack.stackTagCompound != null) { System.out.println("stackTagCompound non null"); } else { System.out.println("stackTagCompound null"); } for (int k1 = 0; k1 < craftingTable.getSizeInventory(); ++k1) { if(itemImproved.isImprovableInClouMode()) { if(craftingTable.getStackInSlot(1) != null && craftingTable.getStackInSlot(3) != null && craftingTable.getStackInSlot(4) != null && craftingTable.getStackInSlot(5) != null && craftingTable.getStackInSlot(7) != null) { if(craftingTable.getStackInSlot(1).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(3).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(5).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(7).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(4).getItem() == itemImproved) { statut = 1; return true; } } } if(itemImproved.isImprovableInPoisonMode()) { if(craftingTable.getStackInSlot(1) != null && craftingTable.getStackInSlot(3) != null && craftingTable.getStackInSlot(4) != null && craftingTable.getStackInSlot(5) != null && craftingTable.getStackInSlot(7) != null) { if(craftingTable.getStackInSlot(1).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(3).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(5).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(7).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(4).getItem() == itemImproved) { statut = 2; return true; } } } } return false; } @Override public ItemStack getCraftingResult(InventoryCrafting inventorycrafting) { ItemStack itemstack = new ItemStack(itemImproved, 1); NBTTagCompound compound = new NBTTagCompound(); // if(statut == 1 && !itemstack.stackTagCompound.hasKey("wasImprovedInClouMode")) // { // compound.setBoolean("wasImprovedInClouMode", true); // return itemstack; // } // if(statut == 1 && itemstack.stackTagCompound.hasKey("wasImprovedInClouMode")) // { // EventHandlerClient.drawCraftPicture(168, 138, new ResourceLocation("dyingcraftmod", "textures/gui/improvements/errorsMessages.png")); // } // else if(statut == 2 && !itemstack.stackTagCompound.hasKey("wasImprovedInPoisonMode")) // { // compound.setBoolean("wasImprovedInPoisonMode", true); // return itemstack; // } if(statut == 1) { compound.setBoolean("wasImprovedInClouMode", true); } else { compound.setBoolean("wasImprovedInPoisonMode", true); } itemstack.setTagCompound(compound); return itemstack; } @Override public int getRecipeSize() { return 9; } @Override public ItemStack getRecipeOutput() { return new ItemStack(itemImproved); } }
-
Une instance de ta classe = un craft ou un groupe de crafts.
Ton matches te donne accès à tous les items de la table de craft, c’est à toi d’aller les chercher au bon endroit et de regarder qu’ils soient bien là.
Pense à enregistrer ton recipe avec GameRegistry.addRecipe(new TaClasse()).
-
Je vais reformuler
J’ai créer une dizaine d’armes toutes extends DyingraftItemSword et je souhaite la chose suivante : Si le joueur a 4 boites de clou et une arme améliorables aux clou alors il place son arme aux centre et l’entour de 4 boites de clou. Ceci fait son arme alors amélioré sera l’arme crafté avec comme NBT ajouté le boolean “wasImprovedInClouMode” passé en true. Cepndant ce que je ne souhaite pas c’est que le joueur remette son arme améliorée aux clous à l’instant même et qu’il la reaméliore. Je souhaite donc qu’une arme avec comme NBT d’actif le boolean “wasImprovedInClouMode”, ne puisse pas être réutilisé dans la table de craft. Mon soucis est que mon premier println n’est pas appelé alors que le second l’est toujorus, lui.
SCAREX, j’ai déjà enregistré mon IRecipe, pas de soucis là-dessus. -
Normal, tu crée un nouvel ItemStack, pourquoi ?
ItemStack itemstack = new ItemStack(itemImproved, 1); if(itemstack.stackTagCompound != null) { System.out.println("stackTagCompound non null"); } else { System.out.println("stackTagCompound null"); }
-
Pour avoir une instance comment je l’ai autrement sinon ?
Non je vais plutôt la créer avec la méthode getStackInRowAndColumn(int i, int y) -
On te donne un InventoryCrafting implements IInventory, donc tu peux utiliser getStackInSlot
-
Ma méthode proposée et la tienne sont équivalentes
C’est bon tout marche à merveille !EDIT :
Bon je suis de retour (jamais 2 sans 3) mais vraiment je ne penser pas en avori besoin. J’ai crée une méthode pour afficher une image elle marche très bien dans l’event ItemToolTip mais dans la méthode matches (), elle ne veut rien savoir
Mon code@Override public boolean matches(InventoryCrafting craftingTable, World world) { for (int k1 = 0; k1 < craftingTable.getSizeInventory(); ++k1) { if(itemImproved.isImprovableInClouMode()) { if(craftingTable.getStackInSlot(1) != null && craftingTable.getStackInSlot(3) != null && craftingTable.getStackInSlot(4) != null && craftingTable.getStackInSlot(5) != null && craftingTable.getStackInSlot(7) != null) { ItemStack itemstack = craftingTable.getStackInSlot(4); if(itemstack.stackTagCompound != null) { System.out.println("stackTagCompound non null"); } else { System.out.println("stackTagCompound null"); } if(craftingTable.getStackInSlot(1).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(3).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(5).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(7).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(4).getItem() == itemImproved && itemstack.stackTagCompound == null) { statut = 1; return true; } else if(craftingTable.getStackInSlot(1).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(3).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(5).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(7).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(4).getItem() == itemImproved && itemstack.stackTagCompound != null) { drawCraftPicture(30, 16, 0, 0,157, 121, new ResourceLocation("dyingcraftmod", "textures/gui/improvements/errorsMessages.png")); } } } if(itemImproved.isImprovableInPoisonMode()) { if(craftingTable.getStackInSlot(1) != null && craftingTable.getStackInSlot(3) != null && craftingTable.getStackInSlot(4) != null && craftingTable.getStackInSlot(5) != null && craftingTable.getStackInSlot(7) != null) { ItemStack itemstack = craftingTable.getStackInSlot(4); if(craftingTable.getStackInSlot(1).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(3).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(5).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(7).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(4).getItem() == itemImproved && itemstack.stackTagCompound == null) { statut = 2; return true; } else if(craftingTable.getStackInSlot(1).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(3).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(5).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(7).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(4).getItem() == itemImproved && itemstack.stackTagCompound != null) { drawCraftPicture(30, 16, 0, 0, 157, 121, new ResourceLocation("dyingcraftmod", "textures/gui/improvements/errorsMessages.png")); } } } } return false; } public void drawCraftPicture(int posX, int posY, int u, int v, int width, int heigth, ResourceLocation craftTextureFile) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); Minecraft.getMinecraft().getTextureManager().bindTexture(craftTextureFile); Minecraft.getMinecraft().currentScreen.drawTexturedModalRect(posX, posY, u, v, width, heigth); }
Le crash report
–-- Minecraft Crash Report ---- // On the bright side, I bought you a teddy bear! Time: 02/07/15 14:57 Description: Ticking memory connection java.lang.RuntimeException: No OpenGL context found in the current thread. at org.lwjgl.opengl.GLContext.getCapabilities(GLContext.java:124) at org.lwjgl.opengl.GL11.glColor4f(GL11.java:891) at fr.mrplaigon.dyingcraft.common.customrecipe.ImprovementsRecipe.drawCraftPicture(ImprovementsRecipe.java:81) at fr.mrplaigon.dyingcraft.common.customrecipe.ImprovementsRecipe.matches(ImprovementsRecipe.java:55) at net.minecraft.item.crafting.CraftingManager.findMatchingRecipe(CraftingManager.java:329) at net.minecraft.inventory.ContainerWorkbench.onCraftMatrixChanged(ContainerWorkbench.java:60) at net.minecraft.inventory.InventoryCrafting.setInventorySlotContents(InventoryCrafting.java:132) at net.minecraft.inventory.Slot.putStack(Slot.java:104) at net.minecraft.inventory.Container.slotClick(Container.java:325) at net.minecraft.network.NetHandlerPlayServer.processClickWindow(NetHandlerPlayServer.java:955) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:41) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:113) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at org.lwjgl.opengl.GLContext.getCapabilities(GLContext.java:124) at org.lwjgl.opengl.GL11.glColor4f(GL11.java:891) at fr.mrplaigon.dyingcraft.common.customrecipe.ImprovementsRecipe.drawCraftPicture(ImprovementsRecipe.java:81) at fr.mrplaigon.dyingcraft.common.customrecipe.ImprovementsRecipe.matches(ImprovementsRecipe.java:55) at net.minecraft.item.crafting.CraftingManager.findMatchingRecipe(CraftingManager.java:329) at net.minecraft.inventory.ContainerWorkbench.onCraftMatrixChanged(ContainerWorkbench.java:60) at net.minecraft.inventory.InventoryCrafting.setInventorySlotContents(InventoryCrafting.java:132) at net.minecraft.inventory.Slot.putStack(Slot.java:104) at net.minecraft.inventory.Container.slotClick(Container.java:325) at net.minecraft.network.NetHandlerPlayServer.processClickWindow(NetHandlerPlayServer.java:955) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:41) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:113) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@66628065 Stacktrace: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_71, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 838059152 bytes (799 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 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.3.1408 4 mods loaded, 4 mods active mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.3.1408-1.7.10.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available Forge{10.13.3.1408} [Minecraft Forge] (forgeSrc-1.7.10-10.13.3.1408-1.7.10.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available dyingcraftmod{1.0.0} [DyingCraft Mod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['Player193'/386, l='Nouveau monde', x=941,46, y=4,00, z=-915,92]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge'
-
EDIT :
Bon je suis de retour (jamais 2 sans 3) mais vraiment je ne penser pas en avori besoin. J’ai crée une méthode pour afficher une image elle marche très bien dans l’event ItemToolTip mais dans la méthode matches (), elle ne veut rien savoir
Mon code@Override public boolean matches(InventoryCrafting craftingTable, World world) { for (int k1 = 0; k1 < craftingTable.getSizeInventory(); ++k1) { if(itemImproved.isImprovableInClouMode()) { if(craftingTable.getStackInSlot(1) != null && craftingTable.getStackInSlot(3) != null && craftingTable.getStackInSlot(4) != null && craftingTable.getStackInSlot(5) != null && craftingTable.getStackInSlot(7) != null) { ItemStack itemstack = craftingTable.getStackInSlot(4); if(itemstack.stackTagCompound != null) { System.out.println("stackTagCompound non null"); } else { System.out.println("stackTagCompound null"); } if(craftingTable.getStackInSlot(1).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(3).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(5).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(7).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(4).getItem() == itemImproved && itemstack.stackTagCompound == null) { statut = 1; return true; } else if(craftingTable.getStackInSlot(1).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(3).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(5).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(7).getItem() == ItemHandler.boiteClous && craftingTable.getStackInSlot(4).getItem() == itemImproved && itemstack.stackTagCompound != null) { drawCraftPicture(30, 16, 0, 0,157, 121, new ResourceLocation("dyingcraftmod", "textures/gui/improvements/errorsMessages.png")); } } } if(itemImproved.isImprovableInPoisonMode()) { if(craftingTable.getStackInSlot(1) != null && craftingTable.getStackInSlot(3) != null && craftingTable.getStackInSlot(4) != null && craftingTable.getStackInSlot(5) != null && craftingTable.getStackInSlot(7) != null) { ItemStack itemstack = craftingTable.getStackInSlot(4); if(craftingTable.getStackInSlot(1).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(3).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(5).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(7).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(4).getItem() == itemImproved && itemstack.stackTagCompound == null) { statut = 2; return true; } else if(craftingTable.getStackInSlot(1).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(3).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(5).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(7).getItem() == ItemHandler.fiolePoison && craftingTable.getStackInSlot(4).getItem() == itemImproved && itemstack.stackTagCompound != null) { drawCraftPicture(30, 16, 0, 0, 157, 121, new ResourceLocation("dyingcraftmod", "textures/gui/improvements/errorsMessages.png")); } } } } return false; } public void drawCraftPicture(int posX, int posY, int u, int v, int width, int heigth, ResourceLocation craftTextureFile) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); Minecraft.getMinecraft().getTextureManager().bindTexture(craftTextureFile); Minecraft.getMinecraft().currentScreen.drawTexturedModalRect(posX, posY, u, v, width, heigth); }
Le crash report
–-- Minecraft Crash Report ---- // On the bright side, I bought you a teddy bear! Time: 02/07/15 14:57 Description: Ticking memory connection java.lang.RuntimeException: No OpenGL context found in the current thread. at org.lwjgl.opengl.GLContext.getCapabilities(GLContext.java:124) at org.lwjgl.opengl.GL11.glColor4f(GL11.java:891) at fr.mrplaigon.dyingcraft.common.customrecipe.ImprovementsRecipe.drawCraftPicture(ImprovementsRecipe.java:81) at fr.mrplaigon.dyingcraft.common.customrecipe.ImprovementsRecipe.matches(ImprovementsRecipe.java:55) at net.minecraft.item.crafting.CraftingManager.findMatchingRecipe(CraftingManager.java:329) at net.minecraft.inventory.ContainerWorkbench.onCraftMatrixChanged(ContainerWorkbench.java:60) at net.minecraft.inventory.InventoryCrafting.setInventorySlotContents(InventoryCrafting.java:132) at net.minecraft.inventory.Slot.putStack(Slot.java:104) at net.minecraft.inventory.Container.slotClick(Container.java:325) at net.minecraft.network.NetHandlerPlayServer.processClickWindow(NetHandlerPlayServer.java:955) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:41) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:113) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at org.lwjgl.opengl.GLContext.getCapabilities(GLContext.java:124) at org.lwjgl.opengl.GL11.glColor4f(GL11.java:891) at fr.mrplaigon.dyingcraft.common.customrecipe.ImprovementsRecipe.drawCraftPicture(ImprovementsRecipe.java:81) at fr.mrplaigon.dyingcraft.common.customrecipe.ImprovementsRecipe.matches(ImprovementsRecipe.java:55) at net.minecraft.item.crafting.CraftingManager.findMatchingRecipe(CraftingManager.java:329) at net.minecraft.inventory.ContainerWorkbench.onCraftMatrixChanged(ContainerWorkbench.java:60) at net.minecraft.inventory.InventoryCrafting.setInventorySlotContents(InventoryCrafting.java:132) at net.minecraft.inventory.Slot.putStack(Slot.java:104) at net.minecraft.inventory.Container.slotClick(Container.java:325) at net.minecraft.network.NetHandlerPlayServer.processClickWindow(NetHandlerPlayServer.java:955) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:41) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:113) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@66628065 Stacktrace: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_71, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 838059152 bytes (799 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 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.3.1408 4 mods loaded, 4 mods active mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.3.1408-1.7.10.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available Forge{10.13.3.1408} [Minecraft Forge] (forgeSrc-1.7.10-10.13.3.1408-1.7.10.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available dyingcraftmod{1.0.0} [DyingCraft Mod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['Player193'/386, l='Nouveau monde', x=941,46, y=4,00, z=-915,92]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge'
-
Tu ne peux pas utiliser openGL à cet endroit.
-
Sa j avais bien compris je sais lire un crash report. Et y a pas de solution, au pire je n utiliserai que la méthode drawRectTextured ()
-
Utilise un tick event.
-
Comment ? Comme tu puis je dans mon TickHandler faore une condition en rapport avec les item présent dans certains slot de la table de craft. La méthode matches () est tickee autant m en servir
-
Tu veux faire quoi en fait, afficher une image ?
-
Salut
SCAREX je sais que mon anglais laisse a désirer mais tout de même le nom de ma méthode ne te parle même pas ?!
(drawCraftPicture)
Et puis dedans y a surtout cette méthode :
drawTexturedModalRectDonc oui, je cherche a affiche une image
-
Tu peux utiliser le RenderGameOverlayEvent mais tu risque d’avoir quelques problèmes car cet event est appelé pour le rendu du jeu donc si tu as un GUI d’ouvert, la texture apparaîtra en-dessous.
-
Ce n’est pas génant car je ne souhaite pas que mon image soit sur le gui mais en dehors. Mais comment dans cet event ou dans mon TickHandler faire comprendre au jeu que c’est à ce moment que l’image doit êttre affichée. Une condition avec un boolean static dans la classe IRecipe qu’on passe à true, etc…Comment ferais-tu ?
-
Comme l’a dit Robin, tu ne peux pas utiliser l’openGL à cet endroit car c’est un événement côté serveur et que du côté client je ne sais pas si tu peux l’utiliser, je ne sais même pas s’il y a quelque chose qui te permette de savoir si l’événement est appelé côté client. Pour le tick handler, tu peux savoir si un gui est ouvert en utilisant player.currentContainer (pas sûr pour le nom, le booléen est peut être dans la classe Minecraft, je ne sais plus).
-
et saurais-tu comment avoir une instance de InventoryCrafting ?
Car dans la méthode matches, ce n’est pas un soucis étant donné qu’il est comme argument mais dans un TickHandler comment faire ?Aussi c’est bizarre mais je récupère un NPE en faisant apparaître mon image avec l’event RenderGameOverlay
Mon crash-report
–-- Minecraft Crash Report ---- // Don't be sad, have a hug! <3 Time: 04/07/15 17:13 Description: Unexpected error java.lang.NullPointerException: Unexpected error at fr.mrplaigon.dyingcraft.client.handler.EventHandlerClient.drawAPicture(EventHandlerClient.java:146) at fr.mrplaigon.dyingcraft.client.handler.EventHandlerClient.onRenderPre(EventHandlerClient.java:190) at cpw.mods.fml.common.eventhandler.ASMEventHandler_8_EventHandlerClient_onRenderPre_Pre.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) at net.minecraftforge.client.GuiIngameForge.pre(GuiIngameForge.java:901) at net.minecraftforge.client.GuiIngameForge.renderHelmet(GuiIngameForge.java:247) at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:120) at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1114) 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.mrplaigon.dyingcraft.client.handler.EventHandlerClient.drawAPicture(EventHandlerClient.java:146) at fr.mrplaigon.dyingcraft.client.handler.EventHandlerClient.onRenderPre(EventHandlerClient.java:190) at cpw.mods.fml.common.eventhandler.ASMEventHandler_8_EventHandlerClient_onRenderPre_Pre.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) at net.minecraftforge.client.GuiIngameForge.pre(GuiIngameForge.java:901) at net.minecraftforge.client.GuiIngameForge.renderHelmet(GuiIngameForge.java:247) at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:120) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityClientPlayerMP['Player455'/194, l='MpServer', x=912,77, y=5,62, z=-910,07]] Chunk stats: MultiplayerChunkCache: 60, 60 Level seed: 0 Level generator: ID 01 - flat, ver 0\. Features enabled: false Level generator options: Level spawn location: World: (941,4,-917), Chunk: (at 13,0,11 in 58,-58; contains blocks 928,0,-928 to 943,255,-913), Region: (1,-2; contains chunks 32,-64 to 63,-33, blocks 512,0,-1024 to 1023,255,-513) Level time: 23216 game time, 7070 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: 78 total; [EntitySheep['Mouton'/42, l='MpServer', x=867,81, y=4,00, z=-934,78], EntityPig['Cochon'/43, l='MpServer', x=877,59, y=4,00, z=-930,81], EntitySheep['Mouton'/46, l='MpServer', x=870,25, y=4,00, z=-912,63], EntityPig['Cochon'/47, l='MpServer', x=873,97, y=4,00, z=-918,09], EntityChicken['Poule'/44, l='MpServer', x=865,53, y=4,00, z=-913,81], EntitySheep['Mouton'/45, l='MpServer', x=878,75, y=4,00, z=-922,56], EntitySheep['Mouton'/51, l='MpServer', x=871,66, y=4,00, z=-904,75], EntitySheep['Mouton'/50, l='MpServer', x=870,19, y=4,00, z=-900,28], EntityChicken['Poule'/49, l='MpServer', x=877,63, y=4,00, z=-918,53], EntityCow['Vache'/48, l='MpServer', x=866,06, y=4,00, z=-912,78], EntityPig['Cochon'/55, l='MpServer', x=865,84, y=4,00, z=-909,59], EntityPig['Cochon'/54, l='MpServer', x=868,41, y=4,00, z=-908,19], EntityChicken['Poule'/53, l='MpServer', x=865,53, y=4,00, z=-904,63], EntitySheep['Mouton'/52, l='MpServer', x=865,78, y=4,00, z=-896,84], EntityChicken['Poule'/59, l='MpServer', x=871,53, y=4,00, z=-884,63], EntityPig['Cochon'/58, l='MpServer', x=868,97, y=4,00, z=-899,91], EntityClientPlayerMP['Player455'/194, l='MpServer', x=912,77, y=5,62, z=-910,07], EntitySheep['Mouton'/57, l='MpServer', x=874,25, y=4,00, z=-905,34], EntityCow['Vache'/56, l='MpServer', x=874,22, y=4,00, z=-906,69], EntityChicken['Poule'/63, l='MpServer', x=877,06, y=4,00, z=-878,13], EntityPig['Cochon'/62, l='MpServer', x=878,94, y=4,00, z=-882,97], EntitySheep['Mouton'/61, l='MpServer', x=864,03, y=4,00, z=-885,97], EntityCow['Vache'/60, l='MpServer', x=871,06, y=4,00, z=-881,50], EntityPig['Cochon'/68, l='MpServer', x=871,88, y=4,00, z=-862,78], EntityPig['Cochon'/69, l='MpServer', x=875,03, y=4,00, z=-862,94], EntityChicken['Poule'/64, l='MpServer', x=864,47, y=4,00, z=-870,47], EntitySheep['Mouton'/65, l='MpServer', x=879,06, y=4,00, z=-879,06], EntityPig['Cochon'/66, l='MpServer', x=873,34, y=4,00, z=-854,31], EntityCow['Vache'/67, l='MpServer', x=866,09, y=4,00, z=-857,94], EntitySheep['Mouton'/76, l='MpServer', x=892,25, y=4,00, z=-937,94], EntitySheep['Mouton'/77, l='MpServer', x=883,34, y=4,00, z=-941,34], EntityHorse['Cheval'/78, l='MpServer', x=892,56, y=4,00, z=-940,19], EntityCow['Vache'/79, l='MpServer', x=891,75, y=4,00, z=-929,63], EntityIronGolem['Golem de fer'/75, l='MpServer', x=889,19, y=4,00, z=-951,56], EntityCow['Vache'/85, l='MpServer', x=883,50, y=4,00, z=-923,63], EntityHorse['Cheval'/84, l='MpServer', x=882,78, y=4,00, z=-920,50], EntitySheep['Mouton'/87, l='MpServer', x=885,88, y=4,00, z=-907,84], EntityChicken['Poule'/86, l='MpServer', x=889,47, y=4,00, z=-925,56], EntitySheep['Mouton'/81, l='MpServer', x=884,84, y=4,00, z=-938,66], EntityCow['Vache'/80, l='MpServer', x=887,75, y=4,00, z=-928,59], EntityHorse['Cheval'/83, l='MpServer', x=880,41, y=4,00, z=-927,84], EntityCow['Vache'/82, l='MpServer', x=884,22, y=4,00, z=-926,22], EntityPig['Cochon'/92, l='MpServer', x=884,91, y=4,00, z=-850,19], EntityHorse['Cheval'/95, l='MpServer', x=904,78, y=4,00, z=-926,78], EntityPig['Cochon'/89, l='MpServer', x=881,88, y=4,00, z=-904,84], EntityCow['Vache'/88, l='MpServer', x=888,88, y=4,00, z=-908,06], EntitySheep['Mouton'/91, l='MpServer', x=887,81, y=4,00, z=-853,38], EntitySheep['Mouton'/90, l='MpServer', x=886,78, y=4,00, z=-871,09], EntityItem['item.item.ingotIron'/102, l='MpServer', x=927,91, y=4,13, z=-885,59], EntityItem['item.item.leather'/100, l='MpServer', x=914,94, y=4,13, z=-912,00], EntityItem['item.item.beefRaw'/101, l='MpServer', x=915,06, y=4,13, z=-911,97], EntityXPOrb['Orbe d'expérience'/99, l='MpServer', x=917,88, y=4,13, z=-912,25], EntityHorse['Cheval'/96, l='MpServer', x=904,88, y=4,00, z=-914,59], EntityCow['Vache'/97, l='MpServer', x=902,03, y=4,00, z=-895,94], EntityPig['Cochon'/110, l='MpServer', x=929,28, y=4,00, z=-845,69], EntityPig['Cochon'/111, l='MpServer', x=940,28, y=4,00, z=-844,09], EntitySheep['Mouton'/108, l='MpServer', x=940,56, y=4,00, z=-848,94], EntityCow['Vache'/109, l='MpServer', x=943,19, y=4,00, z=-856,06], EntitySheep['Mouton'/106, l='MpServer', x=930,06, y=4,00, z=-854,03], EntityPig['Cochon'/107, l='MpServer', x=941,81, y=4,00, z=-860,38], EntityCow['Vache'/104, l='MpServer', x=938,78, y=4,00, z=-887,75], EntityCow['Vache'/105, l='MpServer', x=937,22, y=4,00, z=-862,53], EntitySheep['Mouton'/119, l='MpServer', x=948,72, y=4,00, z=-835,19], EntityPig['Cochon'/118, l='MpServer', x=950,38, y=4,00, z=-856,16], EntityCow['Vache'/117, l='MpServer', x=955,81, y=4,00, z=-862,94], EntityCow['Vache'/116, l='MpServer', x=947,66, y=4,00, z=-856,72], EntityPig['Cochon'/115, l='MpServer', x=956,19, y=4,00, z=-866,84], EntityCow['Vache'/114, l='MpServer', x=944,16, y=4,00, z=-871,22], EntityCow['Vache'/113, l='MpServer', x=951,63, y=4,00, z=-865,97], EntitySheep['Mouton'/112, l='MpServer', x=937,38, y=4,00, z=-838,19], EntityPig['Cochon'/127, l='MpServer', x=967,16, y=4,00, z=-859,13], EntityCow['Vache'/126, l='MpServer', x=969,06, y=4,00, z=-878,84], EntityCow['Vache'/125, l='MpServer', x=967,56, y=4,00, z=-879,75], EntityCow['Vache'/124, l='MpServer', x=963,97, y=4,00, z=-880,91], EntityCow['Vache'/123, l='MpServer', x=966,22, y=4,00, z=-892,75], EntityPig['Cochon'/122, l='MpServer', x=966,88, y=4,00, z=-884,81], EntityCow['Vache'/121, l='MpServer', x=969,19, y=4,00, z=-917,81], EntityIronGolem['Golem de fer'/120, l='MpServer', x=975,19, y=4,00, z=-941,53]] 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:991) 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 7 (amd64) version 6.1 Java Version: 1.7.0_71, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 759704616 bytes (724 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 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.3.1408 4 mods loaded, 4 mods active mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.3.1408-1.7.10.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{10.13.3.1408} [Minecraft Forge] (forgeSrc-1.7.10-10.13.3.1408-1.7.10.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available dyingcraftmod{1.0.0} [DyingCraft Mod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.4.13283 Compatibility Profile Context 14.501.1003.0' Renderer: 'AMD Radeon HD 8570D' Launched Version: 1.7.10 LWJGL: 2.9.1 OpenGL: AMD Radeon HD 8570D GL version 4.4.13283 Compatibility Profile Context 14.501.1003.0, ATI Technologies Inc. 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: Français (France) Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Anisotropic Filtering: Off (1)
Mon code
public void drawAPicture(int posX, int posY, int u, int v, int width, int heigth, ResourceLocation craftTextureFile) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); Minecraft.getMinecraft().getTextureManager().bindTexture(craftTextureFile); Minecraft.getMinecraft().currentScreen.drawTexturedModalRect(posX, posY, u, v, width, heigth); } @SubscribeEvent public void onRenderPre(RenderGameOverlayEvent.Pre event) { if(event.type == RenderGameOverlayEvent.ElementType.HELMET) { event.setCanceled(true); drawAPicture(30, 16, 0, 0,157, 121, new ResourceLocation("dyingcraftmod", "textures/gui/improvements/errorsMessages.png")); } }
Je précise que je n’ai pas du tout de soucis au niveaux des coordonnées que j’ai donné ; seule chose bizarre quand je load mon mode et qu’il se met direct en menu échap je peux voir mon image mais dès que je reviens en jeu (que je quitte le menu échap) mon jeu crash.
Je sais qu’on quitte en ce moment complétement le sujet du bug des NBTTag donc pensez-vous qu’il soit nécessaire de créer un nouveau topic pour parler de ce soucis d’OpenGL / et sûrement de Side ?
-
Le crash report est bien, mais il faut donner la classe entière sinon on peut pas savoir à quelle ligne est le problème. Tu peux récupérer une instance du container ouvert grâce à player.currentContainer et donc tu as accès à toutes les variables du container.