Nope. Not doing that after all.

This commit is contained in:
oitsjustjose 2015-10-30 15:54:16 -05:00
commit 04cdd24870
12 changed files with 3 additions and 1026 deletions

View file

@ -1,122 +0,0 @@
package com.oitsjustjose.criss_cross.Blocks;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
import com.oitsjustjose.criss_cross.CrissCross;
import com.oitsjustjose.criss_cross.GUI.GUIHandler;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityAutosmith;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityAutosmith;
import com.oitsjustjose.criss_cross.Util.Reference;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockAutosmith extends BlockMachineBase
{
private static String unlocName = "autosmith";
public BlockAutosmith()
{
super(unlocName);
GameRegistry.registerTileEntity(TileEntityAutosmith.class, unlocName);
GameRegistry.registerBlock(this, unlocName);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register)
{
blockTextures[0] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Bottom");
blockTextures[1] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Top");
blockTextures[2] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Front");
blockTextures[3] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Sides");
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta)
{
Random random = new Random();
TileEntityAutosmith tile = (TileEntityAutosmith) world.getTileEntity(x, y, z);
if(tile != null)
{
for(int i = 0; i < tile.getSizeInventory(); ++i)
{
ItemStack itemstack = tile.getStackInSlot(i);
if(itemstack != null)
{
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
float f2 = random.nextFloat() * 0.8F + 0.1F;
while(itemstack.stackSize > 0)
{
int j = random.nextInt(21) + 10;
if(j > itemstack.stackSize)
{
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, (double) ((float) x + f),
(double) ((float) y + f1), (double) ((float) z + f2),
new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if(itemstack.hasTagCompound())
{
entityitem.getEntityItem()
.setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (double) ((float) random.nextGaussian() * f3);
entityitem.motionY = (double) ((float) random.nextGaussian() * f3 + 0.2F);
entityitem.motionZ = (double) ((float) random.nextGaussian() * f3);
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileEntityAutosmith();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX,
float hitY, float hitZ)
{
if(world.isRemote)
{
return true;
}
else
{
TileEntityAutosmith tileentityautosmith = (TileEntityAutosmith) world.getTileEntity(x, y, z);
if(tileentityautosmith != null)
player.openGui(CrissCross.instance, GUIHandler.Autosmith, world, x, y, z);
return true;
}
}
}

View file

@ -2,34 +2,21 @@ package com.oitsjustjose.criss_cross.Blocks;
import com.oitsjustjose.criss_cross.CrissCross;
import com.oitsjustjose.criss_cross.GUI.GUIHandler;
import com.oitsjustjose.criss_cross.Recipes.CropomatorRecipes;
import com.oitsjustjose.criss_cross.Recipes.ElectroextractorRecipes;
import com.oitsjustjose.criss_cross.Recipes.CCMachineRecipes;
import com.oitsjustjose.criss_cross.Recipes.WoodchipperRecipes;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityElectroextractor;
import com.oitsjustjose.criss_cross.Util.CCLog;
import com.oitsjustjose.criss_cross.Util.ConfigHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
public class CCBlocks
{
public static Block cropomator;
public static Block electroextractor;
public static Block woodchipper;
public static Block autosmith;
public static void init()
{
cropomator = new BlockCropomator();
electroextractor = new BlockElectroextractor();
woodchipper = new BlockWoodchipper();
autosmith = new BlockAutosmith();
NetworkRegistry.INSTANCE.registerGuiHandler(CrissCross.instance, new GUIHandler());
}

View file

@ -1,155 +0,0 @@
package com.oitsjustjose.criss_cross.Container;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityAutosmith;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerAutosmith extends Container
{
TileEntityAutosmith autosmith;
EntityPlayer player;
private int lastUseTime;
private int lastChopTime;
private int lastFuelTime;
public ContainerAutosmith(EntityPlayer player, TileEntityAutosmith autosmith)
{
this.player = player;
this.autosmith = autosmith;
lastUseTime = 0;
lastChopTime = 0;
lastFuelTime = 0;
this.addSlotToContainer(new Slot(autosmith, 0, 56, 17)); // tool
this.addSlotToContainer(new Slot(autosmith, 1, 56, 53)); // repairItem
this.addSlotToContainer(new MachineOutputSlot(player, autosmith, 2, 116, 35));
this.addSlotToContainer(new Slot(autosmith, 3, 140, 35));
this.addInventorySlots();
}
@SideOnly(Side.CLIENT)
public void updateProgressBar(int timeType1, int timeType2)
{
switch(timeType1)
{
case 0:
this.autosmith.processTime = timeType2;
break;
case 1:
this.autosmith.fuelTime = timeType2;
break;
case 2:
this.autosmith.fuelUsetime = timeType2;
break;
}
}
@Override
public void addCraftingToCrafters(ICrafting crafting)
{
super.addCraftingToCrafters(crafting);
crafting.sendProgressBarUpdate(this, 0, this.autosmith.processTime);
crafting.sendProgressBarUpdate(this, 1, this.autosmith.fuelTime);
crafting.sendProgressBarUpdate(this, 2, this.autosmith.fuelUsetime);
}
@Override
public void detectAndSendChanges()
{
super.detectAndSendChanges();
for(int i = 0; i < this.crafters.size(); ++i)
{
ICrafting crafting = (ICrafting) this.crafters.get(i);
if(this.lastUseTime != this.autosmith.processTime)
crafting.sendProgressBarUpdate(this, 0, this.autosmith.processTime);
if(this.lastChopTime != this.autosmith.fuelTime)
crafting.sendProgressBarUpdate(this, 1, this.autosmith.fuelTime);
if(this.lastFuelTime != this.autosmith.fuelUsetime)
crafting.sendProgressBarUpdate(this, 2, this.autosmith.fuelUsetime);
}
this.lastUseTime = this.autosmith.processTime;
this.lastChopTime = this.autosmith.fuelTime;
this.lastFuelTime = this.autosmith.fuelUsetime;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{
ItemStack itemstack = null;
Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (slotID < 4)
{
if (!this.mergeItemStack(itemstack1, 4, 40, true))
return null;
}
else if (TileEntityAutosmith.isItemFuel(itemstack1))
{
if (!this.mergeItemStack(itemstack1, 1, 2, false))
return null;
}
else if (slotID >= 3 && slotID < 31)
{
if (!this.mergeItemStack(itemstack1, 31, 40, false))
return null;
}
else if (slotID >= 30 && slotID < 40)
{
if (!this.mergeItemStack(itemstack1, 4, 31, false))
return null;
}
if (itemstack1.stackSize == 0)
{
slot.putStack(null);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize)
return null;
slot.onPickupFromSlot(player, itemstack);
}
return itemstack;
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return this.autosmith.isUseableByPlayer(this.player);
}
public final void addInventorySlots()
{
this.addInventorySlots(8, 84, 142);
}
public final void addInventorySlots(int xOffset, int yOffset, int yHotbar)
{
InventoryPlayer inventory = this.player.inventory;
for(int i = 0; i < 3; ++i)
for(int j = 0; j < 9; ++j)
this.addSlotToContainer(new Slot(inventory, 9 + j + i * 9, xOffset + j * 18, yOffset + i * 18));
for(int i = 0; i < 9; ++i)
this.addSlotToContainer(new Slot(inventory, i, xOffset + i * 18, yHotbar));
}
}

View file

@ -16,6 +16,7 @@ import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import net.minecraft.creativetab.CreativeTabs;

View file

@ -1,48 +0,0 @@
package com.oitsjustjose.criss_cross.GUI;
import org.lwjgl.opengl.GL11;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityAutosmith;
import com.oitsjustjose.criss_cross.Container.ContainerAutosmith;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
public class GUIAutosmith extends GuiContainer
{
public static final ResourceLocation texture = new ResourceLocation("crisscross", "textures/gui/autosmith.png");
private TileEntityAutosmith autosmith;
public GUIAutosmith(EntityPlayer player, TileEntityAutosmith autosmith)
{
super(new ContainerAutosmith(player, autosmith));
this.autosmith = autosmith;
}
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.autosmith"), 55, 7, 4210752);
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 7, this.ySize - 92,
4210752);
}
protected void drawGuiContainerBackgroundLayer(float partialTickTime, int mouseX, int mouseY)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
if(this.autosmith.isUsingFuel())
{
int i1 = this.autosmith.getBurnTimeRemainingScaled(13);
this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1);
i1 = this.autosmith.getProgressScaled(24);
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
}
}
}

View file

@ -1,10 +1,8 @@
package com.oitsjustjose.criss_cross.GUI;
import com.oitsjustjose.criss_cross.Container.ContainerAutosmith;
import com.oitsjustjose.criss_cross.Container.ContainerCropomator;
import com.oitsjustjose.criss_cross.Container.ContainerElectroextractor;
import com.oitsjustjose.criss_cross.Container.ContainerWoodchipper;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityAutosmith;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityCropomator;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityElectroextractor;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityWoodchipper;
@ -19,7 +17,6 @@ public class GUIHandler implements IGuiHandler
public static final int Cropomator = 1;
public static final int Electroextractor = 2;
public static final int Woodchipper = 3;
public static final int Autosmith = 4;
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
@ -44,12 +41,7 @@ public class GUIHandler implements IGuiHandler
return new ContainerWoodchipper(player, TE);
}
if(tile instanceof TileEntityAutosmith)
{
TileEntityAutosmith TE = (TileEntityAutosmith) tile;
return new ContainerAutosmith(player, TE);
}
return null;
}
@ -77,12 +69,7 @@ public class GUIHandler implements IGuiHandler
return new GUIWoodchipper(player, TE);
}
if(tile instanceof TileEntityAutosmith)
{
TileEntityAutosmith TE = (TileEntityAutosmith) tile;
return new GUIAutosmith(player, TE);
}
return null;
}
}

