Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TileEntityForge extends TileEntity implements ISidedInventory
- {
- private String localizedName;
- private static final int[] slots_top = new int[] {0, 1, 2, 3};
- private static final int[] slots_bottom = new int[] {4, 5};
- private static final int[] slots_sides = new int[] {4};
- private ItemStack[] slots = new ItemStack[6];
- public int furnaceSpeed = 500;
- public int burnTime;
- public int currentItemBurnTime;
- public int cookTime;
- public int getSizeInventory()
- {
- return this.slots.length;
- }
- public boolean isInvNameLocalized()
- {
- return this.localizedName != null && this.localizedName.length() > 0;
- }
- public String getInvName()
- {
- return this.isInvNameLocalized() ? this.localizedName : "container.Forge";
- }
- public void setGuiDisplayName(String displayName)
- {
- this.localizedName = displayName;
- }
- public ItemStack getStackInSlot(int i)
- {
- return null;
- }
- public ItemStack decrStackSize(int i, int j)
- {
- return null;
- }
- public ItemStack getStackInSlotOnClosing(int i)
- {
- return null;
- }
- public void setInventorySlotContents(int i, ItemStack itemstack)
- {
- }
- public int getInventoryStackLimit()
- {
- return 0;
- }
- public boolean isUseableByPlayer(EntityPlayer entityplayer)
- {
- return false;
- }
- public void openChest()
- {
- }
- public void closeChest()
- {
- }
- public boolean isBurning()
- {
- return this.burnTime > 0;
- }
- public void updateEntity()
- {
- boolean flag = this.burnTime > 0;
- boolean flag1 = false;
- if(this.burnTime > 0)
- {
- this.burnTime--;
- }
- if(!this.worldObj.isRemote)
- {
- if(this.burnTime == 0 && this.canSmelt())
- {
- this.currentItemBurnTime = this.burnTime = getItemBurnTime(this.slots[4]);
- if(this.burnTime > 0)
- {
- flag1 = true;
- if(this.slots[4] != null)
- {
- this.slots[4].stackSize--;
- if(this.slots[4].stackSize == 0)
- {
- this.slots[4] = this.slots[4].getItem().getContainerItemStack(this.slots[4]);
- }
- }
- }
- }
- if(this.isBurning() && this.canSmelt())
- {
- this.cookTime++;
- if(this.cookTime == this.furnaceSpeed)
- {
- this.cookTime = 0;
- this.smeltItem();
- flag1 = true;
- }
- }
- else
- {
- this.cookTime = 0;
- }
- if(flag != this.burnTime > 0)
- {
- flag1 = true;
- BlockForge.updateForgeBlockState(this.burnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
- }
- }
- if(flag1)
- {
- this.onInventoryChanged();
- }
- }
- private boolean canSmelt()
- {
- if(this.slots[0] == null)
- {
- return false;
- }
- else
- {
- }
- if(this.slots[1] == null)
- {
- return false;
- }
- else
- {
- }
- if(this.slots[2] == null)
- {
- return false;
- }
- else
- {
- }
- if(this.slots[3] == null)
- {
- return false;
- }
- else
- {
- }
- }
- public static int getItemBurnTime(ItemStack itemstack)
- {
- if(itemstack == null)
- {
- return 0;
- }
- else
- {
- int i = itemstack.getItem().itemID;
- if(i == Item.coal.itemID) return 1600;
- return GameRegistry.getFuelValue(itemstack);
- }
- }
- public static boolean isItemFuel(ItemStack itemstack)
- {
- return getItemBurnTime(itemstack) == 1600;
- }
- public boolean isItemValidForSlot(int i, ItemStack itemstack)
- {
- return i == 5 ? false : (i == 4 ? isItemFuel(itemstack) : true);
- }
- public int[] getAccessibleSlotsFromSide(int var1)
- {
- return var1 == 0 ? slots_bottom : (var1 == 4 ? slots_top : slots_sides);
- }
- public boolean canInsertItem(int i, ItemStack itemstack, int j)
- {
- return this.isItemValidForSlot(i, itemstack);
- }
- public boolean canExtractItem(int i, ItemStack itemstack, int j)
- {
- return j != 0 || i != 1 || itemstack.itemID == Item.bucketEmpty.itemID;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment