tsughub: btw-gloryholes

ref: 2c305a89aceb99de504672b0b1dce29d47d09aa2

View raw version
package btw.community.tsughoggr.gloryholes;

import net.minecraft.src.*;

public class TSGBlowingStand extends TileEntity implements IInventory{
	private ItemStack[] contents = new ItemStack[8];
	private ItemStack recipe; /* Blowpipe with a loaded recipe*/
	private int progress;


	/*TileEntity*/
	public void
	readFromNBT(NBTTagCompound nbt){
		super.readFromNBT(nbt);
		contents = new ItemStack[8];
		for(int i=0;i<contents.length;++i){
			if(nbt.hasKey("inventory_" + i))
				contents[i] = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("inventory_" + i));
		}
		if(nbt.hasKey("recipe"))
			recipe = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("recipe"));
		if(nbt.hasKey("progress"))
			progress = nbt.getInteger("progress");
		else
			progress = 0;
	}
	public void
	writeToNBT(NBTTagCompound nbt){
		super.writeToNBT(nbt);
		for(int i=0;i<contents.length;++i){
			if(contents[i] != null)
				nbt.setCompoundTag("inventory_" + i, contents[i].writeToNBT(new NBTTagCompound()));
		}
		if(recipe != null)
			nbt.setCompoundTag("recipe", recipe.writeToNBT(new NBTTagCompound()));
		nbt.setInteger("progress", progress);
	}

	/*IInventory*/
	public int 
	getSizeInventory(){
		return 4;
	}
	public ItemStack
	getStackInSlot(int i){
		return contents[i];
	}
	public ItemStack
	decrStackSize(int i, int amt){
		return null;
	}
	public ItemStack
	getStackInSlotOnClosing(int i){
		return null;
	}
	public void
	setInventorySlotContents(int i, ItemStack stack){
		if(contents[i] == null && stack != null)
			contents[i] = stack.splitStack(1);

	}
	public String getInvName(){
		return "Blowing Stand";
	}
	public boolean
	isInvNameLocalized(){
		return false;
	}
	public int
	getInventoryStackLimit(){
		return 1;
	}
	public void
	InventoryChanged(){

	}
	public boolean
	isUseableByPlayer(EntityPlayer player){
		return Math.sqrt(((xCoord - player.posX) * (xCoord - player.posX)) + ((yCoord - player.posY) * (yCoord - player.posY)) + ((zCoord - player.posZ) * (zCoord - player.posZ))) < 5;
	}

	public void
	openChest(){};
	public void
	closeChest(){};

	public	boolean
	isStackValidForSlot(int i, ItemStack is){
		if(contents[i] == null)
			return true;
		return false;
	}
	public boolean
	isItemValidForSlot(int i, ItemStack is){
		return isStackValidForSlot(i, is);
	}


	/*Class Specific*/

	//Design: - on neighbor change, if bellows and behind, update recipe.
	public void
	updateProgress(int amt){
		
	}
}