Résolu Probléme machine
-
Merci je laisse ce sujet ouvert car j’aurais d’autre problémes je pense
-
Dez double post mais sa me ferme le launcheur quand j’ouvre le GUI voici mon crash report
–-- Minecraft Crash Report ---- // Don't be sad. I'll do better next time, I promise! Time: 08/05/16 20:20 Description: Rendering screen java.lang.ArrayIndexOutOfBoundsException: 2 at com.adamitemod.mod.TileEntityMachineCraft.getStackInSlot(TileEntityMachineCraft.java:76) at net.minecraft.inventory.Slot.getStack(Slot.java:88) at net.minecraft.client.gui.inventory.GuiContainer.func_146977_a(GuiContainer.java:219) at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:114) 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 com.adamitemod.mod.TileEntityMachineCraft.getStackInSlot(TileEntityMachineCraft.java:76) at net.minecraft.inventory.Slot.getStack(Slot.java:88) at net.minecraft.client.gui.inventory.GuiContainer.func_146977_a(GuiContainer.java:219) at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:114) -- Screen render details -- Details: Screen name: com.adamitemod.mod.GuiMachineCraft Mouse location: Scaled: (213, 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['Player971'/281, l='MpServer', x=-133,57, y=90,62, z=315,22]] Chunk stats: MultiplayerChunkCache: 49, 49 Level seed: 0 Level generator: ID 00 - default, ver 1\. Features enabled: false Level generator options: Level spawn location: World: (-188,64,256), Chunk: (at 4,4,0 in -12,16; contains blocks -192,0,256 to -177,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 330319 game time, 193663 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: 7 total; [EntityPig['Pig'/160, l='MpServer', x=-91,50, y=69,00, z=298,84], EntityPig['Pig'/134, l='MpServer', x=-104,50, y=71,00, z=319,69], EntityPig['Pig'/135, l='MpServer', x=-103,81, y=74,00, z=331,13], EntityItem['item.item.rottenFlesh'/121, l='MpServer', x=-130,66, y=70,13, z=325,06], EntityClientPlayerMP['Player971'/281, l='MpServer', x=-133,57, y=90,62, z=315,22], EntityChicken['Chicken'/174, l='MpServer', x=-86,61, y=79,47, z=364,72], EntityPig['Pig'/127, l='MpServer', x=-116,69, y=72,00, z=339,50]] 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 (x86) version 10.0 Java Version: 1.8.0_66, Oracle Corporation Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation Memory: 752220696 bytes (717 MB) / 1046937600 bytes (998 MB) up to 1046937600 bytes (998 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: 13, tallocated: 95 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 adamitemod{1.0.0} [Adamite Mod] (bin) GL info: ' Vendor: 'Intel' Version: '4.0.0 - Build 10.18.10.4276' Renderer: 'Intel(R) HD Graphics' Launched Version: 1.7.10 LWJGL: 2.9.1 OpenGL: Intel(R) HD Graphics GL version 4.0.0 - Build 10.18.10.4276, Intel 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)
-
T’as quoi à cette ligne : at com.adamitemod.mod.TileEntityMachineCraft.getStackInSlot(TileEntityMachineCraft.java:76)
Au pire file ta classe TileEntityMachineCraft, stp -
et la une Class surgit
package com.adamitemod.mod; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; public class TileEntityMachineCraft extends TileEntity implements IInventory { private ItemStack[] contents = new ItemStack[2]; // #SCAREX : tu n'as que 2 slots private int workingTime = 0; private int workingTimeNeeded = 60; @SideOnly(Side.CLIENT) public int getCookProgress() { return this.workingTime * 17 / this.workingTimeNeeded; } @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.contents.length; ++i) { if (this.contents* != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte)i); this.contents*.writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } compound.setTag("Items", nbttaglist); compound.setShort("workingTime",(short)this.workingTime); compound.setShort("workingTimeNeeded", (short)this.workingTimeNeeded); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList nbttaglist = compound.getTagList("Items", 10); this.contents = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); int j = nbttagcompound1.getByte("Slot") & 255; if (j >= 0 && j < this.contents.length) { this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } this.workingTime = compound.getShort("workingTime"); this.workingTimeNeeded = compound.getShort("workingTimeNeeded"); } @Override public int getSizeInventory() { return this.contents.length; } @Override public ItemStack getStackInSlot(int slotIndex) { return this.contents[slotIndex]; } @Override public ItemStack decrStackSize(int slotIndex, int amount) { if (this.contents[slotIndex] != null) { ItemStack itemstack; if (this.contents[slotIndex].stackSize <= amount) { itemstack = this.contents[slotIndex]; this.contents[slotIndex] = null; this.markDirty(); return itemstack; } else { itemstack = this.contents[slotIndex].splitStack(amount); if (this.contents[slotIndex].stackSize == 0) { this.contents[slotIndex] = null; } this.markDirty(); return itemstack; } } else { return null; } } @Override public ItemStack getStackInSlotOnClosing(int slotIndex) { if (this.contents[slotIndex] != null) { ItemStack itemstack = this.contents[slotIndex]; this.contents[slotIndex] = null; return itemstack; } else { return null; } } @Override public void setInventorySlotContents(int slotIndex, ItemStack stack) { this.contents[slotIndex] = stack; if (stack != null && stack.stackSize > this.getInventoryStackLimit()) { stack.stackSize = this.getInventoryStackLimit(); } this.markDirty(); } @Override public String getInventoryName() { return "tile.machineTuto"; } @Override public boolean hasCustomInventoryName() { return false; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; } @Override public void openInventory() { } @Override public void closeInventory() { } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return slot == 3 ? false : true; } public boolean isBurning() { return this.workingTime > 0; } private boolean canSmelt() { if (this.contents[0] == null) // #SCAREX : tu n'as qu'un seul slot ici { return false; } else { ItemStack itemstack = MachineRecipesCraft.smelting().getSmeltingResult(this.contents[0]); // #SCAREX : un seul slot if (itemstack == null) return false; if (this.contents[3] == null) return true; if (!this.contents[3].isItemEqual(itemstack)) return false; int result = contents[3].stackSize + itemstack.stackSize; return result <= getInventoryStackLimit() && result <= this.contents[3].getMaxStackSize(); } } public void updateEntity() { if(this.isBurning() && this.canSmelt()) { ++this.workingTime; } if(this.canSmelt() && !this.isBurning()) { this.workingTime = 1; } if(this.canSmelt() && this.workingTime == this.workingTimeNeeded) { this.smeltItem(); this.workingTime = 0; } if(!this.canSmelt()) { this.workingTime= 0; } } public void smeltItem() { if (this.canSmelt()) { ItemStack itemstack = MachineRecipesCraft.smelting().getSmeltingResult(this.contents[0]); // #SCAREX : tu n'as qu'un seul input if (this.contents[1] == null) // #SCAREX : ton slot d'output devient 1 { this.contents[1] = itemstack.copy(); } else if (this.contents[1].getItem() == itemstack.getItem()) { this.contents[1].stackSize += itemstack.stackSize; } –this.contents[0].stackSize; if (this.contents[0].stackSize <= 0) { this.contents[0] = null; } } } }
Voilla
-
Pour éviter les doubles posts : tu peux éditer le message.
Du coup si tu veux faire un UncraftingTable, tu as besoin de 1 input, 9 outputs et pas besoin de classe pour les recettes car il y a déjà celle de minecraft.
PS : fait gaffe il y a plusieurs moyens de crafter quelque chose
-
Ligne 13, tu mets 2 slots alors que tu as besoin de 10 slots.
-
[font=Ubuntu, sans-serifDu coup si tu veux faire un UncraftingTable, tu as besoin de 1 input, 9 outputs et pas besoin de classe pour les recettes car il y a déjà celle de minecraft.]
[font=Ubuntu, sans-serifPS : fait gaffe il y a plusieurs moyens de crafter quelque chose]
oui mais si je met le class de minecraft je porrais pas decraft les truc de mon mod si ?
sinon sa ne crash plus !
EDIT je veux faire sa :
this.addRecipe(ItemsMod.adamiteShovel, new ItemStack(ItemsMod.adamite, ItemsMod.fission));
sa me demande de retirer sa ItemsMod.fission -
this.addRecipe(ItemsMod.adamiteShovel, new ItemStack(ItemsMod.adamite), new ItemStack(ItemsMod.fission));
-
j’avais essayer et sa me metais un erreur sur addRecipe et sa me met toujour l’erreur
-
Tu peux envoyer la class où se trouve cette erreur ?
-
package com.adamitemod.mod; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import com.adamitemod.mod.init.BlocksMod; import com.adamitemod.mod.init.ItemsMod; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class MachineRecipesCraft { private static final MachineRecipesCraft smeltingBase = new MachineRecipesCraft(); private HashMap <itemstack, itemstack="">smeltingList = new HashMap(); // #SCAREX : c'est mieux d'indiquer ce que l'on met dans la HashMap public MachineRecipesCraft() { this.addRecipe(ItemsMod.adamiteShovel, new ItemStack(ItemsMod.adamite), new ItemStack(ItemsMod.fission)); // #SCAREX : tu changes ta recette } public void addRecipe(ItemStack input, ItemStack output) { this.smeltingList.put(input, output); } public void addRecipe(Item input, ItemStack output) { this.addRecipe(new ItemStack(input), output); } public void addRecipe(Block input, ItemStack output) { this.addRecipe(Item.getItemFromBlock(input), output); } public ItemStack getSmeltingResult(ItemStack stack) { Iterator iterator = this.smeltingList.entrySet().iterator(); Entry entry; do { if (!iterator.hasNext()) { return null; } entry = (Entry)iterator.next(); } while (!this.isSameKey(stack, (ItemStack)entry.getKey())); return (ItemStack)entry.getValue(); } private boolean isSameKey(ItemStack machinesStack, ItemStack key) // #SCAREX : vu que tu n'as qu'un seul item, ça ne sert à rien de faire une boucle { return machinesStack.getItem() == key.getItem(); } public HashMap <itemstack, itemstack="">getSmeltingList() { return this.smeltingList; } public static MachineRecipesCraft smelting() { return smeltingBase; } }
ses à la ligne 25</itemstack,></itemstack,>
-
Quelle est l’erreur indiquée par eclipse ?
-
sur addRecipe: remove argument to match ‘add recipe(item, ItemStack)’
-
Tu as un paramètre en trop
-
Bas oui je sait ses sa new ItemStack(ItemsMod.fission)___dez double post mais alors je fait comment pour ajouter un item a mon craft car j’ai neuf ouput et un input je voudrai que quand je mais un item sa me donne un item différent dans le 9ouput donc moi j’ai déja essayer mais j’y suis pas arriver qui sait ?
-
Ton code actuelle n’est pas adapté pour avoir plusieurs output.
Il faut utiliser un tableau d’item stack au lieu d’un simple item stack pour ça :
private HashMap <itemstack, itemstack**[]**=“”>smeltingList = new HashMap();Il faut adapter en conséquence les autres fonctions :
public void addRecipe(ItemStack input, ItemStack**…** output)
public ItemStack**[]** getSmeltingResult(ItemStack stack)etc …</itemstack,>
-
Bien Re tous le mondes j’ai un pb dans mon code le Voici
package com.adamitemod.mod; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import com.adamitemod.mod.init.BlocksMod; import com.adamitemod.mod.init.ItemsMod; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class MachineRecipesCraft { private static final MachineRecipesCraft smeltingBase = new MachineRecipesCraft(); private HashMap <itemstack, itemstack[]="">smeltingList = new HashMap(); // #SCAREX : c'est mieux d'indiquer ce que l'on met dans la HashMap public MachineRecipesCraft() { public void addRecipe(ItemStack input, ItemStack… output) // #SCAREX : tu changes ta recette } public void addRecipe(ItemStack input, ItemStack... output) { this.smeltingList.put(input, output); } public void addRecipe(Item input, ItemStack output) { this.addRecipe(new ItemStack(input), output); } public void addRecipe(Block input, ItemStack output) { this.addRecipe(Item.getItemFromBlock(input), output); } public ItemStack getSmeltingResult(ItemStack stack) { Iterator iterator = this.smeltingList.entrySet().iterator(); Entry entry; do { if (!iterator.hasNext()) { return null; } entry = (Entry)iterator.next(); } while (!this.isSameKey(stack, (ItemStack)entry.getKey())); return (ItemStack)entry.getValue(); } private boolean isSameKey(ItemStack machinesStack, ItemStack key) // #SCAREX : vu que tu n'as qu'un seul item, ça ne sert à rien de faire une boucle { return machinesStack.getItem() == key.getItem(); } public HashMap <itemstack, itemstack[]="">getSmeltingList() { return this.smeltingList; } public static MachineRecipesCraft smelting() { return smeltingBase; } }
plus précisement à la ligne 25</itemstack,></itemstack,>
-
Lis ça (au moins le début, les bases, parce que c’est long).
Et regarde tes “{” et “}”, tu ne remarques pas que tu ne fermes pas ton bloc (avec un “}”) après le contructeur (“public MachineRecipesCraft(){”). Et ensuite que tu n’ouvres pas le bloc de ta fonction avec “{” après “public void addRecipe(ItemStack input, ItemStack… output)[font=monospace”.]
Et j’ajoute aussi, là l’erreur était simple à voir, et comme t’a mis la ligne ça allait, mais des fois ça peut être plus compliqué donc ajoute le(s) message(s) que eclipse met sur l’erreur dans le futur. -
l’open classe room je l’ai déja lu . . . mais sinon je dois faire quoi ? car j’ai pas comrpis le tebleau
-
Lignes 23 à 31 :
public MachineRecipesCraft() { public void addRecipe(ItemStack input, ItemStack… output) //Retire cette ligne (je viens de me rendre compte que c'est pas les "{" le problème, mais c'est que t'a dut copier deux fois cette ligne et au mauvais endroit (il y a déjà cette fonction plus bas)) } public void addRecipe(ItemStack input, ItemStack... output) { this.smeltingList.put(input, output); }