Code cleanup

removed grinder code from git repo in favor of using hawks grinder.
This commit is contained in:
Rseifert 2012-07-22 21:21:39 -04:00
parent 3c1a173070
commit fbb7a56c6f
6 changed files with 0 additions and 679 deletions

View file

@ -1,55 +0,0 @@
package net.minecraft.src.eui;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.pipes.api.ILiquidProducer;
public class TileEntityCondenser extends TileEntityMachine implements ILiquidProducer {
int tickCount = 0;
int waterStored = 0;
int energyStored = 0;
@Override
public int onProduceLiquid(int type,int maxVol, int side) {
/**if(type == 1)
{
int tradeW = Math.min(maxVol, waterStored);
waterStored -= tradeW;
return tradeW;
}**/
return 1;
}
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("energyStored", (int)this.energyStored);
par1NBTTagCompound.setInteger("waterStored", (int)this.waterStored);
}
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
this.energyStored = par1NBTTagCompound.getInteger("energyStored");
this.waterStored = par1NBTTagCompound.getInteger("waterStored");
}
public void updateEntity()
{
if(energyStored > 100 && tickCount > 200 && waterStored < 10)
{
energyStored -= 100;
waterStored += 1;
tickCount = 0;
}
tickCount++;
}
@Override
public boolean canProduceLiquid(int type, byte side) {
if(type == 1)
{
return true;
}
return false;
}
}

View file

@ -1,87 +0,0 @@
package net.minecraft.src.eui.grinder;
import net.minecraft.src.*;
public class ContainerGrinder extends Container
{
private TileEntityGrinder grinder;
private int lastCookTime = 0;
private int lastBurnTime = 0;
private int lastItemBurnTime = 0;
public ContainerGrinder(InventoryPlayer par1InventoryPlayer, TileEntityGrinder par2TileEntityGrinder)
{
this.grinder = par2TileEntityGrinder;
this.addSlot(new Slot(par2TileEntityGrinder, 0, 56, 17));
//this.addSlot(new Slot(par2TileEntityGrinder, 1, 116, 35));
this.addSlot(new SlotGrinder(par1InventoryPlayer.player, par2TileEntityGrinder, 1, 116, 35));
int var3;
for (var3 = 0; var3 < 3; ++var3)
{
for (int var4 = 0; var4 < 9; ++var4)
{
this.addSlot(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
}
}
for (var3 = 0; var3 < 9; ++var3)
{
this.addSlot(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142));
}
}
/**
* Updates crafting matrix; called from onCraftMatrixChanged. Args: none
*/
public void updateCraftingResults()
{
super.updateCraftingResults();
for (int var1 = 0; var1 < this.crafters.size(); ++var1)
{
ICrafting var2 = (ICrafting)this.crafters.get(var1);
if (this.lastCookTime != this.grinder.furnaceCookTime)
{
var2.updateCraftingInventoryInfo(this, 0, this.grinder.furnaceCookTime);
}
if (this.lastBurnTime != this.grinder.GrinderRunTime)
{
var2.updateCraftingInventoryInfo(this, 1, this.grinder.GrinderRunTime);
}
}
this.lastCookTime = this.grinder.furnaceCookTime;
this.lastBurnTime = this.grinder.GrinderRunTime;
}
public void updateProgressBar(int par1, int par2)
{
if (par1 == 0)
{
this.grinder.furnaceCookTime = par2;
}
if (par1 == 1)
{
this.grinder.GrinderRunTime = par2;
}
}
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
{
return this.grinder.isUseableByPlayer(par1EntityPlayer);
}
/**
* Called to transfer a stack from one inventory to the other eg. when shift clicking.
*/
public ItemStack transferStackInSlot(int par1)
{
return null;
}
}

View file

