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[],>