Machine Recipe Complex
-
Il faut aussi que tu vérifiés dans ta fonction smelt de tile entity
-
oui pourtant il est present
package com.google.SpyMan.Mechanicalcraft.common.blockOreExtractor; import com.google.SpyMan.Mechanicalcraft.common.Items.SpeedUpgrade; import com.google.SpyMan.Mechanicalcraft.common.Items.SpeedUpgradeThree; import com.google.SpyMan.Mechanicalcraft.common.Items.SpeedUpgradeTwo; import com.google.SpyMan.Mechanicalcraft.common.MechanicalCraft; 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.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; public class TileEntityOreExtractor extends TileEntity implements IInventory { private byte direction; private ItemStack[] contents = new ItemStack[15]; protected int workingTime = 0; protected int workingTimeNeeded = 200; protected int workingTimeNeededDefault = 200; protected int burnTime = 0; protected int burnTimeTotal = 0; @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.direction = compound.getByte("Direction"); 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.burnTime = compound.getShort("burnTime"); this.burnTimeTotal = compound.getShort("burnTimeTotal"); //this.workingTimeNeeded = compound.getShort("workingTimeNeeded"); } @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); NBTTagList nbttaglist = new NBTTagList(); compound.setByte("Direction", this.direction); 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("burnTime", (short)this.burnTime); compound.setShort("burnTimeTotal", (short)this.burnTimeTotal); //compound.setShort("workingTimeNeeded", (short)this.workingTimeNeeded); } public byte getDirection() { return direction; } public void setDirection(byte direction) { this.direction = direction; this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound); } public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { this.readFromNBT(pkt.func_148857_g()); } public int getSizeInventory() { return this.contents.length; } public void openInventory() {} public void closeInventory() {} public String getInventoryName() { return MechanicalCraft.oreExtractor.getLocalizedName(); } public boolean hasCustomInventoryName() { return false; } public int getInventoryStackLimit() { return 64; } 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; } public ItemStack getStackInSlot(int slotIndex) { return this.contents[slotIndex]; } 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; } } public ItemStack getStackInSlotOnClosing(int slotIndex) { if(this.contents[slotIndex] != null) { ItemStack itemstack = this.contents[slotIndex]; this.contents[slotIndex] = null; return itemstack; } else { return null; } } public void setInventorySlotContents(int slotIndex, ItemStack stack) { this.contents[slotIndex] = stack; if(stack != null && stack.stackSize > this.getInventoryStackLimit()) { stack.stackSize = this.getInventoryStackLimit(); } this.markDirty(); } public boolean isItemValidForSlot(int slot, ItemStack stack) { return slot == 2 ? false : true; } public boolean isBurning() { return this.workingTime > 0; } protected boolean canSmelt() { if(this.contents[0] == null) { return false; } else { ItemStack itemstack = OreExtractorRecipes.smelting().getSmeltingResult(new ItemStack[] {this.contents[0]}); 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 smeltItem() { if(this.canSmelt()) { ItemStack itemstack = OreExtractorRecipes.smelting().getSmeltingResult(new ItemStack[] {this.contents[0]}); if(this.contents[3] == null) { this.contents[3] = itemstack.copy(); } else if(this.contents[3].getItem() == itemstack.getItem()) { this.contents[3].stackSize += itemstack.stackSize; } this.decrStackSize(0, 1); } } public void updateEntity() { if(this.burnTime > 0) { burnTime–; } if(this.canSmelt()) { if(this.burnTime <= 0) { int time = TileEntityFurnace.getItemBurnTime(contents[1]); if (time > 0) { this.decrStackSize(1, 1); this.burnTimeTotal = time; this.burnTime = time; } } if(burnTime > 0) { workingTime++; } } if (this.workingTime >= this.workingTimeNeeded) { this.smeltItem(); this.workingTime = 0; } if (!this.canSmelt() || burnTime <= 0) { this.workingTime = 0; } // Update WorkingTime –> Speed Upgrade if (contents[2] != null) { if (contents[2].getItem() == MechanicalCraft.speedUpgrade) { workingTimeNeeded = SpeedUpgrade.getSpeedUp(); } else if (contents[2].getItem() == MechanicalCraft.speedUpgradeTwo) { workingTimeNeeded = SpeedUpgradeTwo.getSpeedUp(); } else if (contents[2].getItem() == MechanicalCraft.speedUpgradeThree) { workingTimeNeeded = SpeedUpgradeThree.getSpeedUp(); } } else { workingTimeNeeded = workingTimeNeededDefault; } } @SideOnly(Side.CLIENT) public int getCookProgress() { return this.workingTime * 24 / this.workingTimeNeeded; } @SideOnly(Side.CLIENT) public int getBurnTime() { return this.burnTime * 14 / this.burnTimeTotal; } }Recipes
package com.google.SpyMan.Mechanicalcraft.common.blockOreExtractor; import com.google.SpyMan.Mechanicalcraft.common.MechanicalCraft; 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; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Random; public class OreExtractorRecipes { private static final OreExtractorRecipes smeltingBase = new OreExtractorRecipes(); private Map <itemstack[], itemstack="">smeltingList = new HashMap<itemstack[], itemstack="">(); private Item[] resultList = new Item[] { MechanicalCraft.brokenTinOre, MechanicalCraft.brokenCopperOre, MechanicalCraft.brokenZincOre, MechanicalCraft.brokenIronOre, MechanicalCraft.brokenGoldOre, MechanicalCraft.brokenCoalOre, MechanicalCraft.brokenDiamondOre, MechanicalCraft.brokenEmeraldOre, MechanicalCraft.brokenRedstoneOre, MechanicalCraft.brokenLapisOre }; public OreExtractorRecipes() { Random item = new Random(); Random quantityRandom = new Random(); int i = item.nextInt(9); int quantity = quantityRandom.nextInt(3); this.addRecipe(Blocks.gravel, new ItemStack(resultList*, quantity, 0)); } public void addRecipe(ItemStack input1, ItemStack output1) { ItemStack[] stackList = new ItemStack[] {input1}; this.smeltingList.put(stackList, output1); } public void addRecipe(Item input1, ItemStack output1) { this.addRecipe(new ItemStack(input1), output1); } public void addRecipe(Block input1, ItemStack output1) { this.addRecipe(new ItemStack(input1), output1); } public ItemStack getSmeltingResult(ItemStack[] stack) { Iterator<map.entry<itemstack[], itemstack="">> iterator = this.smeltingList.entrySet().iterator(); Map.Entry <itemstack[], itemstack="">entry; do { if(!iterator.hasNext()) { return null; } entry = (Map.Entry<itemstack[], itemstack="">)iterator.next(); } while(!this.isSameKey(stack, (ItemStack[])entry.getKey())); return (ItemStack)entry.getValue(); } private boolean isSameKey(ItemStack[] stackList, ItemStack[] stackList2) { boolean isSame = false; if(stackList[0].getItem() == stackList2[0].getItem()) { isSame = true; } else { return false; } return isSame; } public Map <itemstack[], itemstack="">getSmeltingList() { return this.smeltingList; } public static OreExtractorRecipes smelting() { return smeltingBase; } } ```</itemstack[],></itemstack[],></itemstack[],></map.entry<itemstack[],></itemstack[],></itemstack[],> -
Effectivement bizarre… Explique plus en détail ce que ça te fait
Et aussi là je te précise que ton random n’est pas vraiment random vu que ce sera le mémé Item pour toute la session de jeu
-
alors quand le craft est terminer j’ai un item en resultat dans un de mes slots result, sauf que cet item n’est pas vraiment “réel” :
Je ne peut pas le stacker –> il se remove quand je le stack
Cela vien de mes recipes car j’ai verifié la choseEt aussi pour les ramdons comment je peut faire?
-
Ah OK, pour le random, il faut que tu le fasses quand la recette à terminé (au getSmeltingResult), et peut-être que ça résoudra ton problème du même coup
-
Ok ça c’est pour la quantity mais le random de l’item comment je peut faire ?
-
Soit dans ta liste de recette tu met le tableau d’item à la place du stack, soit tu fait un mémé random pour tt les items avec le tableau que tu as déjà crée
-
J’ai essayé de verifier si l’item dans le slot est celui que je veut et de lancer le craft avec un random mais ce ne fonctionne poins
-
? Ai pas totalement compris
Je réexplique : pour tes recettes, au lieu de faire une map avec <ce que=“” ça=“” use,=“” ce=“” donne=“” (item)=“”>, tu fais <ce que=“” ça=“” use,=“” ce=“” peut=“” donner=“” <item[]=“”>, et ensuite dans la fonction getSmeltingResult(), tu prends un item au hasard.</ce></ce>
-
Je n’y arrive poins

J’ai essayé mais après le craft n’a pas de result
Voici ma class avant modification :[font=Courier Newpublic class ]%(#345f99)[OreExtractorRecipes ]{ private static final OreExtractorRecipes smeltingBase = new OreExtractorRecipes()%(#aaa9a7)[; ] private Map<ItemStack[], ItemStack> smeltingList = new HashMap<ItemStack[], ItemStack>()%(#aaa9a7)[; ] private Item[] resultList = new Item[] { MechanicalCraft.brokenTinOre%(#aaa9a7)[, ] MechanicalCraft.brokenCopperOre%(#aaa9a7)[, ] MechanicalCraft.brokenZincOre%(#aaa9a7)[, ] MechanicalCraft.brokenIronOre%(#aaa9a7)[, ] MechanicalCraft.brokenGoldOre%(#aaa9a7)[, ] MechanicalCraft.brokenCoalOre%(#aaa9a7)[, ] MechanicalCraft.brokenDiamondOre%(#aaa9a7)[, ] MechanicalCraft.brokenEmeraldOre%(#aaa9a7)[, ] MechanicalCraft.brokenRedstoneOre%(#aaa9a7)[, ] MechanicalCraft.%(#666965)[brokenLapisOre ] }%(#aaa9a7)[; ] Random itemRand = new Random()%(#aaa9a7)[; ] Random quantityRand = new Random()%(#aaa9a7)[; ] public OreExtractorRecipes() { this.addRecipe(Blocks.gravel, new ItemStack(resultList[itemRand.nextInt(10)], quantityRand.nextInt((3) + 1), 0))%(#aaa9a7)[; ] } public void addRecipe(ItemStack *input1*, ItemStack *output1*) { ItemStack[] stackList = new ItemStack[] {*input1*}%(#aaa9a7)[; ] this.smeltingList.put(stackList, *output1*)%(#aaa9a7)[; ] } public void addRecipe(Item *input1*, ItemStack *output1*) { this.addRecipe(new ItemStack(*input1*), *output1*)%(#aaa9a7)[; ] } public void addRecipe(Block *input1*, ItemStack *output1*) { this.addRecipe(new ItemStack(*input1*), *output1*)%(#aaa9a7)[; ] } public ItemStack getSmeltingResult(ItemStack[] *stack*) { Iterator<Map.Entry<ItemStack[], ItemStack>> iterator = this.smeltingList.entrySet().iterator()%(#aaa9a7)[; ] Map.Entry<ItemStack[], ItemStack> entry%(#aaa9a7)[; ] %(#0187df)[do ] { if(!iterator.hasNext()) { return null%(#aaa9a7)[; ] } entry = (Map.Entry<ItemStack[], ItemStack>)iterator.next()%(#aaa9a7)[; ] } while(!this.isSameKey(*stack*, (ItemStack[])entry.getKey()))%(#aaa9a7)[; ] return (ItemStack)entry.getValue()%(#aaa9a7)[; ] } private boolean isSameKey(ItemStack[] *stackList*, ItemStack[] *stackList2*) { boolean isSame = false%(#aaa9a7)[; ] if(*stackList*[0].getItem() == *stackList2*[0].getItem()) { isSame = true%(#aaa9a7)[; ] } %(#0187df)[else ] { return false%(#aaa9a7)[; ] } return isSame%(#aaa9a7)[; ] } public Map<ItemStack[], ItemStack> getSmeltingList() { return this.smeltingList%(#aaa9a7)[; ] } public static OreExtractorRecipes smelting() { return smeltingBase%(#aaa9a7)[; ] } } -
Cette liste :
%(#0187df)[[size=small]**private**] %(#345f99)[[size=small]Map]%(#aaa9a7)[[size=small]<]%(#345f99)[[size=small]ItemStack]%(#666600)[[size=small][][/font]]%(#aaa9a7)[[size=small],] %(#345f99)[[size=small]ItemStack]%(#aaa9a7)[[size=small]>] %(#666965)[[size=small]smeltingList ]%(#aaa9a7)[[size=small]=] %(#0187df)[[size=small]**new**] %(#afb8c5)[[size=small]HashMap]%(#aaa9a7)[[size=small]<]%(#345f99)[[size=small]ItemStack]%(#666600)[[size=small][][/font]]%(#aaa9a7)[[size=small],] %(#345f99)[[size=small]ItemStack]%(#aaa9a7)[[size=small]>]%(#666600)[[size=small]()]%(#aaa9a7)[[size=small];]devient
%(#0187df)[[size=small]**private**] %(#345f99)[[size=small]Map]%(#aaa9a7)[[size=small]<]%(#345f99)[[size=small]ItemStack]%(#666600)[[size=small][][/font]]%(#aaa9a7)[[size=small],] %(#345f99)[[size=small]ItemStack[]]%(#aaa9a7)[[size=small]>] %(#666965)[[size=small]smeltingList ]%(#aaa9a7)[[size=small]=] %(#0187df)[[size=small]**new**] %(#afb8c5)[[size=small]HashMap]%(#aaa9a7)[[size=small]<]%(#345f99)[[size=small]ItemStack]%(#666600)[[size=small][][/font]]%(#aaa9a7)[[size=small],] %(#345f99)[[size=small]ItemStack[]]%(#aaa9a7)[[size=small]>]%(#666600)[[size=small]()]%(#aaa9a7)[[size=small];]Ducoup ceci
%(#0187df)[[size=small]**this**]%(#666600)[[size=small].]%(#afb8c5)[[size=small]addRecipe]%(#666600)[[size=small](]%(#345f99)[[size=small]Blocks]%(#666600)[[size=small].]%(#666965)[[size=small]gravel]%(#aaa9a7)[[size=small],] %(#0187df)[[size=small]**new**] %(#afb8c5)[[size=small]ItemStack]%(#666600)[[size=small](]%(#666965)[[size=small]resultList]%(#666600)[[size=small][[/font]]%(#666965)[[size=small]itemRand]%(#666600)[[size=small].]%(#afb8c5)[[size=small]nextInt]%(#666600)[[size=small](]%(#feff06)[[size=small]10]%(#666600)[[size=small])]]%(#aaa9a7)[[size=small],] %(#666965)[[size=small]quantityRand]%(#666600)[[size=small].]%(#afb8c5)[[size=small]nextInt]%(#666600)[[size=small]((]%(#feff06)[[size=small]3]%(#666600)[[size=small])] %(#aaa9a7)[[size=small]+] %(#feff06)[[size=small]1]%(#666600)[[size=small])]%(#aaa9a7)[[size=small],] %(#feff06)[[size=small]0]%(#666600)[[size=small]))]%(#aaa9a7)[[size=small];]devient ceci
%(#0187df)[[size=small]**this**]%(#666600)[[size=small].]%(#afb8c5)[[size=small]addRecipe]%(#666600)[[size=small](]%(#345f99)[[size=small]Blocks]%(#666600)[[size=small].]%(#666965)[[size=small]gravel]%(#aaa9a7)[[size=small],] %(#666965)[[size=small]resultList]%(#aaa9a7)[[size=small]; //Il faut donc que tu transformes resultList en un array d'itemstacks]Et la fonction getSmeltingResult devient ça (après le while) :
ItemStack result = [size=small((][size=smallItemStack[]][size=small)][size=smallentry][size=small.][size=smallgetValue][size=small())[random.nextInt(…)];] [size=smallresult.stackSize = random.nextInt(…);] [size=small**return**] result[size=small;] ``` Et il faut bien sur que tu changes toutes les fonctions addRecipe. -
J’ai une erreur ici: ```java
(ItemStack[])entry.getValue()qui me dit "cannot cast ….ItemStack to .....ItemStack[]" ```java [font=Courier Newpublic class ]%(#345f99)[OreExtractorRecipes ]{ private static final OreExtractorRecipes smeltingBase = new OreExtractorRecipes()%(#aaa9a7)[; ] private Map<ItemStack[], ItemStack[]> smeltingList = new HashMap<ItemStack[], ItemStack[]>()%(#aaa9a7)[; ] private ItemStack[] resultList = new ItemStack[] { new ItemStack(MechanicalCraft.brokenTinOre)%(#aaa9a7)[, ] new ItemStack(MechanicalCraft.brokenCopperOre)%(#aaa9a7)[, ] new ItemStack(MechanicalCraft.brokenZincOre)%(#aaa9a7)[, ] new ItemStack(MechanicalCraft.brokenIronOre)%(#aaa9a7)[, ] new ItemStack(MechanicalCraft.brokenGoldOre)%(#aaa9a7)[, ] new ItemStack(MechanicalCraft.brokenCoalOre)%(#aaa9a7)[, ] new ItemStack(MechanicalCraft.brokenDiamondOre)%(#aaa9a7)[, ] new ItemStack(MechanicalCraft.brokenEmeraldOre)%(#aaa9a7)[, ] new ItemStack(MechanicalCraft.brokenRedstoneOre)%(#aaa9a7)[, ] new ItemStack(MechanicalCraft.brokenLapisOre) }%(#aaa9a7)[; ] Random itemRand = new Random()%(#aaa9a7)[; ] Random quantityRand = new Random()%(#aaa9a7)[; ] public OreExtractorRecipes() { this.addRecipe(Blocks.gravel, resultList)%(#aaa9a7)[; ] } public void addRecipe(ItemStack *input1*, ItemStack[] *output1*) { ItemStack[] stackList = new ItemStack[] {*input1*}%(#aaa9a7)[; ] this.smeltingList.put(stackList, *output1*)%(#aaa9a7)[; ] } public void addRecipe(Item *input1*, ItemStack[] *output1*) { this.addRecipe(new ItemStack(*input1*), *output1*)%(#aaa9a7)[; ] } public void addRecipe(Block *input1*, ItemStack[] *output1*) { this.addRecipe(new ItemStack(*input1*), *output1*)%(#aaa9a7)[; ] } public ItemStack getSmeltingResult(ItemStack[] stack) { Iterator<Map.Entry<ItemStack[], ItemStack[]>> iterator = this.smeltingList.entrySet().iterator()%(#aaa9a7)[; ] Map.Entry<ItemStack[], ItemStack> entry%(#aaa9a7)[; ] %(#0187df)[do ] { if(!iterator.hasNext()) { return null%(#aaa9a7)[; ] } entry = (Map.Entry<ItemStack[], ItemStack>)iterator.next()%(#aaa9a7)[; ] } while(!this.isSameKey(*stack*, (ItemStack[])entry.getKey()))%(#aaa9a7)[; ] ItemStack result = ((ItemStack[])entry.getValue())[itemRand.nextInt(10)]%(#aaa9a7)[; ] result.stackSize = quantityRand.nextInt((3) + 1)%(#aaa9a7)[; ] return result%(#aaa9a7)[; ] } private boolean isSameKey(ItemStack[] *stackList*, ItemStack[] *stackList2*) { boolean isSame = false%(#aaa9a7)[; ] if(*stackList*[0].getItem() == *stackList2*[0].getItem()) { isSame = true%(#aaa9a7)[; ] } %(#0187df)[else ] { return false%(#aaa9a7)[; ] } return isSame%(#aaa9a7)[; ] } public Map<ItemStack[], ItemStack[]> getSmeltingList() { return this.smeltingList%(#aaa9a7)[; ] } public static OreExtractorRecipes smelting() { return smeltingBase%(#aaa9a7)[; ] } -
Ah oui, change ça :
java Map.Entry <itemstack[], itemstack="">entry;par ça : ```java
Map.Entry <itemstack[], itemstack[]=“”>entry;Et également ça : ```java entry = (Map.Entry<itemstack[], itemstack="">)iterator.next(); ``` par ça : ```java entry = (Map.Entry<itemstack[], itemstack[]="">)iterator.next(); ```.</itemstack[],></itemstack[],></itemstack[],></itemstack[],> -
Merci y a plus d’erreurs.
Mon Craft peut sortir plusieurs items différents, pour cela j’ai créer plusieurs slotresults (12 en tout). Comment faire pour qu’il soi tous utilisés si par exemple l’un est plein ou que l’item n’est pas le même et bien que le suivant se remplisse? -
Il faut que tu fasses une fonction qui vérifies si un slot est libre (item correcpondant, taille…), si le slot est libre, tu ajoutes l’item, sinon, tu fait la même chose avec le slot d’après. je sais qu’il y a une fonction comme ça dans le InventoryPlayer, essaye de regarder.
-
J’ai regardé dans la class InventoryPlayer j’ai je n’est pas trouvé la fonction en question
-
playerInventory.addItemStackToInventory
-
J’ai essayé de faire plusieurs conditions pour vérifier l’état du slot mais mon craft ne se lance plus car je n’est plus de slotresult “valide”
-
Tu fais une fonction qui, avec un slot donné en id, vérifies si ce slot est vide ou que son item correspond à celui que tu veux ajouter.
Après dans ta fonction smelt, tu fais un for() pour vérifier chaque slot avec cette fonction, quand un slot libre est trouvé, tu insères l’item dans le slot libre. Et tu fais la même chose dans la fonction canSmelt() sauf que là tu n’ajoutes pas l’item. -
Mon jeu crash

[20:47:08] [Client thread/FATAL]: Reported exception thrown! net.minecraft.util.ReportedException: Ticking block entity at net.minecraft.world.World.updateEntities(World.java:2175) ~[World.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:2097) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_66] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_66] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_66] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_66] 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/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_66] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_66] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_66] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_66] at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:?] Caused by: java.lang.ArrayIndexOutOfBoundsException: 15 at com.google.SpyMan.Mechanicalcraft.common.blockOreExtractor.TileEntityOreExtractor.smeltItem(TileEntityOreExtractor.java:258) ~[TileEntityOreExtractor.class:?] at com.google.SpyMan.Mechanicalcraft.common.blockOreExtractor.TileEntityOreExtractor.updateEntity(TileEntityOreExtractor.java:297) ~[TileEntityOreExtractor.class:?] at net.minecraft.world.World.updateEntities(World.java:2160) ~[World.class:?] … 17 more [20:47:08] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ---- // Why is it breaking :( Time: 14/03/16 20:47 Description: Ticking block entity java.lang.ArrayIndexOutOfBoundsException: 15 at com.google.SpyMan.Mechanicalcraft.common.blockOreExtractor.TileEntityOreExtractor.smeltItem(TileEntityOreExtractor.java:258) at com.google.SpyMan.Mechanicalcraft.common.blockOreExtractor.TileEntityOreExtractor.updateEntity(TileEntityOreExtractor.java:297) at net.minecraft.world.World.updateEntities(World.java:2160) at net.minecraft.client.Minecraft.runTick(Minecraft.java:2097) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) 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(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) 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) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)[font=Courier Newpublic class ]TileEntityOreExtractor extends TileEntity implements %(#345f99)[IInventory ]{ private byte direction%(#aaa9a7)[; ] %(#8242ff)[/** Slots list */ ] private ItemStack[] contents = new ItemStack[15]%(#aaa9a7)[; ] %(#8242ff)[/** Actual working time */ ] protected int workingTime = 0%(#aaa9a7)[; ] %(#8242ff)[/** Working time for one recipes */ ] protected int workingTimeNeeded = 200%(#aaa9a7)[; ] %(#8242ff)[/** Working time default value for one recipes */ ] protected int workingTimeNeededDefault = 200%(#aaa9a7)[; ] %(#8242ff)[/** Actual burn time */ ] protected int burnTime = 0%(#aaa9a7)[; ] %(#8242ff)[/** Burn time of fuel */ ] protected int burnTimeTotal = 0%(#aaa9a7)[; ] %(#8242ff)[/** Id of the result slot */ ] private int slotResultID = 3%(#aaa9a7)[; ] %(#8242ff)[/** Id of the upgrade slot */ ] private int slotUpgradeID = 2%(#aaa9a7)[; ] %(#8242ff)[/** Id of the fuel slot */ ] private int slotFuelID = 1%(#aaa9a7)[; ] %(#8242ff)[/** Id of the input slot */ ] private int slotInputID = 0%(#aaa9a7)[; ] %(#278c3c)[***@Override ***] public void readFromNBT(NBTTagCompound *compound*) { super.readFromNBT(*compound*)%(#aaa9a7)[; ] this.direction = *compound*.getByte("Direction")%(#aaa9a7)[; ] NBTTagList nbttaglist = *compound*.getTagList("Items", 10)%(#aaa9a7)[; ] this.contents = new ItemStack[this.getSizeInventory()]%(#aaa9a7)[; ] for(int %(#666965)_= 0; %(#666965)_< nbttaglist.tagCount(); ++%(#666965)*) { NBTTagCompound nbtTagCompound = nbttaglist.getCompoundTagAt(%(#666965)*)%(#aaa9a7)[; ] int j = nbtTagCompound.getByte("Slot") & 255%(#aaa9a7)[; ] if(j >= 0 && j < this.contents.length) { this.contents[j] = ItemStack.loadItemStackFromNBT(nbtTagCompound)%(#aaa9a7)[; ] } } this.workingTime = *compound*.getShort("workingTime")%(#aaa9a7)[; ] this.burnTime = *compound*.getShort("burnTime")%(#aaa9a7)[; ] this.burnTimeTotal = *compound*.getShort("burnTimeTotal")%(#aaa9a7)[; ] } %(#278c3c)[***@Override ***] public void writeToNBT(NBTTagCompound *compound*) { super.writeToNBT(*compound*)%(#aaa9a7)[; ] NBTTagList nbttaglist = new NBTTagList()%(#aaa9a7)[; ] *compound*.setByte("Direction", this.direction)%(#aaa9a7)[; ] for(int %(#666965)_= 0; %(#666965)_< this.contents.length; ++%(#666965)*) { if(this.contents[%(#666965)*] != null) { NBTTagCompound nbtTagCompound = new NBTTagCompound()%(#aaa9a7)[; ] nbtTagCompound.setByte("Slot", (byte)%(#666965)*)%(#aaa9a7)[; ] this.contents[%(#666965)*].writeToNBT(nbtTagCompound)%(#aaa9a7)[; ] nbttaglist.appendTag(nbtTagCompound)%(#aaa9a7)[; ] } } *compound*.setTag("Items", nbttaglist)%(#aaa9a7)[; ] *compound*.setShort("workingTime", (short)this.workingTime)%(#aaa9a7)[; ] *compound*.setShort("burnTime", (short)this.burnTime)%(#aaa9a7)[; ] *compound*.setShort("burnTimeTotal", (short)this.burnTimeTotal)%(#aaa9a7)[; ] } public byte getDirection() { return direction%(#aaa9a7)[; ] } public void setDirection(byte *direction*) { this.direction = *direction*%(#aaa9a7)[; ] this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord)%(#aaa9a7)[; ] } public Packet getDescriptionPacket() { NBTTagCompound nbtTagCompound = new NBTTagCompound()%(#aaa9a7)[; ] this.writeToNBT(nbtTagCompound)%(#aaa9a7)[; ] return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbtTagCompound)%(#aaa9a7)[; ] } public void onDataPacket(NetworkManager *net*, S35PacketUpdateTileEntity *pkt*) { this.readFromNBT(*pkt*.func_148857_g())%(#aaa9a7)[; ] } public int getSizeInventory() { return this.contents.length%(#aaa9a7)[; ] } public void openInventory() {} public void closeInventory() {} public String getInventoryName() { return MechanicalCraft.oreExtractor.getLocalizedName()%(#aaa9a7)[; ] } public boolean hasCustomInventoryName() { return false%(#aaa9a7)[; ] } public int getInventoryStackLimit() { return 64%(#aaa9a7)[; ] } 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%(#aaa9a7)[; ] } public ItemStack getStackInSlot(int *slotIndex*) { return this.contents[*slotIndex*]%(#aaa9a7)[; ] } public ItemStack decrStackSize(int *slotIndex*, int *amount*) { if(this.contents[*slotIndex*] != null) { ItemStack itemstack%(#aaa9a7)[; ] if(this.contents[*slotIndex*].stackSize <= *amount*) { itemstack = this.contents[*slotIndex*]%(#aaa9a7)[; ] this.contents[*slotIndex*] = null%(#aaa9a7)[; ] this.markDirty()%(#aaa9a7)[; ] return itemstack%(#aaa9a7)[; ] } %(#0187df)[else ] { itemstack = this.contents[*slotIndex*].splitStack(*amount*)%(#aaa9a7)[; ] if(this.contents[*slotIndex*].stackSize == 0) { this.contents[*slotIndex*] = null%(#aaa9a7)[; ] } this.markDirty()%(#aaa9a7)[; ] return itemstack%(#aaa9a7)[; ] } } %(#0187df)[else ] { return null%(#aaa9a7)[; ] } } public ItemStack getStackInSlotOnClosing(int *slotIndex*) { if(this.contents[*slotIndex*] != null) { ItemStack itemstack = this.contents[*slotIndex*]%(#aaa9a7)[; ] this.contents[*slotIndex*] = null%(#aaa9a7)[; ] return itemstack%(#aaa9a7)[; ] } %(#0187df)[else ] { return null%(#aaa9a7)[; ] } } public void setInventorySlotContents(int *slotIndex*, ItemStack *stack*) { this.contents[*slotIndex*] = *stack*%(#aaa9a7)[; ] if(*stack *!= null && *stack*.stackSize > this.getInventoryStackLimit()) { *stack*.stackSize = this.getInventoryStackLimit()%(#aaa9a7)[; ] } this.markDirty()%(#aaa9a7)[; ] } public boolean isItemValidForSlot(int *slot*, ItemStack *stack*) { return *slot *== 2 ? false : true%(#aaa9a7)[; ] } public boolean isBurning() { return this.workingTime > 0%(#aaa9a7)[; ] } protected boolean canSmelt() { if(this.contents[this.slotInputID] == null) { return false%(#aaa9a7)[; ] } %(#0187df)[else ] { ItemStack itemstack = OreExtractorRecipes.smelting().getSmeltingResult(new ItemStack[] { this.contents[this.slotInputID] })%(#aaa9a7)[; ] int j = 0%(#aaa9a7)[; ] for (int %(#666965)_= 3; %(#666965)_< 15; %(#666965)*++) { j = %(#666965)*%(#aaa9a7)[; ] if (itemstack == null) { return false%(#aaa9a7)[; ] } if (this.contents[%(#666965)*] == null) { return true%(#aaa9a7)[; ] } if (!this.contents[%(#666965)*].isItemEqual(itemstack)) { return false%(#aaa9a7)[; ] } } int result = contents[j].stackSize + itemstack.stackSize%(#aaa9a7)[; ] return result <= getInventoryStackLimit() && result <= this.contents[j].getMaxStackSize()%(#aaa9a7)[; ] } } public void smeltItem() { ItemStack itemstack = OreExtractorRecipes.smelting().getSmeltingResult(new ItemStack[] { this.contents[this.slotInputID] })%(#aaa9a7)[; ] for (int %(#666965)_= 3; %(#666965)_<= 15; %(#666965)*++) { if (this.canSmelt()) { if (this.contents[%(#666965)*] == null) { this.contents[%(#666965)*] = itemstack.copy()%(#aaa9a7)[; ] } else if (this.contents[%(#666965)*].getItem() == itemstack.getItem()) { this.contents[%(#666965)*].stackSize += itemstack.stackSize%(#aaa9a7)[; ] } this.decrStackSize(0, 1)%(#aaa9a7)[; ] } } } public void updateEntity() { if(this.burnTime > 0) { burnTime%(#aaa9a7)[–; ] } if(this.canSmelt()) { if(this.burnTime <= 0) { int %(#666965)________