View file

@ -1,21 +1,15 @@
package com.oitsjustjose.criss_cross.Items;
import com.oitsjustjose.criss_cross.Recipes.ForgingHammerRecipes;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
public class CCItems
{
public static Item dusts;
public static Item magicBucket;
public static Item forgingHammer;
public static void init()
{
dusts = new ItemDust();
magicBucket = new ItemMagicBuckets();
forgingHammer = new ItemForgingHammer();
ForgingHammerRecipes.init();
}
}

View file

@ -1,52 +0,0 @@
package com.oitsjustjose.criss_cross.Items;
import java.util.List;
import com.oitsjustjose.criss_cross.CrissCross;
import com.oitsjustjose.criss_cross.Util.Reference;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class ItemForgingHammer extends Item
{
@SideOnly(Side.CLIENT)
IIcon icon;
private String unlocName;
public ItemForgingHammer()
{
unlocName = "forgingHammer";
this.setContainerItem(this);
this.maxStackSize = 1;
this.setMaxDamage(3);
this.setCreativeTab(CrissCross.CCTab);
GameRegistry.registerItem(this, unlocName);
}
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta)
{
return this.icon;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register)
{
icon = register.registerIcon(Reference.modid + ":" + this.unlocName);
}
}

View file

@ -1,169 +0,0 @@
package com.oitsjustjose.criss_cross.Recipes;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import com.google.common.collect.Maps;
import net.minecraft.item.ItemStack;
public class AutosmithRecipes
{
private Map<ItemStack, Integer> stack1Size = Maps.newHashMap();
private Map<ItemStack, Integer> stack2Size = Maps.newHashMap();
public class RepairRecipe
{
private final ItemStack toolItem;
private final ItemStack repairItem;
private final ItemStack repairedTool;
public RepairRecipe(final ItemStack repairItem, final ItemStack toolItem)
{
this.repairItem = repairItem;
this.toolItem = toolItem;
this.repairedTool = toolItem.copy();
this.repairedTool.setItemDamage(0);
}
public ItemStack getCraftingResult()
{
return this.repairedTool.copy();
}
public ItemStack[] getIngredients()
{
return new ItemStack[]
{
this.repairItem, this.toolItem
};
}
public boolean uses(final ItemStack ingredient)
{
if(ingredient == null)
{
return false;
}
if((this.repairItem != null) && this.repairItem.isItemEqual(ingredient))
{
return true;
}
else if((this.toolItem != null) && this.toolItem.isItemEqual(ingredient))
{
return true;
}
return false;
}
@SuppressWarnings("unused")
public boolean matches(ItemStack toolItem, ItemStack repairItem)
{
if(toolItem.isItemEqual(repairItem))
{
return false;
}
if(this.uses(toolItem) && this.uses(repairItem))
{
return true;
}
if(this.uses(toolItem) && (repairItem == null))
{
return true;
}
if(this.uses(repairItem) && (toolItem == null))
{
return true;
}
return false;
}
}
private static AutosmithRecipes instance = new AutosmithRecipes();
private final ArrayList<RepairRecipe> recipes = new ArrayList<RepairRecipe>();
public static AutosmithRecipes getInstance()
{
return AutosmithRecipes.instance;
}
public void addRecipe(ItemStack itemStack, ItemStack otherItemStack)
{
this.recipes.add(new RepairRecipe(itemStack, otherItemStack));
this.stack1Size.put(itemStack, itemStack.stackSize);
this.stack2Size.put(otherItemStack, otherItemStack.stackSize);
this.stack1Size.put(otherItemStack, otherItemStack.stackSize);
this.stack2Size.put(itemStack, itemStack.stackSize);
}
public ItemStack getResult(ItemStack toolItem, ItemStack repairItem)
{
for(int j = 0; j < this.recipes.size(); ++j)
{
RepairRecipe irecipe = this.recipes.get(j);
if(irecipe.matches(toolItem, repairItem))
{
if((ItemStack.areItemStacksEqual(toolItem, irecipe.toolItem) && ItemStack.areItemStacksEqual(repairItem, irecipe.repairItem)))
{
return irecipe.getCraftingResult();
}
}
}
return null;
}
public boolean hasUsage(ItemStack itemStack)
{
for(int j = 0; j < this.recipes.size(); ++j)
{
RepairRecipe irecipe = this.recipes.get(j);
if(irecipe.uses(itemStack))
{
return true;
}
}
return false;
}
public ArrayList<RepairRecipe> getRecipesFor(ItemStack output)
{
ArrayList<RepairRecipe> list = new ArrayList<RepairRecipe>();
for(RepairRecipe recipe : this.recipes)
{
if(recipe.repairedTool.isItemEqual(output)
&& recipe.repairedTool.getTagCompound() == output.getTagCompound())
{
list.add(recipe);
}
}
return list;
}
public ArrayList<RepairRecipe> getRecipesUsing(ItemStack ingredient)
{
ArrayList<RepairRecipe> list = new ArrayList<RepairRecipe>();
for(RepairRecipe recipe : this.recipes)
{
if(recipe.uses(ingredient))
{
list.add(recipe);
continue;
}
}
return list;
}
}