@ -1,74 +0,0 @@
package net.minecraft.src.eui.grinder;
import net.minecraft.src.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class GrinderRecipes
{
private static final GrinderRecipes smeltingBase = new GrinderRecipes();
/** The list of smelting results. */
private Map smeltingList = new HashMap();
private Map metaSmeltingList = new HashMap();
/**
* Used to call methods addSmelting and getSmeltingResult.
*/
public static final GrinderRecipes smelting()
{
return smeltingBase;
}
private GrinderRecipes()
{
this.addSmelting(Item.coal.shiftedIndex, new ItemStack(mod_EUIndustry.coalNugget, 2,0));
this.addSmelting(mod_EUIndustry.coalNugget.shiftedIndex,0, new ItemStack(mod_EUIndustry.coalNugget,2,1));
this.addSmelting(mod_EUIndustry.coalNugget.shiftedIndex,1, new ItemStack(mod_EUIndustry.coalNugget,2,2));
}
/**
* Adds a smelting recipe.
*/
public void addSmelting(int par1, ItemStack par2ItemStack)
{
this.smeltingList.put(Integer.valueOf(par1), par2ItemStack);
}
public Map getSmeltingList()
{
return this.smeltingList;
}
/**
* Add a metadata-sensitive furnace recipe
* @param itemID The Item ID
* @param metadata The Item Metadata
* @param itemstack The ItemStack for the result
*/
public void addSmelting(int itemID, int metadata, ItemStack itemstack)
{
metaSmeltingList.put(Arrays.asList(itemID, metadata), itemstack);
}
/**
* Used to get the resulting ItemStack form a source ItemStack
* @param item The Source ItemStack
* @return The result ItemStack
*/
public ItemStack getSmeltingResult(ItemStack item)
{
if (item == null)
{
return null;
}
ItemStack ret = (ItemStack)metaSmeltingList.get(Arrays.asList(item.itemID, item.getItemDamage()));
if (ret != null)
{
return ret;
}
return (ItemStack)smeltingList.get(Integer.valueOf(item.itemID));
}
}

View file

@ -1,46 +0,0 @@
package net.minecraft.src.eui.grinder;
import net.minecraft.src.*;
import org.lwjgl.opengl.GL11;
public class GuiGrinder extends GuiContainer
{
private TileEntityGrinder grinderInventory;
public GuiGrinder(InventoryPlayer par1InventoryPlayer, TileEntityGrinder par2TileEntityGrinder)
{
super(new ContainerGrinder(par1InventoryPlayer, par2TileEntityGrinder));
this.grinderInventory = par2TileEntityGrinder;
}
/**
* Draw the foreground layer for the GuiContainer (everythin in front of the items)
*/
protected void drawGuiContainerForegroundLayer()
{
this.fontRenderer.drawString("Coal Processor", 60, 6, 4210752);
this.fontRenderer.drawString("Inventory", 8, this.ySize - 96 + 2, 4210752);
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int var4 = this.mc.renderEngine.getTexture("/eui/GrinderGUI.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4);
int var5 = (this.width - this.xSize) / 2;
int var6 = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
int var7;
if (this.grinderInventory.isBurning())
{
var7 = this.grinderInventory.getBurnTimeRemainingScaled(12);
this.drawTexturedModalRect(var5 + 56, var6 + 36 + 12 - var7, 176, 12 - var7, 14, var7 + 2);
}
var7 = this.grinderInventory.getCookProgressScaled(24);
this.drawTexturedModalRect(var5 + 79, var6 + 34, 176, 14, var7 + 1, 16);
}
}

View file

@ -1,60 +0,0 @@
package net.minecraft.src.eui.grinder;
import net.minecraft.src.*;
public class SlotGrinder extends Slot
{
/** The player that is using the GUI where this slot resides. */
private EntityPlayer thePlayer;
private int field_48437_f;
public SlotGrinder(EntityPlayer par1EntityPlayer, IInventory par2IInventory, int par3, int par4, int par5)
{
super(par2IInventory, par3, par4, par5);
this.thePlayer = par1EntityPlayer;
}
/**
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
*/
public boolean isItemValid(ItemStack par1ItemStack)
{
return false;
}
/**
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
* stack.
*/
public ItemStack decrStackSize(int par1)
{
if (this.getHasStack())
{
this.field_48437_f += Math.min(par1, this.getStack().stackSize);
}
return super.decrStackSize(par1);
}
/**
* Called when the player picks up an item from an inventory slot
*/
public void onPickupFromSlot(ItemStack par1ItemStack)
{
this.func_48434_c(par1ItemStack);
super.onPickupFromSlot(par1ItemStack);
}
protected void func_48435_a(ItemStack par1ItemStack, int par2)
{
this.field_48437_f += par2;
this.func_48434_c(par1ItemStack);
}
protected void func_48434_c(ItemStack par1ItemStack)
{
par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.field_48437_f);
this.field_48437_f = 0;
ModLoader.takenFromFurnace(this.thePlayer, par1ItemStack);
}
}

