package com.harry9137.ct.tileentity; import com.harry9137.ct.client.container.ContainerTechTable; import com.harry9137.ct.energy.IEnergyContainer; import com.harry9137.ct.handler.recipies.Recipe; import com.harry9137.ct.handler.recipies.Recipes; 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; import net.minecraft.util.IChatComponent; public class TileEntityTechTable extends TileEntity implements IInventory, IEnergyContainer, ITickUpdater { public int front; public ItemStack[] items = new ItemStack[11]; public ContainerTechTable container; public TileEntityTechTable(){ } public void setFrontDirection(int f) { this.front = f; } public int getFrontDirection() { return this.front; } public void updateInventory(){ System.out.println("1"); for(Recipe recipe : Recipes.techTableRecipes3x3){ System.out.println("2"); int temp = 0; int[] output = new int[9]; output[0] = 0; output[1] = 0; output[2] = 0; output[3] = 0; output[4] = 0; output[5] = 0; output[6] = 0; output[7] = 0; output[8] = 0; for(ItemStack item : recipe.Input){ System.out.println("3"); if(this.getStackInSlot(temp) != null) { if (item.getItem() == this.getStackInSlot(temp).getItem()) { System.out.println("4"); output[temp] = 1; } else { output[temp] = 0; } } else{ if(this.getStackInSlot(temp) == null && item.getItem() == null){ output[temp] = 1; } else { output[temp] = 0; } } temp++; } if(checkOutput(output) && worldObj.isRemote){ System.out.println("5"); this.setInventorySlotContents2(0, null); this.setInventorySlotContents2(1, null); this.setInventorySlotContents2(2, null); this.setInventorySlotContents2(3, null); this.setInventorySlotContents2(4, null); this.setInventorySlotContents2(5, null); this.setInventorySlotContents2(6, null); this.setInventorySlotContents2(7, null); this.setInventorySlotContents2(8, null); this.setInventorySlotContents2(10, recipe.Output); } } } private boolean checkOutput(int[] list){ if(list[0] == 1 && list[1] == 1 && list[2] == 1 && list[3] == 1 && list[4] == 1 && list[5] == 1 && list[6] == 1 && list[7] == 1 && list[8] == 1){ return true; } else{ return false; } } @Override public int getSizeInventory() { return 10; } @Override public ItemStack getStackInSlot(int p_70301_1_) { if(items.length > 0) { return items[p_70301_1_]; } else{ return null; } } @Override public ItemStack decrStackSize(int i, int j) { System.out.println(Integer.toString(i)); if (items[i] != null) { if (items[i].stackSize <= j) { ItemStack itemstack = items[i]; items[i] = null; markDirty(); return itemstack; } ItemStack itemstack1 = items[i].splitStack(j); if (items[i].stackSize == 0) { items[i] = null; } markDirty(); return itemstack1; } else { return null; } } @Override public ItemStack getStackInSlotOnClosing(int p_70304_1_) { return null; } @Override public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { this.items[p_70299_1_] = p_70299_2_; if (p_70299_2_ != null && p_70299_2_.stackSize > this.getInventoryStackLimit()) { p_70299_2_.stackSize = this.getInventoryStackLimit(); } this.markDirty(); this.updateInventory(); } public void setInventorySlotContents2(int p_70299_1_, ItemStack p_70299_2_) { this.items[p_70299_1_] = p_70299_2_; if (p_70299_2_ != null && p_70299_2_.stackSize > this.getInventoryStackLimit()) { p_70299_2_.stackSize = this.getInventoryStackLimit(); } this.markDirty(); } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { return true; } @Override public void openInventory(EntityPlayer playerIn) { } @Override public void closeInventory(EntityPlayer playerIn) { } @Override public boolean isItemValidForSlot(int slot, ItemStack itemStack) { System.out.println(Integer.toString(slot)); return true; } @Override public int getField(int id) { return 0; } @Override public void setField(int id, int value) { } @Override public int getFieldCount() { return 0; } @Override public void clear() { } @Override public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); NBTTagList itemList = new NBTTagList(); for (int i = 0; i < items.length; i++) { ItemStack stack = items[i]; if (stack != null) { NBTTagCompound tag = new NBTTagCompound(); tag.setByte("Slot", (byte) i); stack.writeToNBT(tag); itemList.appendTag(tag); } } tagCompound.setTag("Inventory", itemList); } @Override public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); NBTTagList tagList = tagCompound.getTagList("Inventory", 9); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i); byte slot = tag.getByte("Slot"); if (slot >= 0 && slot < items.length) { items[slot] = ItemStack.loadItemStackFromNBT(tag); } } } @Override public int getEnergyLevel() { return 0; } @Override public boolean getCanSendPower() { return false; } @Override public boolean getCanReceivePower() { return false; } @Override public int getEnergyMax() { return 100; } @Override public void onEnergyUpdate() { } @Override public void setPowerLevel(int powerLevel) { } @Override public void updateEntity() { } @Override public String getName() { return null; } @Override public boolean hasCustomName() { return false; } @Override public IChatComponent getDisplayName() { return null; } }