View file

@ -4,7 +4,6 @@ import java.util.ArrayList;
import com.oitsjustjose.criss_cross.Items.CCItems;
import com.oitsjustjose.criss_cross.Items.ItemDust;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityAutosmith;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityCropomator;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityElectroextractor;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityWoodchipper;
@ -19,7 +18,6 @@ import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
@ -38,9 +36,6 @@ public class CCMachineRecipes
initWoodchipperFuels();
initWoodchipperOreDictionary();
AutosmithRecipes.getInstance().addRecipe(new ItemStack(Items.iron_pickaxe, 1, Short.MAX_VALUE), new ItemStack(Items.iron_ingot));
TileEntityAutosmith.addFuel(new ItemStack(Items.redstone));
ElectroextractorRecipes.getInstance().addRecipe(new ItemStack(Blocks.diamond_ore),
new ItemStack(Items.diamond, electroQTY));
ElectroextractorRecipes.getInstance().addRecipe(new ItemStack(Blocks.emerald_ore),

View file

@ -1,41 +0,0 @@
package com.oitsjustjose.criss_cross.Recipes;
import com.oitsjustjose.criss_cross.Items.CCItems;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
public class ForgingHammerRecipes
{
public static void init()
{
for(int i = 0; i < Item.itemRegistry.getKeys().size(); i++)
{
ItemStack toolStack = new ItemStack(Item.getItemById(i));
if(toolStack != null && (toolStack.getItem() instanceof ItemTool || toolStack.getItem() instanceof ItemArmor))
{
for(int toolMat = 0; toolMat < Item.ToolMaterial.values().length; toolMat++)
{
ItemStack repairItem = Item.ToolMaterial.values()[toolMat].getRepairItemStack();
String[] toolName = toolStack.getDisplayName().split(" ");
if(repairItem == null)
return;
for(int name = 0; name < toolName.length; name++)
{
if(repairItem.getDisplayName().contains(toolName[name]))
{
ItemStack repairedTool = toolStack.copy();
toolStack.setItemDamage(0);
GameRegistry.addShapelessRecipe(repairedTool, new Object[] {
toolStack, repairItem, CCItems.forgingHammer
});
}
}
}
}
}
}
}

View file

@ -1,400 +0,0 @@
package com.oitsjustjose.criss_cross.TileEntity;
import java.util.ArrayList;
import com.oitsjustjose.criss_cross.Util.ConfigHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import com.oitsjustjose.criss_cross.Blocks.BlockAutosmith;
import com.oitsjustjose.criss_cross.Recipes.AutosmithRecipes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
public class TileEntityAutosmith extends TileEntity implements ISidedInventory
{
private static int proTicks = ConfigHandler.autosmithProcessTime;
private static final int[] slotsTop = new int[]
{
0
};
private static final int[] slotsBottom = new int[]
{
3
};
private static final int[] slotsSides = new int[]
{
2, 1
};
private static ArrayList<ItemStack> fuelItems = new ArrayList<ItemStack>();
private ItemStack[] ItemStacks = new ItemStack[4];
//Slot [0] is the tool Item
//Slot [1] is the tool repair Item
//Slot [2] is the output
//Slot [3] is the fuel
public int fuelTime;
public int processTime;
public int fuelUsetime;
public static ArrayList<ItemStack> getFuels()
{
return fuelItems;
}
@Override
public int getSizeInventory()
{
return this.ItemStacks.length;
}
@Override
public ItemStack getStackInSlot(int slot)
{
return this.ItemStacks[slot];
}
@Override
public ItemStack decrStackSize(int slot, int qtyToDecr)
{
if(this.ItemStacks[slot] != null)
{
ItemStack itemstack;
if(this.ItemStacks[slot].stackSize <= qtyToDecr)
{
itemstack = this.ItemStacks[slot];
this.ItemStacks[slot] = null;
return itemstack;
}
else
{
itemstack = this.ItemStacks[slot].splitStack(qtyToDecr);
if(this.ItemStacks[slot].stackSize == 0)
{
this.ItemStacks[slot] = null;
}
return itemstack;
}
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
if(this.ItemStacks[slot] != null)
{
ItemStack itemstack = this.ItemStacks[slot];
this.ItemStacks[slot] = null;
return itemstack;
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemstack)
{
this.ItemStacks[slot] = itemstack;
if(itemstack != null && itemstack.stackSize > this.getInventoryStackLimit())
{
itemstack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public String getInventoryName()
{
return "container.autosmith";
}
@Override
public boolean hasCustomInventoryName()
{
return true;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT(tag);
NBTTagList nbttaglist = tag.getTagList("Items", 10);
this.ItemStacks = new ItemStack[this.getSizeInventory()];
for(int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
byte b0 = nbttagcompound1.getByte("Slot");
if(b0 >= 0 && b0 < this.ItemStacks.length)
{
this.ItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
this.fuelTime = tag.getShort("FuelTime");
this.processTime = tag.getShort("WorkTime");
this.fuelUsetime = getItemBurnTime(this.ItemStacks[3]);
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
tag.setShort("FuelTime", (short) this.fuelTime);
tag.setShort("WorkTime", (short) this.processTime);
NBTTagList nbttaglist = new NBTTagList();
for(int i = 0; i < this.ItemStacks.length; ++i)
{
if(this.ItemStacks[i] != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte) i);
this.ItemStacks[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
tag.setTag("Items", nbttaglist);
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@SideOnly(Side.CLIENT)
public int getProgressScaled(int par1)
{
return this.processTime * par1 / proTicks;
}
@SideOnly(Side.CLIENT)
public int getBurnTimeRemainingScaled(int par1)
{
if(this.fuelUsetime == 0)
{
this.fuelUsetime = proTicks;
}
return this.fuelTime * par1 / this.fuelUsetime;
}
public boolean isUsingFuel()
{
return this.fuelTime > 0;
}
public void updateEntity()
{
boolean flag = this.fuelTime > 0;
boolean flag1 = false;
if(this.fuelTime > 0)
{
--this.fuelTime;
}
if(!this.worldObj.isRemote)
{
if(this.fuelTime != 0 || this.ItemStacks[3] != null && this.ItemStacks[0] != null)
{
if(this.fuelTime == 0 && this.canProcess())
{
this.fuelUsetime = this.fuelTime = getItemBurnTime(this.ItemStacks[3]);
if(this.fuelTime > 0)
{
flag1 = true;
if(this.ItemStacks[3] != null)
{
--this.ItemStacks[3].stackSize;
if(this.ItemStacks[3].stackSize == 0)
{
this.ItemStacks[3] = ItemStacks[3].getItem().getContainerItem(ItemStacks[3]);
}
}
}
}
if(this.isUsingFuel() && this.canProcess())
{
++this.processTime;
if(this.processTime == proTicks)
{
this.processTime = 0;
this.processItem();
flag1 = true;
}
}
else
{
this.processTime = 0;
}
}
if(flag != this.fuelTime > 0)
{
flag1 = true;
BlockAutosmith.updateBlockState(this.fuelTime > 0, this.worldObj, this.xCoord, this.yCoord,
this.zCoord);
}
}
if(flag1)
{
this.markDirty();
}
}
private boolean canProcess()
{
ItemStack tool = this.ItemStacks[0];
ItemStack repair = this.ItemStacks[1];
if(tool != null && repair != null)
{
ItemStack output = AutosmithRecipes.getInstance().getResult(tool, repair);
if(output == null)
return false;
ItemStack outputSlot = this.ItemStacks[2];
if(outputSlot == null)
return true;
if(!outputSlot.isItemEqual(output))
return false;
int result = outputSlot.stackSize + output.stackSize;
return result <= output.getMaxStackSize();
}
return false;
}
public static void addFuel(ItemStack itemstack)
{
fuelItems.add(itemstack);
}
public static boolean removeFuel(ItemStack itemstack)
{
for(int i = 0; i < fuelItems.size(); i++)
{
if(fuelItems.get(i) == itemstack)
{
fuelItems.remove(i);
return true;
}
}
return false;
}
public static boolean isValidForRepair(ItemStack tool, ItemStack item)
{
if(AutosmithRecipes.getInstance().getResult(tool, item) != null)
return true;
return false;
}
public void processItem()
{
if(this.canProcess())
{
ItemStack tool = ItemStacks[0];
ItemStack item = ItemStacks[1];
ItemStack output = AutosmithRecipes.getInstance().getResult(tool, item);
ItemStack outputSlot = ItemStacks[2];
if(outputSlot == null)
{
ItemStacks[2] = output.copy();
}
else if(outputSlot.isItemEqual(output))
{
outputSlot.stackSize += output.stackSize;
}
--tool.stackSize;
if(tool.stackSize <= 0)
{
ItemStacks[0] = null;
}
}
}
public static int getItemBurnTime(ItemStack itemstack)
{
return isItemFuel(itemstack) ? proTicks : 0;
}
public static boolean isItemFuel(ItemStack itemstack)
{
for(int i = 0; i < fuelItems.size(); i++)
{
ItemStack temp = fuelItems.get(i);
if(temp.getItem() == itemstack.getItem() && temp.getItemDamage() == itemstack.getItemDamage())
return true;
}
return false;
}
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 void openInventory()
{
}
public void closeInventory()
{
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
{
return slot == 2 ? false : (slot == 1 ? isItemFuel(itemstack) : true);
}
@Override
public int[] getAccessibleSlotsFromSide(int slot)
{
return slot == 0 ? slotsBottom : (slot == 1 ? slotsTop : slotsSides);
}
@Override
public boolean canInsertItem(int slot, ItemStack itemstack, int side)
{
return this.isItemValidForSlot(slot, itemstack);
}
@Override
public boolean canExtractItem(int slot, ItemStack itemstack, int side)
{
return side != 0 || slot != 1;
}
@Override
public void markDirty()
{
}
}