View file

@ -1,357 +0,0 @@
package net.minecraft.src.eui.grinder;
import net.minecraft.src.*;
import net.minecraft.src.universalelectricity.electricity.IElectricUnit;
import net.minecraft.src.eui.TileEntityMachine;
import net.minecraft.src.forge.ForgeHooks;
import net.minecraft.src.forge.ISidedInventory;
public class TileEntityGrinder extends TileEntityMachine implements IElectricUnit, IInventory
{
/**
* The ItemStacks that hold the items currently being used in the furnace
*/
private ItemStack[] furnaceItemStacks = new ItemStack[3];
/** The number of ticks that the furnace will keep burning */
public int GrinderRunTime = 0;
/** The ammount of energy stored before turning into runtimer */
public int energyStore = 0;
/**
* The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for
*/
public int currentItemBurnTime = 0;
/** The number of ticks that the current item has been cooking for */
public int furnaceCookTime = 0;
/**
* Returns the number of slots in the inventory.
*/
public int getSizeInventory()
{
return this.furnaceItemStacks.length;
}
/**
* Returns the stack in slot i
*/
public ItemStack getStackInSlot(int par1)
{
return this.furnaceItemStacks[par1];
}
/**
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
* stack.
*/
public ItemStack decrStackSize(int par1, int par2)
{
if (this.furnaceItemStacks[par1] != null)
{
ItemStack var3;
if (this.furnaceItemStacks[par1].stackSize <= par2)
{
var3 = this.furnaceItemStacks[par1];
this.furnaceItemStacks[par1] = null;
return var3;
}
else
{
var3 = this.furnaceItemStacks[par1].splitStack(par2);
if (this.furnaceItemStacks[par1].stackSize == 0)
{
this.furnaceItemStacks[par1] = null;
}
return var3;
}
}
else
{
return null;
}
}
/**
* When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
* like when you close a workbench GUI.
*/
public ItemStack getStackInSlotOnClosing(int par1)
{
if (this.furnaceItemStacks[par1] != null)
{
ItemStack var2 = this.furnaceItemStacks[par1];
this.furnaceItemStacks[par1] = null;
return var2;
}
else
{
return null;
}
}
/**
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
*/
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{
this.furnaceItemStacks[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
}
/**
* Returns the name of the inventory.
*/
public String getInvName()
{
return "container.furnace";
}
/**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
this.furnaceItemStacks = new ItemStack[this.getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
{
NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 >= 0 && var5 < this.furnaceItemStacks.length)
{
this.furnaceItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
this.GrinderRunTime = par1NBTTagCompound.getShort("BurnTime");
this.furnaceCookTime = par1NBTTagCompound.getShort("CookTime");
this.energyStore = par1NBTTagCompound.getInteger("energyStore");
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setShort("BurnTime", (short)this.GrinderRunTime);
par1NBTTagCompound.setShort("CookTime", (short)this.furnaceCookTime);
par1NBTTagCompound.setInteger("energyStore", (int)this.energyStore);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.furnaceItemStacks.length; ++var3)
{
if (this.furnaceItemStacks[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
this.furnaceItemStacks[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
par1NBTTagCompound.setTag("Items", var2);
}
/**
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't
* this more of a set than a get?*
*/
public int getInventoryStackLimit()
{
return 64;
}
/**
* Returns an integer between 0 and the passed value representing how close the current item is to being completely
* cooked
*/
public int getCookProgressScaled(int par1)
{
return this.furnaceCookTime * par1 / 600;
}
/**
* Returns an integer between 0 and the passed value representing how much burn time is left on the current fuel
* item, where 0 means that the item is exhausted and the passed value means that the item is fresh
*/
public int getBurnTimeRemainingScaled(int par1)
{
return this.GrinderRunTime * par1 / 120;
}
/**
* Returns true if the furnace is currently burning
*/
public boolean isBurning()
{
return this.GrinderRunTime > 0;
}
/**
* Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
* ticks and creates a new spawn inside its implementation.
*/
public void updateEntity()
{
boolean var1 = this.GrinderRunTime > 0;
boolean var2 = false;
if (!this.worldObj.isRemote)
{
if(this.GrinderRunTime < 120)
{
int varE = (int) (this.energyStore / 50);
if(GrinderRunTime + varE >= 120)
{
this.GrinderRunTime = this.GrinderRunTime + varE;
this.energyStore = this.energyStore - (varE * 150);
}
}
if (this.GrinderRunTime > 0)
{
--this.GrinderRunTime;
}
if (this.isBurning() && this.canSmelt())
{
++this.furnaceCookTime;
if (this.furnaceCookTime == 600)
{
this.furnaceCookTime = 0;
this.smeltItem();
var2 = true;
}
}
else
{
this.furnaceCookTime = 0;
}
}
if (var2)
{
this.onInventoryChanged();
}
}
/**
* Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
*/
private boolean canSmelt()
{
if (this.furnaceItemStacks[0] == null)
{
return false;
}
else
{
ItemStack var1 = GrinderRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);
if(var1 == null)
{
return false;
}
if(this.furnaceItemStacks[1] == null)
{
return true;
}
if (!this.furnaceItemStacks[1].isItemEqual(var1))
{
return false;
}
int result = furnaceItemStacks[1].stackSize + var1.stackSize;
return (result <= getInventoryStackLimit() && result <= var1.getMaxStackSize());
}
}
/**
* Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
*/
public void smeltItem()
{
if (this.canSmelt())
{
ItemStack var1 = GrinderRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);
if (this.furnaceItemStacks[1] == null)
{
this.furnaceItemStacks[1] = var1.copy();
}
if (this.furnaceItemStacks[1].isItemEqual(var1))
{
this.furnaceItemStacks[1].stackSize += var1.stackSize;
}
if (this.furnaceItemStacks[0].getItem().func_46056_k())
{
this.furnaceItemStacks[0] = new ItemStack(this.furnaceItemStacks[0].getItem().setFull3D());
}
else
{
--this.furnaceItemStacks[0].stackSize;
}
if (this.furnaceItemStacks[0].stackSize <= 0)
{
this.furnaceItemStacks[0] = null;
}
}
}
/**
* Do not make give this method the name canInteractWith because it clashes with Container
*/
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
{
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
}
public void openChest() {}
public void closeChest() {}
@Override
public boolean canReceiveFromSide(byte side) {
// TODO Auto-generated method stub
return true;
}
@Override
public float getVoltage() {
// TODO Auto-generated method stub
return 120;
}
@Override
public void onDisable(int duration) {
// TODO Auto-generated method stub
}
@Override
public boolean isDisabled() {
// TODO Auto-generated method stub
return false;
}
public float electricityRequest()
{
return Math.max(this.energyStore - 100,0);
}
}