Signed-off-by: Rseifert <rseifert.phone@gmail.com>

This commit is contained in:
Rseifert 2012-06-18 13:42:50 -04:00
parent 1c41902c6e
commit aa8432a07a
37 changed files with 4282 additions and 0 deletions

View file

@ -0,0 +1,388 @@
package net.minecraft.src.eui;
import java.util.ArrayList;
import java.util.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.src.*;
import net.minecraft.src.eui.api.ISteamConsumer;
import net.minecraft.src.eui.api.ISteamProducer;
import net.minecraft.src.eui.boiler.*;
import net.minecraft.src.eui.burner.GUIFireBox;
import net.minecraft.src.eui.burner.TileEntityFireBox;
import net.minecraft.src.eui.grinder.*;
import net.minecraft.src.eui.turbine.GUIGenerator;
import net.minecraft.src.eui.turbine.TileEntityGenerator;
import net.minecraft.src.forge.*;
import net.minecraft.src.universalelectricity.UEBlockMachine;
import net.minecraft.src.universalelectricity.UEElectricItem;
import net.minecraft.src.universalelectricity.UERenderBlocks;
import net.minecraft.src.universalelectricity.UniversalElectricity;
import net.minecraft.src.universalelectricity.components.TileEntityCoalGenerator;
import net.minecraft.src.universalelectricity.components.UniversalComponents;
public class BlockMachine extends UEBlockMachine implements ITextureProvider
{
private Random furnaceRand = new Random();
private static boolean keepFurnaceInventory = true;
public BlockMachine(int par1)
{
super("machine", par1, Material.iron);
this.setRequiresSelfNotify();
}
@Override
protected int damageDropped(int metadata)
{
return metadata;
}
@Override
public void randomDisplayTick(World par1World, int x, int y, int z, Random par5Random)
{
TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z);
if(tileEntity instanceof TileEntityFireBox)
{
if(((TileEntityFireBox)tileEntity).generateRate > 0)
{
int var6 = (int)((TileEntityFireBox)tileEntity).getDirection();
float var7 = (float)x + 0.5F;
float var8 = (float)y + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;
float var9 = (float)z + 0.5F;
float var10 = 0.52F;
float var11 = par5Random.nextFloat() * 0.6F - 0.3F;
if (var6 == 5)
{
par1World.spawnParticle("smoke", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
}
else if (var6 == 4)
{
par1World.spawnParticle("smoke", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
}
else if (var6 == 3)
{
par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
}
else if (var6 == 2)
{
par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
}
}
}
}
@Override
public int getBlockTexture(IBlockAccess par1iBlockAccess, int x, int y, int z, int side)
{
TileEntity tileEntity = par1iBlockAccess.getBlockTileEntity(x, y, z);
int metadata = par1iBlockAccess.getBlockMetadata(x, y, z);
if (side == 1)
{
switch(metadata)
{
case 0: return 1;
case 1: return 3;
case 2: return 18;
case 3: return 5;
}
}
//If it is the front side
if(side == ((TileEntityMachine)tileEntity).getDirection())
{
switch(metadata)
{
case 1: return 3;
case 3: return 3;
}
}
//If it is the back side
else if(side == UniversalElectricity.getOrientationFromSide(((TileEntityMachine)tileEntity).getDirection(), (byte)2))
{
switch(metadata)
{
case 0: return 19;
case 1: return 6;
case 2: return 17;
case 3: return 3;
}
}
switch(metadata)
{
case 1: return 4;
case 2: return 16;
case 3: return 2;
}
return 0;
}
@Override
public int getBlockTextureFromSideAndMetadata(int side, int metadata)
{
if (side == 1)
{
switch(metadata)
{
case 0: return 1;
case 1: return 3;
case 2: return 18;
case 3: return 5;
}
}
else
{
//If it is the front side
if(side == 3)
{
switch(metadata)
{
case 0: return 19;
case 1: return 6;
case 2: return 17;
case 3: return 3;
}
}
//If it is the back side
else if(side == 2)
{
switch(metadata)
{
case 0: return this.blockIndexInTexture + 2;
case 1: return this.blockIndexInTexture + 3;
case 2: return this.blockIndexInTexture + 2;
}
}
switch(metadata)
{
case 1: return 4;
case 2: return 16;
case 3: return 2;
}
}
return 0;
}
public boolean blockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
{
int metadata = par1World.getBlockMetadata(par2, par3, par4);
/**
* Check if the player is holding a wrench or an electric item. If so, do not open the GUI.
*/
if(par5EntityPlayer.inventory.getCurrentItem() != null)
{
if(par5EntityPlayer.inventory.getCurrentItem().itemID == UniversalComponents.ItemWrench.shiftedIndex)
{
if(onUseWrench(par1World, par2, par3, par4, par5EntityPlayer))
{
par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
return true;
}
}
else if(par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof UEElectricItem)
{
if(onUseElectricItem(par1World, par2, par3, par4, par5EntityPlayer))
{
return true;
}
}
}
return machineActivated(par1World, par2, par3, par4, par5EntityPlayer);
}
public boolean onUseElectricItem(World par1World, int par2, int par3,
int par4, EntityPlayer par5EntityPlayer) {
// TODO Auto-generated method stub
return false;
}
public boolean onUseWrench(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
{
TileEntityMachine tileEntity = (TileEntityMachine)par1World.getBlockTileEntity(par2, par3, par4);
//Reorient the block
switch(tileEntity.getDirection())
{
case 2: tileEntity.setDirection((byte)5); break;
case 5: tileEntity.setDirection((byte)3); break;
case 3: tileEntity.setDirection((byte)4); break;
case 4: tileEntity.setDirection((byte)2); break;
}
return true;
}
/**
* Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the
* block.
*/
public boolean machineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer)
{
if (par1World.isRemote)
{
return true;
}
else
{
TileEntity blockEntity = (TileEntity)par1World.getBlockTileEntity(x, y, z);
if (blockEntity != null)
{
if(blockEntity instanceof TileEntityGrinder)
{
TileEntity var6 = (TileEntityGrinder)par1World.getBlockTileEntity(x, y, z);
ModLoader.openGUI(par5EntityPlayer, new GuiGrinder(par5EntityPlayer.inventory, (TileEntityGrinder) var6 )); ;
}
if(blockEntity instanceof TileEntityBoiler)
{
TileEntity var6 = (TileEntityBoiler)par1World.getBlockTileEntity(x, y, z);
ModLoader.openGUI(par5EntityPlayer, new GuiBoiler(par5EntityPlayer.inventory, (TileEntityBoiler) var6 )); ;
}
if(blockEntity instanceof TileEntityFireBox)
{
TileEntity var6 = (TileEntityFireBox)par1World.getBlockTileEntity(x, y, z);
ModLoader.openGUI(par5EntityPlayer, new GUIFireBox(par5EntityPlayer.inventory, (TileEntityFireBox) var6 )); ;
}
if(blockEntity instanceof TileEntityGenerator)
{
TileEntity var6 = (TileEntityGenerator)par1World.getBlockTileEntity(x, y, z);
ModLoader.openGUI(par5EntityPlayer, new GUIGenerator(par5EntityPlayer.inventory, (TileEntityGenerator) var6 )); ;
}
}
return true;
}
}
@Override
public TileEntity getBlockEntity(int meta)
{
switch(meta)
{
case 0: return new TileEntityGrinder();
case 1: return new TileEntityBoiler();
case 2: return new TileEntityFireBox();
case 3: return new TileEntityGenerator();
case 14: return new TileEntityCondenser();
case 15: return new TileEntityNuller();
}
return null;
}
/**
* Called when the block is placed in the world.
*/
@Override
public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLiving par5EntityLiving)
{
int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int metadata = par1World.getBlockMetadata(x, y, z);
TileEntityMachine tileEntity = (TileEntityMachine)par1World.getBlockTileEntity(x, y, z);
if(metadata == 0)
{
switch (angle)
{
case 0: tileEntity.setDirection((byte)5); break;
case 1: tileEntity.setDirection((byte)3); break;
case 2: tileEntity.setDirection((byte)4); break;
case 3: tileEntity.setDirection((byte)2); break;
}
}
else
{
switch (angle)
{
case 0: tileEntity.setDirection((byte)3); break;
case 1: tileEntity.setDirection((byte)4); break;
case 2: tileEntity.setDirection((byte)2); break;
case 3: tileEntity.setDirection((byte)5); break;
}
}
}
/**
* Called whenever the block is removed.
*/
public void onBlockRemoval(World par1World, int par2, int par3, int par4)
{
if (!keepFurnaceInventory)
{
TileEntityGrinder var5 = (TileEntityGrinder)par1World.getBlockTileEntity(par2, par3, par4);
if (var5 != null)
{
for (int var6 = 0; var6 < var5.getSizeInventory(); ++var6)
{
ItemStack var7 = var5.getStackInSlot(var6);
if (var7 != null)
{
float var8 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
float var9 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
float var10 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
while (var7.stackSize > 0)
{
int var11 = this.furnaceRand.nextInt(21) + 10;
if (var11 > var7.stackSize)
{
var11 = var7.stackSize;
}
var7.stackSize -= var11;
EntityItem var12 = new EntityItem(par1World, (double)((float)par2 + var8), (double)((float)par3 + var9), (double)((float)par4 + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage()));
if (var7.hasTagCompound())
{
var12.item.setTagCompound((NBTTagCompound)var7.getTagCompound().copy());
}
float var13 = 0.05F;
var12.motionX = (double)((float)this.furnaceRand.nextGaussian() * var13);
var12.motionY = (double)((float)this.furnaceRand.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double)((float)this.furnaceRand.nextGaussian() * var13);
par1World.spawnEntityInWorld(var12);
}
}
}
}
}
super.onBlockRemoval(par1World, par2, par3, par4);
}
@Override
public TileEntity getBlockEntity() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getTextureFile() {
// TODO Auto-generated method stub
return "/eui/blocks.png";
}
@Override
public boolean isOpaqueCube()
{
return false;
}
public int getRenderType()
{
return UniversalComponents.MachineRenderType;
}
public void addCreativeItems(ArrayList itemList) {
itemList.add(new ItemStack(this, 1,0));
itemList.add(new ItemStack(this, 1,1));
itemList.add(new ItemStack(this, 1,2));
itemList.add(new ItemStack(this, 1,3));
itemList.add(new ItemStack(this, 1,14));
itemList.add(new ItemStack(this, 1,15));
}
}

View file

@ -0,0 +1,60 @@
package net.minecraft.src.eui;
import java.util.ArrayList;
import net.minecraft.src.*;
import net.minecraft.src.forge.*;
public class ItemCoalFuel extends Item implements ITextureProvider
{
public ItemCoalFuel(int par1)
{
super(par1);
this.setItemName("CoalDust");
this.setHasSubtypes(true);
this.setMaxDamage(0);
this.setMaxStackSize(64);
}
@Override
public int getIconFromDamage(int par1)
{
switch(par1)
{
case 0: return 0;
case 1: return 1;
case 2: return 2;
}
return this.iconIndex;
}
@Override
public String getTextureFile() {
// TODO Auto-generated method stub
return "/eui/Items.png";
}
public String getItemName()
{
return "CoalDust";
}
public String getItemNameIS(ItemStack par1ItemStack)
{
int var3 = par1ItemStack.getItemDamage();
switch(var3)
{
case 0: return "CoalNuggets";
case 1: return "CoalPellets";
case 2: return "CoalDust";
}
return this.getItemName();
}
public void addCreativeItems(ArrayList itemList) {
itemList.add(new ItemStack(this, 1,0));
itemList.add(new ItemStack(this, 1,1));
itemList.add(new ItemStack(this, 1,2));
}
}

View file

@ -0,0 +1,50 @@
package net.minecraft.src.eui;
import java.util.ArrayList;
import net.minecraft.src.*;
public class ItemMachine extends ItemBlock {
public ItemMachine(int id) {
super(id);
setMaxDamage(0);
setHasSubtypes(true);
}
public int getMetadata(int metadata)
{
return metadata;
}
public String getItemName()
{
return "Machine";
}
public int getPlacedBlockMetadata(int damage) {
return damage;
}
public String getItemNameIS(ItemStack par1ItemStack)
{
int var3 = par1ItemStack.getItemDamage();
switch(var3)
{
case 0: return "CoalProcessor";
case 1: return "Boiler";
case 2: return "FireBox";
case 3: return "SteamGen";
case 15: return "EnergyNuller";
}
return this.getItemName();
}
public void addCreativeItems(ArrayList itemList) {
itemList.add(new ItemStack(this, 1,0));
itemList.add(new ItemStack(this, 1,1));
itemList.add(new ItemStack(this, 1,2));
itemList.add(new ItemStack(this, 1,3));
itemList.add(new ItemStack(this, 1,15));
}
}

View file

@ -0,0 +1,71 @@
package net.minecraft.src.eui;
import java.util.ArrayList;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.forge.ITextureProvider;
public class ItemParts extends Item implements ITextureProvider{
public ItemParts(int par1)
{
super(par1);
this.setItemName("Parts");
this.setHasSubtypes(true);
this.setMaxDamage(0);
this.setMaxStackSize(64);
}
@Override
public int getIconFromDamage(int par1)
{
switch(par1)
{
case 0: return 3;
case 1: return 4;
case 2: return 5;
case 3: return 6;
case 4: return 7;
case 5: return 8;
case 6: return 9;
}
return this.iconIndex;
}
@Override
public String getTextureFile() {
// TODO Auto-generated method stub
return "/eui/Items.png";
}
public String getItemName()
{
return "parts";
}
public String getItemNameIS(ItemStack par1ItemStack)
{
int var3 = par1ItemStack.getItemDamage();
switch(var3)
{
case 1: return "Tank";
case 3: return "Valve";
case 4: return "Tube";
case 5: return "Seal";
case 6: return "Rivits";
}
return this.getItemName();
}
public void addCreativeItems(ArrayList itemList)
{
itemList.add(new ItemStack(this, 1,1));
itemList.add(new ItemStack(this, 1,3));
itemList.add(new ItemStack(this, 1,4));
itemList.add(new ItemStack(this, 1,5));
itemList.add(new ItemStack(this, 1,6));
}
}

View file

@ -0,0 +1,79 @@
package net.minecraft.src.eui;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.eui.api.IWaterProducer;
import net.minecraft.src.universalelectricity.UEIConsumer;
public class TileEntityCondenser extends TileEntityMachine implements IWaterProducer,UEIConsumer {
int tickCount = 0;
int waterStored = 0;
int energyStored = 0;
@Override
public int onProduceWater(int maxVol, int side) {
if( maxVol > 0)
{
int tradeW = Math.min(maxVol, waterStored);
waterStored -= tradeW;
return tradeW;
}
return 0;
}
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 canProduceWater(byte side) {
// TODO Auto-generated method stub
return true;
}
@Override
public int onReceiveElectricity(int watts, int voltage, byte side) {
int rejectedElectricity = Math.max((this.waterStored + watts) - this.getElectricityCapacity(), 0);
this.energyStored += watts - rejectedElectricity;
return rejectedElectricity;
}
@Override
public boolean canRecieveElectricity(byte side) {
// TODO Auto-generated method stub
return true;
}
@Override
public int getStoredElectricity() {
// TODO Auto-generated method stub
return this.energyStored;
}
@Override
public int getElectricityCapacity() {
// TODO Auto-generated method stub
return 1000;
}
@Override
public int getVolts() {
// TODO Auto-generated method stub
return 240;
}
}

View file

@ -0,0 +1,56 @@
package net.minecraft.src.eui;
import net.minecraft.src.*;
import net.minecraft.src.forge.ITextureProvider;
import net.minecraft.src.universalelectricity.UEIRotatable;
import net.minecraft.src.universalelectricity.components.UniversalComponents;
public class TileEntityMachine extends TileEntity implements ITextureProvider,UEIRotatable {
private int facing;
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("facing", (int)this.facing);
}
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
this.facing = par1NBTTagCompound.getInteger("facing");
}
public TileEntity getSteamMachine(int i)
{
int x = this.xCoord;
int y = this.yCoord;
int z = this.zCoord;
switch(i){
case 0: y = y - 1;break;
case 1: y = y + 1;break;
case 2: z = z + 1;break;
case 3: z = z - 1;break;
case 4: x = x + 1;break;
case 5: x = x - 1;break;
}
TileEntity aEntity = worldObj.getBlockTileEntity(x, y, z);
if(aEntity instanceof TileEntityMachine)
{
return aEntity;
}
return null;
}
public byte getDirection() {
// TODO Auto-generated method stub
return (byte) this.facing;
}
public void setDirection(byte facingDirection) {
this.facing = facingDirection;
}
@Override
public String getTextureFile()
{
return "/eui/blocks.png";
}
}

View file

@ -0,0 +1,37 @@
package net.minecraft.src.eui;
import net.minecraft.src.universalelectricity.UEIConsumer;
public class TileEntityNuller extends TileEntityMachine implements UEIConsumer {
@Override
public int onReceiveElectricity(int watts, int voltage, byte side) {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean canRecieveElectricity(byte side) {
// TODO Auto-generated method stub
return true;
}
@Override
public int getStoredElectricity() {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getElectricityCapacity() {
// TODO Auto-generated method stub
return 100000;
}
@Override
public int getVolts() {
// TODO Auto-generated method stub
return 100000000;
}
}

View file

@ -0,0 +1,22 @@
package net.minecraft.src.eui.api;
/**
* The IHeatConsumer interface is an interface that must be applied to all tile entities that can receive heat joules.
* @author Darkguardsman code sourced from Calclavia
*
*/
public interface IHeatConsumer
{
/**
* onRecieveSteam is called whenever a Steam transmitter sends a packet of electricity to the consumer (which is this block).
* @param vol - The amount of steam this block received
* @param side - The side of the block in which the electricity came from.
* @return vol - The amount of rejected steam to be sent to back
*/
public float onReceiveHeat(float jouls, int side);
/**
* @return Return the stored electricity in this consumer. Called by conductors to spread electricity to this unit.
*/
public float getStoredHeat();
}

View file

@ -0,0 +1,14 @@
package net.minecraft.src.eui.api;
public interface IHeatProducer
{
/**
* onProduceElectricity is called when a conductor is connected to the producer block in which the conductor will demand power from the producer
* block.
* @param jouls - The maximum jouls can be transfered
* @param side - The side of block in which the conductor is on
* @return jouls - Return jouls to consumer
*/
public float onProduceHeat(float jouls, int side);
}

View file

@ -0,0 +1,30 @@
package net.minecraft.src.eui.api;
public interface ISteamConsumer
{
/**
* onRecieveElectricity is called whenever a Universal Electric conductor sends a packet of electricity to the consumer (which is this block).
* @param watts - The amount of watts this block received.
* @param side - The side of the block in which the electricity came from.
* @return watt - The amount of rejected power to be sent back into the conductor
*/
public int onReceiveSteam(int watts, byte side);
// 1 unit of steam is = to 7132.6gal(27m^3) at 1ATM 424*F(200*C)
/**
* You can use this to check if a wire can connect to this UE consumer to properly render the graphics
* @param side - The side in which the electricity is coming from.
* @return Returns true or false if this consumer can receive electricity at this given tick or moment.
*/
public boolean canRecieveSteam(byte side);
/**
* @return Return the stored electricity in this consumer. Called by conductors to spread electricity to this unit.
*/
public int getStoredSteam();
/**
* @return Return the maximum amount of stored electricity this consumer can get.
*/
public int getSteamCapacity();
}

View file

@ -0,0 +1,20 @@
package net.minecraft.src.eui.api;
/**
* The UEIProducer interface is an interface that must be applied to all tile entities that can produce electricity.
* @author Calclavia
*
*/
public interface ISteamProducer
{
/**
* onProduceElectricity is called when a conductor is connected to the producer block in which the conductor will demand power from the producer
* block.
* @param maxvol - The maximum vol the steam pipe can take
* @param side - The side of block in which the conductor is on
* @return vol - Return the amount of vol that cam be moved at one time
*/
public int onProduceSteam(float maxVol, int side);
public boolean canProduceSteam(byte side);
}

View file

@ -0,0 +1,30 @@
package net.minecraft.src.eui.api;
public interface IWaterConsumer
{
/**
* onRecieveElectricity is called whenever a Universal Electric conductor sends a packet of electricity to the consumer (which is this block).
* @param watts - The amount of watts this block received.
* @param side - The side of the block in which the electricity came from.
* @return watt - The amount of rejected power to be sent back into the conductor
*/
public int onReceiveWater(int vol, byte side);
/**
* You can use this to check if a wire can connect to this UE consumer to properly render the graphics
* @param side - The side in which the electricity is coming from.
* @return Returns true or false if this consumer can receive electricity at this given tick or moment.
*/
public boolean canRecieveWater(byte side);
/**
* @return Return the stored electricity in this consumer. Called by conductors to spread electricity to this unit.
*/
public int getStoredWater();
/**
* @return Return the maximum amount of stored electricity this consumer can get.
*/
public int getWaterCapacity();
}

View file

@ -0,0 +1,20 @@
package net.minecraft.src.eui.api;
/**
* The UEIProducer interface is an interface that must be applied to all tile entities that can produce electricity.
* @author Calclavia
*
*/
public interface IWaterProducer
{
/**
* onProduceElectricity is called when a conductor is connected to the producer block in which the conductor will demand power from the producer
* block.
* @param maxvol - The maximum vol the steam pipe can take
* @param side - The side of block in which the conductor is on
* @return vol - Return the amount of vol that cam be moved at one time
*/
public int onProduceWater(int maxVol, int side);
public boolean canProduceWater(byte side);
}

View file

@ -0,0 +1,59 @@
package net.minecraft.src.eui.boiler;
import net.minecraft.src.*;
public class ContainerBoiler extends Container
{
private TileEntityBoiler boiler;
private int lastCookTime = 0;
private int lastBurnTime = 0;
private int lastItemBurnTime = 0;
public ContainerBoiler(InventoryPlayer par1InventoryPlayer, TileEntityBoiler par2TileEntityboiler)
{
this.boiler = par2TileEntityboiler;
this.addSlot(new Slot(par2TileEntityboiler, 0, 56, 17));
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));
}
}
public void updateProgressBar(int par1, int par2)
{
if (par1 == 0)
{
// this.boiler.furnaceCookTime = par2;
}
if (par1 == 1)
{
//this.boiler.boilerRunTime = par2;
}
}
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
{
return this.boiler.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

@ -0,0 +1,84 @@
package net.minecraft.src.eui.boiler;
import java.text.DecimalFormat;
import net.minecraft.src.*;
import org.lwjgl.opengl.GL11;
public class GuiBoiler extends GuiContainer
{
private TileEntityBoiler boilerInventory;
public GuiBoiler(InventoryPlayer par1InventoryPlayer, TileEntityBoiler par2TileEntityGrinder)
{
super(new ContainerBoiler(par1InventoryPlayer, par2TileEntityGrinder));
this.boilerInventory = par2TileEntityGrinder;
}
/**
* Draw the foreground layer for the GuiContainer (everythin in front of the items)
*/
protected void drawGuiContainerForegroundLayer()
{
this.fontRenderer.drawString("Boiler", 60, 6, 4210752);
this.fontRenderer.drawString("Inventory", 8, this.ySize - 96 + 2, 4210752); if(boilerInventory.hullHeat >=10000)
{
this.fontRenderer.drawString("Heat Danger", (int)(105), 50, 4210752);
}
this.fontRenderer.drawString(StatCollector.translateToLocal("container.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/BoilerGui.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-1, this.ySize);
int var7;
int var8;
int var9;
int var10;
if (this.boilerInventory.waterStored > 0)
{
var7 = boilerInventory.getStoredWater()*4 + 1;
this.drawTexturedModalRect(var5 + 29, var6 + 72 - var7, 176, 148 - var7, 23, var7);
}
if (this.boilerInventory.steamStored > 0)
{
var8 = boilerInventory.steamStored/14*4 + 1;
this.drawTexturedModalRect(var5 + 108, var6 + 72 - var8, 176, 90 - var8, 23, var8);
}
float precentH = Math.min(boilerInventory.hullHeat/1000 + 1, 10);
var9 = (int) Math.min(precentH*3.0F,30);
this.drawTexturedModalRect(var5 + 59, var6 + 70 - var9, 199, 71 - var9, 9, var9);
float precentSH = this.boilerInventory.heatStored/1000;
var10 = (int) Math.round(precentSH*5.33);
this.drawTexturedModalRect(var5 + 78, var6 + 16, 176, 14, var10, 16);
}
public static String getWattDisplay(int watts)
{
String displayWatt;
if(watts > 1000)
{
displayWatt = roundTwoDecimals((double)watts/1000)+" MJ";
}
else
{
displayWatt = watts+" kJ";
}
return displayWatt;
}
public static double roundTwoDecimals(double d)
{
DecimalFormat twoDForm = new DecimalFormat("#.##");
return Double.valueOf(twoDForm.format(d));
}
}

View file

@ -0,0 +1,60 @@
package net.minecraft.src.eui.boiler;
import net.minecraft.src.*;
public class SlotBoiler extends Slot
{
/** The player that is using the GUI where this slot resides. */
private EntityPlayer thePlayer;
private int field_48437_f;
public SlotBoiler(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

@ -0,0 +1,601 @@
package net.minecraft.src.eui.boiler;
import net.minecraft.src.*;
import net.minecraft.src.eui.BlockMachine;
import net.minecraft.src.eui.TileEntityMachine;
import net.minecraft.src.eui.api.*;
import net.minecraft.src.eui.burner.TileEntityFireBox;
import net.minecraft.src.eui.steam.TileEntityPipe;
import net.minecraft.src.forge.ForgeHooks;
import net.minecraft.src.forge.ISidedInventory;
import net.minecraft.src.universalelectricity.UniversalElectricity;
public class TileEntityBoiler extends TileEntityMachine implements IInventory, ISidedInventory,ISteamProducer, IWaterConsumer
{
/**
* The ItemStacks that hold the items currently being used in the furnace
*/
private ItemStack[] furnaceItemStacks = new ItemStack[3];
/** The number of ticks that the boiler will keep burning */
public int RunTime = 0;
/** The ammount of energy stored before being add to run Timer */
public int energyStore = 0;
/** The ammount of water stored */
public int waterStored = 0;
/** The ammount of steam stored */
public int steamStored = 0;
/** The ammount of heat stored */
public int heatStored = 0;
public int heatMax = 10000;
/** The ammount of heat stored */
public int hullHeat = 0;
public int hullHeatMax = 10000;
private int heatTick = 0;
public TileEntity[] connectedBlocks = {null, null, null, null, null, null};
public TileEntity[] connectedFaces = {null, null, null, null, null, null, null, null};
int steamMax = 140;
public boolean isBeingHeated = false;
/**
* 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.boiler";
}
/**
* 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.RunTime = par1NBTTagCompound.getShort("BurnTime");
this.energyStore = par1NBTTagCompound.getInteger("energyStore");
this.steamStored = par1NBTTagCompound.getInteger("steamStore");
this.heatStored = par1NBTTagCompound.getInteger("heatStore");
this.waterStored = par1NBTTagCompound.getInteger("waterStore");
this.hullHeat = par1NBTTagCompound.getInteger("hullHeat");
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setShort("BurnTime", (short)this.RunTime);
par1NBTTagCompound.setInteger("energyStore", (int)this.energyStore);
par1NBTTagCompound.setInteger("steamStore", (int)this.steamStored);
par1NBTTagCompound.setInteger("heatStore", (int)this.heatStored);
par1NBTTagCompound.setInteger("waterStore", (int)this.waterStored);
par1NBTTagCompound.setInteger("hullHeat", (int)this.hullHeat);
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;
}
/**
* 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.
*/
private boolean getIsHeated() {
TileEntity blockEntity = worldObj.getBlockTileEntity(this.xCoord, this.yCoord - 1, this.zCoord);
if(blockEntity instanceof TileEntityFireBox)
{
return true;
}
else
{
return false;
}
}
private int getTextureFront() {
return 0;
}
public TileEntity getFacingBoilers(int i)
{
int x = this.xCoord;
int y = this.yCoord;
int z = this.zCoord;
switch(i){
case 0: y = y - 1;break;
case 1: y = y + 1;break;
case 2: z = z + 1;break;
case 3: z = z - 1;break;
case 4: x = x + 1;break;
case 5: x = x - 1;break;
}
TileEntity aEntity = worldObj.getBlockTileEntity(x, y, z);
if(aEntity instanceof TileEntityBoiler)
{
return aEntity;
}
return null;
}
int count = 0;
public void updateEntity(){
if(count == 20){
isBeingHeated = getIsHeated();
addConnection();
shareResources();
count = 0;
}
else
{
count++;
}
boolean hullHeated = false;
//changed hullHeat max depending on contents of boiler
if(waterStored>0)
{
hullHeatMax = 4700;
if(hullHeat > hullHeatMax)
{
hullHeat = 4700;
}
}
else
{
hullHeatMax = 10000;
}
//Checks if the hull is heated
if(hullHeat >= hullHeatMax)
{
hullHeated = true;
}
else
{
hullHeat = Math.min(hullHeat + heatStored, hullHeatMax);
}
//checks if heat level hit max
if(hullHeat >= 10000)
{
if(heatTick >= 1200)
{
// TODO remove block and set fire
heatTick = 0;
}
else
{
heatTick += 1;
}
}
//adds water from container slot
addWater();
int heatNeeded = mod_EUIndustry.boilerHeat; // kilo joules
//if hull heated do work
if(hullHeated)
{
if(heatStored > mod_EUIndustry.fireOutput)
{
if(waterStored >= 1){
if(heatStored >= heatNeeded)
{
heatStored = Math.max(heatStored - heatNeeded, 0);
--waterStored;
steamStored = Math.min(steamStored + mod_EUIndustry.steamOutBoiler,this.steamMax);
}
}
else
{
heatStored = 0;
}
}
}
TileEntity blockE = worldObj.getBlockTileEntity(xCoord, yCoord -1, zCoord);
if(blockE instanceof TileEntityFireBox)
{
if(!hullHeated || waterStored > 0)
{
heatStored = (int) Math.min((heatStored + ((TileEntityFireBox)blockE).onProduceHeat(mod_EUIndustry.fireOutput, 1)), heatMax);
}
}
}
int transferW = 0;
int transferS = 0;
int transferH = 0;
public void shareResources()
{
for(int i = 0; i<6; i++)
{
if(connectedBlocks[i] instanceof TileEntityBoiler)
{
TileEntityBoiler connectedConsumer = (TileEntityBoiler)connectedBlocks[i];
//add steam to other boiler if less
boolean canTradeSteam;
if( i ==0)
{
if(this.steamStored == this.steamMax)
{
canTradeSteam = true;
}
else
{
canTradeSteam = false;
}
}
else
{
canTradeSteam = true;
}
if(canTradeSteam)
{
if( this.steamStored > 0)
{
int SSum = (this.steamStored + connectedConsumer.steamStored)/2;
if(i == 1 && connectedConsumer.steamStored < connectedConsumer.steamMax && this.steamStored > 0){
if(this.steamStored >= 10 )
{
int rejectedW = connectedConsumer.addSteam(10);
this.steamStored = Math.max(Math.min(this.steamStored - 10 + rejectedW, this.steamMax), 0);
}
else
{
int rejectedW = connectedConsumer.addSteam(this.steamStored);
this.steamStored = Math.max(Math.min(this.steamStored - this.steamStored + rejectedW, this.steamMax), 0);
}
}
if(this.steamStored > connectedConsumer.steamStored)
{
transferS = SSum - connectedConsumer.steamStored;
int rejectedS = connectedConsumer.addSteam(transferS);
this.steamStored = Math.max(Math.min(this.steamStored - transferS + rejectedS, 140), 0);
}
}
}
//add water to other boiler if less
if( this.waterStored > 0)
{
boolean canTradeWater;
if( i ==1)
{
if(this.waterStored == this.getWaterCapacity())
{
canTradeWater = true;
}
else
{
canTradeWater = false;
}
}
else
{
canTradeWater = true;
}
if(canTradeWater)
{
int WSum = (this.waterStored + connectedConsumer.waterStored)/2;
if(i == 0 && this.waterStored > 0 && connectedConsumer.waterStored < connectedConsumer.getWaterCapacity())
{
int rejectedW = connectedConsumer.addwater(1);
this.waterStored = Math.max(Math.min(this.waterStored - 1 + rejectedW, this.getWaterCapacity()), 0);
}
if(this.waterStored > connectedConsumer.waterStored)
{
transferW =Math.round(WSum - connectedConsumer.waterStored);
if(transferW > 0)
{
int rejectedW = connectedConsumer.addwater(transferW);
this.waterStored = Math.max(Math.min(this.waterStored - transferW + rejectedW, this.getWaterCapacity()), 0);
}
}
}
}
//add heat to other boiler if less
boolean canTradeHeat;
if(this.heatStored == heatMax || !isBeingHeated)
{
canTradeHeat = true;
}
else
{
canTradeHeat = false;
}
if(canTradeHeat)
{
if( this.heatStored > 0)
{
if(this.heatStored > connectedConsumer.heatStored )
{
int HSum = (this.heatStored + connectedConsumer.heatStored)/2;
transferH = HSum - connectedConsumer.heatStored;
int rejectedH = connectedConsumer.onReceiveHeat(transferH);
this.heatStored = Math.max(Math.min(this.waterStored - transferW + rejectedH, heatMax), 0);
}
}
}
}
}
}
private int onProduceWater(int t, int i) {
if(waterStored - t > 0)
{
waterStored = waterStored - t;
return t;
}
return 0;
}
public void addConnection()
{
for(int i = 0; i<6; i++)
{
TileEntity aEntity = getSteamMachine(i);
if(aEntity instanceof TileEntityBoiler)
{
this.connectedBlocks[i] = aEntity;
}
else
{
this.connectedBlocks[i] = null;
}
}
}
public int addSteam(int watt) {
int rejectedElectricity = Math.max((this.steamStored + watt) - steamMax, 0);
this.steamStored += watt - rejectedElectricity;
return rejectedElectricity;
}
public int addwater(int watt) {
int rejectedElectricity = Math.max((this.waterStored + watt) - this.getWaterCapacity(), 0);
this.waterStored += watt - rejectedElectricity;
return rejectedElectricity;
}
public int onReceiveHeat(int watt) {
if(heatStored < heatMax)
{
int rejectedElectricity = Math.max((this.heatStored + watt) - heatMax, 0);
this.heatStored += watt - rejectedElectricity;
return rejectedElectricity;
}
return watt;
}
/**
* adds water too the system
*/
private void addWater() {
if (this.furnaceItemStacks[0] != null)
{
if(this.furnaceItemStacks[0].isItemEqual(new ItemStack(Item.bucketWater,1)))
{
if((int)waterStored < getWaterCapacity())
{
++waterStored;
this.furnaceItemStacks[0] = new ItemStack(Item.bucketEmpty,1);
this.onInventoryChanged();
}
}
}
}
/**
* 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 int getStartInventorySide(int side)
{
if (side == 0) return 1;
if (side == 1) return 0;
return 2;
}
@Override
public int getSizeInventorySide(int side)
{
return 1;
}
@Override
public int onReceiveWater(int vol, byte side) {
if(waterStored + vol < getWaterCapacity()){
waterStored = waterStored + (int)vol;
return 0;
}
return vol;
}
@Override
public int getStoredWater() {
return this.waterStored;
}
@Override
public int getWaterCapacity() {
return 14;
}
public int precentHeated() {
int var1;
if(hullHeat < 100)
{
var1 = (int)(100 *(hullHeat/100));
}
else
{
var1 = 100;
}
return var1;
}
@Override
public boolean canRecieveWater(byte side) {
return true;
}
@Override
public int onProduceSteam(float maxVol, int side) {
if(steamStored > 0)
{
--steamStored;
return 1;
}
return 0;
}
@Override
public boolean canProduceSteam(byte side) {
return true;
}
}

View file

@ -0,0 +1,42 @@
package net.minecraft.src.eui.burner;
import net.minecraft.src.*;
public class ContainerFireBox extends Container
{
private TileEntityFireBox tileEntity;
public ContainerFireBox(InventoryPlayer par1InventoryPlayer, TileEntityFireBox tileEntity)
{
this.tileEntity = tileEntity;
this.addSlot(new Slot(tileEntity, 0, 33, 34));
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));
}
}
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
{
return this.tileEntity.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

@ -0,0 +1,87 @@
package net.minecraft.src.eui.burner;
import org.lwjgl.opengl.GL11;
import java.math.*;
import java.text.DecimalFormat;
import java.lang.Integer;
import net.minecraft.src.*;
import net.minecraft.src.universalelectricity.UniversalElectricity;
public class GUIFireBox extends GuiContainer
{
private TileEntityFireBox tileEntity;
private int containerWidth;
private int containerHeight;
public GUIFireBox(InventoryPlayer par1InventoryPlayer, TileEntityFireBox tileEntity)
{
super(new ContainerFireBox(par1InventoryPlayer, tileEntity));
this.tileEntity = tileEntity;
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
protected void drawGuiContainerForegroundLayer()
{
this.fontRenderer.drawString("FireBox", 55, 6, 4210752);
this.fontRenderer.drawString("HeatOut", 90, 33, 4210752);
String displayText = "";
if(!tileEntity.isConnected)
{
displayText = "No Boiler";
}
else if(tileEntity.containingItems[0] != null)
{
if(tileEntity.containingItems[0].getItem().shiftedIndex != Item.coal.shiftedIndex)
{
displayText = "No Coal";
}
else{
if(tileEntity.generateRate*20 < 20)
{
displayText = "Hull Heat: "+(tileEntity.generateRate*100)+"%";
}
else
{
displayText = getWattDisplay((tileEntity.generateRate*20));
}
}
}
this.fontRenderer.drawString(displayText, (int)(105-displayText.length()*1.25), 45, 4210752);
this.fontRenderer.drawString(StatCollector.translateToLocal("container.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/SteamGUI.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4);
containerWidth = (this.width - this.xSize) / 2;
containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
}
public static String getWattDisplay(int watts)
{
String displayWatt;
if(watts > 1000)
{
displayWatt = roundTwoDecimals((double)watts/1000)+" MJ";
}
else
{
displayWatt = watts+" KJ";
}
return displayWatt;
}
public static double roundTwoDecimals(double d)
{
DecimalFormat twoDForm = new DecimalFormat("#.##");
return Double.valueOf(twoDForm.format(d));
}
}

View file

@ -0,0 +1,265 @@
package net.minecraft.src.eui.burner;
import net.minecraft.src.eui.TileEntityMachine;
import net.minecraft.src.eui.api.IHeatProducer;
import net.minecraft.src.eui.boiler.TileEntityBoiler;
import net.minecraft.src.forge.ForgeHooks;
import net.minecraft.src.*;
import net.minecraft.src.universalelectricity.*;
import net.minecraft.src.forge.ISidedInventory;
public class TileEntityFireBox extends TileEntityMachine implements IInventory, ISidedInventory, IHeatProducer
{
//max heat generated per second
private int connectedUnits = 0;
public static int maxGenerateRate = 0;
//Current generation rate based on hull heat. In TICKS.
public int generateRate = 0;
public boolean isConnected = false;
public TileEntity[] connectedBlocks = {null, null, null, null, null, null};
int count = 0;
public int itemCookTime = 0;
public ItemStack[] containingItems = new ItemStack[1];
public void updateEntity()
{if (!this.worldObj.isRemote){
if(count == 20)
{
addConnection();
sharCoal();
count = 0;
}
count++;
maxGenerateRate = mod_EUIndustry.fireOutput + (connectedUnits*5);
TileEntity blockEntity = worldObj.getBlockTileEntity(this.xCoord, this.yCoord + 1, this.zCoord);
if(blockEntity instanceof TileEntityBoiler)
{
isConnected = true;
}
else
{
isConnected = false;
}
//The top slot is for recharging items. Check if the item is a electric item. If so, recharge it.
if (this.containingItems[0] != null && isConnected)
{
if (this.containingItems[0].getItem().shiftedIndex == Item.coal.shiftedIndex)
{
if(this.itemCookTime <= 0)
{
itemCookTime = Math.max(1600 - (int)(this.generateRate*20), 400);
this.decrStackSize(0, 1);
}
}
}
}
//Starts generating electricity if the device is heated up
if (this.itemCookTime > 0)
{
this.itemCookTime --;
if(isConnected)
{
this.generateRate = Math.min(this.generateRate+Math.min((this.generateRate)+1, 1), this.maxGenerateRate/20);
}
}
//Loose heat when the generator is not connected or if there is no coal in the inventory.
if(this.itemCookTime <= 0 || !isConnected)
{
this.generateRate = Math.max(this.generateRate-5, 0);
}
}
//gets all connected fireBoxes and shares its supply of coal
public void sharCoal(){
for(int i =0; i<6;i++)
{
if(connectedBlocks[i] instanceof TileEntityFireBox)
{
TileEntityFireBox connectedConsumer = (TileEntityFireBox) connectedBlocks[i];
if(this.containingItems[0] != null)
{
if(this.containingItems[0].getItem().shiftedIndex == Item.coal.shiftedIndex && this.containingItems[0].stackSize > 0)
{
if(connectedConsumer.containingItems[0] != null)
{
if(connectedConsumer.containingItems[0].getItem().shiftedIndex == Item.coal.shiftedIndex)
{
if(connectedConsumer.containingItems[0].getItem().shiftedIndex == Item.coal.shiftedIndex)
{
int CSum = Math.round(this.containingItems[0].stackSize + connectedConsumer.containingItems[0].stackSize)/2;
if(this.containingItems[0].stackSize > connectedConsumer.containingItems[0].stackSize)
{
int transferC = 0;
transferC = Math.round(CSum - connectedConsumer.containingItems[0].stackSize);
connectedConsumer.containingItems[0].stackSize = connectedConsumer.containingItems[0].stackSize + transferC;
this.containingItems[0].stackSize = this.containingItems[0].stackSize - transferC;
}
}
}
}
else
{
connectedConsumer.containingItems[0] = new ItemStack(this.containingItems[0].getItem());
this.containingItems[0].stackSize -= 1;
}
}
}
}
}
}
public void addConnection()
{
connectedUnits = 0;
for(int i = 0; i<6; i++)
{
TileEntity aEntity = getSteamMachine(i);
if(aEntity instanceof TileEntityFireBox && i != 0 && i != 1)
{
this.connectedBlocks[i] = aEntity;
connectedUnits += 1;
}
else
{
this.connectedBlocks[i] = null;
}
}
}
/**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
this.itemCookTime = par1NBTTagCompound.getInteger("itemCookTime");
this.generateRate = par1NBTTagCompound.getInteger("generateRate");
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
this.containingItems = 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.containingItems.length)
{
this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("itemCookTime", (int)this.itemCookTime);
par1NBTTagCompound.setInteger("generateRate", (int)this.generateRate);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.containingItems.length; ++var3)
{
if (this.containingItems[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
this.containingItems[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
par1NBTTagCompound.setTag("Items", var2);
}
@Override
public int getStartInventorySide(int side)
{
if (side == 0)
{
return 1;
}
if (side == 1)
{
return 0;
}
return 2;
}
@Override
public int getSizeInventorySide(int side) { return getSizeInventory(); }
@Override
public int getSizeInventory() { return this.containingItems.length; }
@Override
public ItemStack getStackInSlot(int par1) { return this.containingItems[par1]; }
@Override
public ItemStack decrStackSize(int par1, int par2)
{
if (this.containingItems[par1] != null)
{
ItemStack var3;
if (this.containingItems[par1].stackSize <= par2)
{
var3 = this.containingItems[par1];
this.containingItems[par1] = null;
return var3;
}
else
{
var3 = this.containingItems[par1].splitStack(par2);
if (this.containingItems[par1].stackSize == 0)
{
this.containingItems[par1] = null;
}
return var3;
}
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int par1)
{
if (this.containingItems[par1] != null)
{
ItemStack var2 = this.containingItems[par1];
this.containingItems[par1] = null;
return var2;
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{
this.containingItems[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public String getInvName() {
return "FireBox";
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
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;
}
@Override
public void openChest() { }
@Override
public void closeChest() { }
@Override
public float onProduceHeat(float jouls, int side) {
// TODO Auto-generated method stub
return Math.min(generateRate,jouls);
}
}

View file

@ -0,0 +1,87 @@
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

@ -0,0 +1,74 @@
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

@ -0,0 +1,46 @@
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

@ -0,0 +1,60 @@
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

@ -0,0 +1,386 @@
package net.minecraft.src.eui.grinder;
import net.minecraft.src.*;
import net.minecraft.src.universalelectricity.UEIConsumer;
import net.minecraft.src.eui.TileEntityMachine;
import net.minecraft.src.forge.ForgeHooks;
import net.minecraft.src.forge.ISidedInventory;
public class TileEntityGrinder extends TileEntityMachine implements IInventory, ISidedInventory, UEIConsumer
{
/**
* 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 int getStartInventorySide(int side)
{
if (side == 0) return 1;
if (side == 1) return 0;
return 2;
}
@Override
public int getSizeInventorySide(int side)
{
return 1;
}
@Override
public int onReceiveElectricity(int watts, int voltage, byte side) {
//can store 1 min of energy too do work
if(this.energyStore <= 1000)
{
if(!(this.energyStore + watts > 1000))
{
this.energyStore = this.energyStore + watts;
return 0;
}
else
{
int varB = watts - this.energyStore;
int eGain = (varB * varB) / 2;
this.energyStore = this.energyStore + eGain;
return (watts - eGain);
}
}
return watts;
}
@Override
public int getStoredElectricity() {
// TODO what is acutal returned
return this.energyStore;
}
@Override
public int getElectricityCapacity() {
// TODO Auto-generated method stub
return 1000;
}
@Override
public boolean canRecieveElectricity(byte side) {
// TODO Auto-generated method stub
return true;
}
@Override
public int getVolts() {
// TODO Auto-generated method stub
return 120;
}
}

View file

@ -0,0 +1,139 @@
package net.minecraft.src.eui.steam;
import java.util.ArrayList;
import net.minecraft.src.eui.api.*;
import net.minecraft.src.eui.*;
import net.minecraft.src.eui.boiler.TileEntityBoiler;
import net.minecraft.src.eui.turbine.TileEntityGenerator;
import net.minecraft.src.eui.steam.TileEntityPipe;
import net.minecraft.src.universalelectricity.UniversalElectricity;
import net.minecraft.src.*;
import java.util.Random;
public class BlockPipe extends BlockContainer
{
static String type = "";
public BlockPipe(int id)
{
super(id, Material.iron);
this.setBlockName("Pipe");
this.setBlockBounds(0.30F, 0.30F, 0.30F, 0.70F, 0.70F, 0.70F);
}
/**
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}
/**
* The type of render function that is called for this block
*/
public int getRenderType()
{
return -1;
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3)
{
return mod_EUIndustry.pipeID;
}
public TileEntity getBlockEntity()
{
return new TileEntityPipe();
}
//Per tick
public int conductorCapacity()
{
return 5;
}
public static TileEntity getUEUnit(World world, int x, int y, int z, byte side)
{
switch(side)
{
case 0: y -= 1; break;
case 1: y += 1; break;
case 2: z += 1; break;
case 3: z -= 1; break;
case 4: x += 1; break;
case 5: x -= 1; break;
}
//Check if the designated block is a UE Unit - producer, consumer or a conductor
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
TileEntity returnValue = null;
if(tileEntity instanceof ISteamConsumer)
{
if(((ISteamConsumer)tileEntity).canRecieveSteam(UniversalElectricity.getOrientationFromSide(side, (byte)2)))
{
returnValue = tileEntity;
}
}
if (tileEntity instanceof ISteamProducer)
{
if(((ISteamProducer)tileEntity).canProduceSteam(UniversalElectricity.getOrientationFromSide(side, (byte)2)))
{
returnValue = tileEntity;
}
}
return returnValue;
}
/**
* Called whenever the block is added into the world. Args: world, x, y, z
*/
@Override
public void onBlockAdded(World world, int x, int y, int z)
{
super.onBlockAdded(world, x, y, z);
this.updateConductorTileEntity(world, x, y, z);
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor blockID
*/
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
{
super.onNeighborBlockChange(world, x, y, z, blockID);
this.updateConductorTileEntity(world, x, y, z);
}
public void updateConductorTileEntity(World world, int x, int y, int z)
{
for(byte i = 0; i < 6; i++)
{
//Update the tile entity on neighboring blocks
TileEntityPipe conductorTileEntity = (TileEntityPipe)world.getBlockTileEntity(x, y, z);
conductorTileEntity.addConnection(getUEUnit(world, x, y, z, i), i);
}
}
}

View file

@ -0,0 +1,139 @@
package net.minecraft.src.eui.steam;
import java.util.ArrayList;
import net.minecraft.src.eui.api.IWaterConsumer;
import net.minecraft.src.eui.api.IWaterProducer;
import net.minecraft.src.eui.*;
import net.minecraft.src.eui.boiler.TileEntityBoiler;
import net.minecraft.src.eui.turbine.TileEntityGenerator;
import net.minecraft.src.eui.steam.TileEntityPipeWater;
import net.minecraft.src.universalelectricity.UniversalElectricity;
import net.minecraft.src.*;
import java.util.Random;
public class BlockPipeWater extends BlockContainer
{
static String type = "";
public BlockPipeWater(int id)
{
super(id, Material.iron);
this.setBlockName("PipeW");
this.setBlockBounds(0.30F, 0.30F, 0.30F, 0.70F, 0.70F, 0.70F);
}
/**
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}
/**
* The type of render function that is called for this block
*/
public int getRenderType()
{
return -1;
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3)
{
return mod_EUIndustry.pipeID;
}
public TileEntity getBlockEntity()
{
return new TileEntityPipeWater();
}
//Per tick
public int conductorCapacity()
{
return 5;
}
public static TileEntity getUEUnit(World world, int x, int y, int z, byte side)
{
switch(side)
{
case 0: y -= 1; break;
case 1: y += 1; break;
case 2: z += 1; break;
case 3: z -= 1; break;
case 4: x += 1; break;
case 5: x -= 1; break;
}
//Check if the designated block is a UE Unit - producer, consumer or a conductor
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
TileEntity returnValue = null;
if(tileEntity instanceof IWaterConsumer)
{
if(((IWaterConsumer)tileEntity).canRecieveWater(UniversalElectricity.getOrientationFromSide(side, (byte)2)))
{
returnValue = tileEntity;
}
}
if (tileEntity instanceof IWaterProducer)
{
if(((IWaterProducer)tileEntity).canProduceWater(UniversalElectricity.getOrientationFromSide(side, (byte)2)))
{
returnValue = tileEntity;
}
}
return returnValue;
}
/**
* Called whenever the block is added into the world. Args: world, x, y, z
*/
@Override
public void onBlockAdded(World world, int x, int y, int z)
{
super.onBlockAdded(world, x, y, z);
this.updateConductorTileEntity(world, x, y, z);
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor blockID
*/
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
{
super.onNeighborBlockChange(world, x, y, z, blockID);
this.updateConductorTileEntity(world, x, y, z);
}
public void updateConductorTileEntity(World world, int x, int y, int z)
{
for(byte i = 0; i < 6; i++)
{
//Update the tile entity on neighboring blocks
TileEntityPipeWater conductorTileEntity = (TileEntityPipeWater)world.getBlockTileEntity(x, y, z);
conductorTileEntity.addConnection(getUEUnit(world, x, y, z, i), i);
}
}
}

View file

@ -0,0 +1,123 @@
package net.minecraft.src.eui.steam;
import java.util.ArrayList;
import net.minecraft.src.forge.*;
import net.minecraft.src.*;
public class ItemPipe extends Item implements ITextureProvider
{
private int spawnID;
public ItemPipe(int id)
{
super(id);
this.setMaxDamage(0);
this.setHasSubtypes(true);
this.setIconIndex(10);
this.setItemName("pipe");
}
@Override
public int getIconFromDamage(int par1)
{
switch(par1)
{
case 0: return 11;
case 1: return 10;
}
return this.iconIndex;
}
public String getItemNameIS(ItemStack par1ItemStack)
{
int var3 = par1ItemStack.getItemDamage();
switch(var3)
{
case 1: return "waterPipe";
case 0: return "steamPipe";
}
return this.getItemName();
}
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS !
*/
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7)
{
int blockID = par3World.getBlockId(par4, par5, par6);
if(par1ItemStack.getItemDamage() == 0)
{
spawnID = mod_EUIndustry.pipeBlockID;
}
if(par1ItemStack.getItemDamage() == 1)
{
spawnID = mod_EUIndustry.pipeBlockID2;
}
if (blockID == Block.snow.blockID)
{
par7 = 1;
}
else if (blockID != Block.vine.blockID && blockID != Block.tallGrass.blockID && blockID != Block.deadBush.blockID)
{
if (par7 == 0)
{
--par5;
}
if (par7 == 1)
{
++par5;
}
if (par7 == 2)
{
--par6;
}
if (par7 == 3)
{
++par6;
}
if (par7 == 4)
{
--par4;
}
if (par7 == 5)
{
++par4;
}
}
if (par3World.canBlockBePlacedAt(this.spawnID, par4, par5, par6, false, par7))
{
Block var9 = Block.blocksList[this.spawnID];
if (par3World.setBlockWithNotify(par4, par5, par6, this.spawnID))
{
if (par3World.getBlockId(par4, par5, par6) == this.spawnID)
{
Block.blocksList[this.spawnID].onBlockPlaced(par3World, par4, par5, par6, par7);
Block.blocksList[this.spawnID].onBlockPlacedBy(par3World, par4, par5, par6, par2EntityPlayer);
}
--par1ItemStack.stackSize;
return true;
}
}
return false;
}
@Override
public String getTextureFile() {
return "/eui/Items.png";
}
public void addCreativeItems(ArrayList itemList) {
itemList.add(new ItemStack(this, 1,0));
itemList.add(new ItemStack(this, 1,1));
}
}

View file

@ -0,0 +1,98 @@
package net.minecraft.src.eui.steam;
import net.minecraft.src.*;
public class ModelPipe extends ModelBase
{
//fields
ModelRenderer Middle;
ModelRenderer Right;
ModelRenderer Left;
ModelRenderer Back;
ModelRenderer Front;
ModelRenderer Top;
ModelRenderer Bottom;
public ModelPipe()
{
textureWidth = 64;
textureHeight = 32;
Middle = new ModelRenderer(this, 0, 0);
Middle.addBox(-1F, -1F, -1F, 4, 4, 4);
Middle.setRotationPoint(-1F, 15F, -1F);
Middle.setTextureSize(64, 32);
Middle.mirror = true;
setRotation(Middle, 0F, 0F, 0F);
Right = new ModelRenderer(this, 21, 0);
Right.addBox(0F, 0F, 0F, 6, 4, 4);
Right.setRotationPoint(2F, 14F, -2F);
Right.setTextureSize(64, 32);
Right.mirror = true;
setRotation(Right, 0F, 0F, 0F);
Left = new ModelRenderer(this, 21, 0);
Left.addBox(0F, 0F, 0F, 6, 4, 4);
Left.setRotationPoint(-8F, 14F, -2F);
Left.setTextureSize(64, 32);
Left.mirror = true;
setRotation(Left, 0F, 0F, 0F);
Back = new ModelRenderer(this, 0, 11);
Back.addBox(0F, 0F, 0F, 4, 4, 6);
Back.setRotationPoint(-2F, 14F, 2F);
Back.setTextureSize(64, 32);
Back.mirror = true;
setRotation(Back, 0F, 0F, 0F);
Front = new ModelRenderer(this, 0, 11);
Front.addBox(0F, 0F, 0F, 4, 4, 6);
Front.setRotationPoint(-2F, 14F, -8F);
Front.setTextureSize(64, 32);
Front.mirror = true;
setRotation(Front, 0F, 0F, 0F);
Top = new ModelRenderer(this, 21, 11);
Top.addBox(0F, 0F, 0F, 4, 6, 4);
Top.setRotationPoint(-2F, 8F, -2F);
Top.setTextureSize(64, 32);
Top.mirror = true;
setRotation(Top, 0F, 0F, 0F);
Bottom = new ModelRenderer(this, 21, 11);
Bottom.addBox(0F, 0F, 0F, 4, 6, 4);
Bottom.setRotationPoint(-2F, 18F, -2F);
Bottom.setTextureSize(64, 32);
Bottom.mirror = true;
setRotation(Bottom, 0F, 0F, 0F);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5);
this.renderMiddle();
this.renderBottom();
this.renderTop();
this.renderLeft();
this.renderRight();
this.renderBack();
this.renderFront();
}
public void renderMiddle() { Middle.render(0.0625F); }
public void renderBottom() { Bottom.render(0.0625F); }
public void renderTop() { Top.render(0.0625F); }
public void renderLeft() { Left.render(0.0625F); }
public void renderRight() { Right.render(0.0625F); }
public void renderBack() { Back.render(0.0625F); }
public void renderFront() { Front.render(0.0625F);}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5);
}
}

View file

@ -0,0 +1,40 @@
package net.minecraft.src.eui.steam;
import org.lwjgl.opengl.GL11;
import net.minecraft.src.*;
public class RenderPipe extends TileEntitySpecialRenderer
{
private ModelPipe model;
public RenderPipe()
{
model = new ModelPipe();
}
public void renderAModelAt(TileEntityPipe tileEntity, double d, double d1, double d2, float f)
{
//Texture file
bindTextureByName("/eui/CopperWire.png");
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
if(tileEntity.connectedBlocks[0] != null) model.renderBottom();
if(tileEntity.connectedBlocks[1] != null) model.renderTop();
if(tileEntity.connectedBlocks[2] != null) model.renderFront();
if(tileEntity.connectedBlocks[3] != null) model.renderBack();
if(tileEntity.connectedBlocks[4] != null) model.renderRight();
if(tileEntity.connectedBlocks[5] != null) model.renderLeft();
model.renderMiddle();
GL11.glPopMatrix();
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) {
this.renderAModelAt((TileEntityPipe)tileEntity, var2, var4, var6, var8);
}
}

View file

@ -0,0 +1,40 @@
package net.minecraft.src.eui.steam;
import org.lwjgl.opengl.GL11;
import net.minecraft.src.*;
public class RenderPipeWater extends TileEntitySpecialRenderer
{
private ModelPipe model;
public RenderPipeWater()
{
model = new ModelPipe();
}
public void renderAModelAt(TileEntityPipeWater tileEntity, double d, double d1, double d2, float f)
{
//Texture file
bindTextureByName("/eui/WaterPipe.png");
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
if(tileEntity.connectedBlocks[0] != null) model.renderBottom();
if(tileEntity.connectedBlocks[1] != null) model.renderTop();
if(tileEntity.connectedBlocks[2] != null) model.renderFront();
if(tileEntity.connectedBlocks[3] != null) model.renderBack();
if(tileEntity.connectedBlocks[4] != null) model.renderRight();
if(tileEntity.connectedBlocks[5] != null) model.renderLeft();
model.renderMiddle();
GL11.glPopMatrix();
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) {
this.renderAModelAt((TileEntityPipeWater)tileEntity, var2, var4, var6, var8);
}
}

View file

@ -0,0 +1,213 @@
package net.minecraft.src.eui.steam;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.TileEntity;
import net.minecraft.src.eui.api.ISteamConsumer;
import net.minecraft.src.eui.api.ISteamProducer;
import net.minecraft.src.universalelectricity.UniversalElectricity;
import net.minecraft.src.universalelectricity.Vector3;
public class TileEntityPipe extends TileEntity implements ISteamConsumer
{
//The amount of electricity stored in the conductor
protected int steamStored = 0;
//The maximum amount of electricity this conductor can take
protected int capacity = 5;
//Stores information on all connected blocks around this tile entity
public TileEntity[] connectedBlocks = {null, null, null, null, null, null};
//Checks if this is the first the tile entity updates
protected boolean firstUpdate = true;
/**
* The tile entity of the closest electric consumer. Null if none. Use this to detect if electricity
* should transfer
*/
public TileEntity closestConsumer = null;
/**
* This function adds a connection between this conductor and the UE unit
* @param tileEntity - Must be either a producer, consumer or a conductor
* @param side - side in which the connection is coming from
*/
public void addConnection(TileEntity tileEntity, byte side)
{
if(tileEntity instanceof ISteamConsumer || tileEntity instanceof ISteamProducer)
{
this.connectedBlocks[side] = tileEntity;
}
else
{
this.connectedBlocks[side] = null;
}
}
/**
* onRecieveElectricity is called whenever a Universal Electric conductor sends a packet of electricity to the consumer (which is this block).
* @param watts - The amount of watt this block recieved
* @param side - The side of the block in which the electricity came from
* @return watt - The amount of rejected power to be sent back into the conductor
*/
@Override
public int onReceiveSteam(int watt, byte side)
{
int rejectedElectricity = Math.max((this.steamStored + watt) - this.capacity, 0);
this.steamStored += watt - rejectedElectricity;
return rejectedElectricity;
}
/**
* You can use this to check if a wire can connect to this UE consumer to properly render the graphics
* @return Returns true or false if this consumer can receive electricity at this given tick or moment.
*/
public boolean canRecieveSteam(byte side)
{
return true;
}
/**
* 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.
*/
@Override
public void updateEntity()
{
if(this.firstUpdate)
{
//Update some variables
BlockPipe conductorBlock = (BlockPipe)this.getBlockType();
this.capacity = (conductorBlock).conductorCapacity();
((BlockPipe)this.getBlockType()).updateConductorTileEntity(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
this.firstUpdate = false;
}
//Spread the electricity to neighboring blocks
byte connectedUnits = 0;
byte connectedConductors = 1;
int averageElectricity = this.steamStored;
this.closestConsumer = null;
Vector3 currentPosition = new Vector3(this.xCoord, this.yCoord, this.zCoord);
if(this.steamStored * 3.3 > 250)
{
// TODO add logic to damage pipe if steam rises to 250PSI
}
//Find the connected unit with the least amount of electricity and give more to them
for(byte i = 0; i < 6; i++)
{
if(connectedBlocks[i] != null)
{
if(connectedBlocks[i] instanceof ISteamConsumer)
{
connectedUnits ++;
if(connectedBlocks[i].getClass() == this.getClass())
{
averageElectricity += ((TileEntityPipe)connectedBlocks[i]).steamStored;
TileEntity tileEntity = ((TileEntityPipe)connectedBlocks[i]).closestConsumer;
if(tileEntity != null)
{
this.closestConsumer = tileEntity;
}
connectedConductors ++;
}
else if(connectedBlocks[i] instanceof ISteamConsumer)
{
if(((ISteamConsumer)connectedBlocks[i]).canRecieveSteam(UniversalElectricity.getOrientationFromSide(i, (byte)2)))
{
this.closestConsumer = connectedBlocks[i];
}
}
}
}
}
averageElectricity = averageElectricity/connectedConductors;
float averageWatt = 0;
if(connectedUnits > 0)
{
for(byte i = 0; i < 6; i++)
{
if(connectedBlocks[i] != null)
{
//Spread the electricity among the different blocks
if(connectedBlocks[i] instanceof ISteamConsumer && this.steamStored > 0)
{
if(((ISteamConsumer)connectedBlocks[i]).canRecieveSteam(UniversalElectricity.getOrientationFromSide(i, (byte) 2)))
{
int transferElectricityAmount = 0;
ISteamConsumer connectedConsumer = ((ISteamConsumer)connectedBlocks[i]);
if(connectedBlocks[i].getClass() == this.getClass() && this.steamStored > ((TileEntityPipe)connectedConsumer).steamStored)
{
transferElectricityAmount = Math.max(Math.min(averageElectricity - ((TileEntityPipe)connectedConsumer).steamStored, this.steamStored), 0);
}
else if(!(connectedConsumer instanceof TileEntityPipe))
{
transferElectricityAmount = this.steamStored;
}
int rejectedElectricity = connectedConsumer.onReceiveSteam(transferElectricityAmount, UniversalElectricity.getOrientationFromSide(i, (byte)2));
this.steamStored = Math.max(Math.min(this.steamStored - transferElectricityAmount + rejectedElectricity, this.capacity), 0);
}
}
if(connectedBlocks[i] instanceof ISteamProducer && this.steamStored < this.getSteamCapacity())
{
if(((ISteamProducer)connectedBlocks[i]).canProduceSteam(UniversalElectricity.getOrientationFromSide(i, (byte)2)))
{
int gainedElectricity = ((ISteamProducer)connectedBlocks[i]).onProduceSteam(this.capacity-this.steamStored, UniversalElectricity.getOrientationFromSide(i, (byte)2));
this.steamStored = Math.max(Math.min(this.steamStored + gainedElectricity, this.capacity), 0);
}
}
}
}
}
}
/**
* @return Return the stored electricity in this consumer. Called by conductors to spread electricity to this unit.
*/
@Override
public int getStoredSteam()
{
return this.steamStored;
}
@Override
public int getSteamCapacity()
{
return this.capacity;
}
/**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
this.steamStored = par1NBTTagCompound.getInteger("steamStored");
this.capacity = par1NBTTagCompound.getInteger("capacity");
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("steamStored", this.steamStored);
par1NBTTagCompound.setInteger("capacity", this.capacity);
}
}

View file

@ -0,0 +1,207 @@
package net.minecraft.src.eui.steam;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.TileEntity;
import net.minecraft.src.eui.api.IWaterConsumer;
import net.minecraft.src.eui.api.IWaterProducer;
import net.minecraft.src.universalelectricity.UniversalElectricity;
import net.minecraft.src.universalelectricity.Vector3;
public class TileEntityPipeWater extends TileEntity implements IWaterConsumer
{
//The amount of electricity stored in the conductor
protected int waterStored = 0;
//The maximum amount of electricity this conductor can take
protected int capacity = 5;
//Stores information on all connected blocks around this tile entity
public TileEntity[] connectedBlocks = {null, null, null, null, null, null};
//Checks if this is the first the tile entity updates
protected boolean firstUpdate = true;
/**
* The tile entity of the closest electric consumer. Null if none. Use this to detect if electricity
* should transfer
*/
public TileEntity closestConsumer = null;
/**
* This function adds a connection between this conductor and the UE unit
* @param tileEntity - Must be either a producer, consumer or a conductor
* @param side - side in which the connection is coming from
*/
public void addConnection(TileEntity tileEntity, byte side)
{
if(tileEntity instanceof IWaterConsumer || tileEntity instanceof IWaterProducer)
{
this.connectedBlocks[side] = tileEntity;
}
else
{
this.connectedBlocks[side] = null;
}
}
/**
* onRecieveElectricity is called whenever a Universal Electric conductor sends a packet of electricity to the consumer (which is this block).
* @param watts - The amount of watt this block recieved
* @param side - The side of the block in which the electricity came from
* @return watt - The amount of rejected power to be sent back into the conductor
*/
@Override
public int onReceiveWater(int watt, byte side)
{
int rejectedElectricity = Math.max((this.waterStored + watt) - this.capacity, 0);
this.waterStored += watt - rejectedElectricity;
return rejectedElectricity;
}
/**
* 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.
*/
@Override
public void updateEntity()
{
if(this.firstUpdate)
{
//Update some variables
BlockPipeWater conductorBlock = (BlockPipeWater)this.getBlockType();
this.capacity = (conductorBlock).conductorCapacity();
((BlockPipeWater)this.getBlockType()).updateConductorTileEntity(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
this.firstUpdate = false;
}
//Spread the electricity to neighboring blocks
byte connectedUnits = 0;
byte connectedConductors = 1;
int averageElectricity = this.waterStored;
this.closestConsumer = null;
Vector3 currentPosition = new Vector3(this.xCoord, this.yCoord, this.zCoord);
//Find the connected unit with the least amount of electricity and give more to them
for(byte i = 0; i < 6; i++)
{
if(connectedBlocks[i] != null)
{
if(connectedBlocks[i] instanceof IWaterConsumer)
{
connectedUnits ++;
if(connectedBlocks[i].getClass() == this.getClass())
{
averageElectricity += ((TileEntityPipeWater)connectedBlocks[i]).waterStored;
TileEntity tileEntity = ((TileEntityPipeWater)connectedBlocks[i]).closestConsumer;
if(tileEntity != null)
{
this.closestConsumer = tileEntity;
}
connectedConductors ++;
}
else if(connectedBlocks[i] instanceof IWaterConsumer)
{
if(((IWaterConsumer)connectedBlocks[i]).canRecieveWater(UniversalElectricity.getOrientationFromSide(i, (byte)2)))
{
this.closestConsumer = connectedBlocks[i];
}
}
}
}
}
averageElectricity = averageElectricity/connectedConductors;
float averageWatt = 0;
if(connectedUnits > 0)
{
for(byte i = 0; i < 6; i++)
{
if(connectedBlocks[i] != null)
{
//Spread the electricity among the different blocks
if(connectedBlocks[i] instanceof IWaterConsumer && this.waterStored > 0)
{
if(((IWaterConsumer)connectedBlocks[i]).canRecieveWater(UniversalElectricity.getOrientationFromSide(i, (byte) 2)))
{
int transferElectricityAmount = 0;
IWaterConsumer connectedConsumer = ((IWaterConsumer)connectedBlocks[i]);
if(connectedBlocks[i].getClass() == this.getClass() && this.waterStored > ((TileEntityPipeWater)connectedConsumer).waterStored)
{
transferElectricityAmount = Math.max(Math.min(averageElectricity - ((TileEntityPipeWater)connectedConsumer).waterStored, this.waterStored), 0);
}
else if(!(connectedConsumer instanceof TileEntityPipeWater))
{
transferElectricityAmount = this.waterStored;
}
int rejectedElectricity = connectedConsumer.onReceiveWater(transferElectricityAmount, UniversalElectricity.getOrientationFromSide(i, (byte)2));
this.waterStored = Math.max(Math.min(this.waterStored - transferElectricityAmount + rejectedElectricity, this.capacity), 0);
}
}
if(connectedBlocks[i] instanceof IWaterProducer && this.waterStored < this.getWaterCapacity())
{
if(((IWaterProducer)connectedBlocks[i]).canProduceWater(UniversalElectricity.getOrientationFromSide(i, (byte)2)))
{
int gainedElectricity = ((IWaterProducer)connectedBlocks[i]).onProduceWater(this.capacity-this.waterStored, UniversalElectricity.getOrientationFromSide(i, (byte)2));
this.waterStored = Math.max(Math.min(this.waterStored + gainedElectricity, this.capacity), 0);
}
}
}
}
}
}
/**
* @return Return the stored electricity in this consumer. Called by conductors to spread electricity to this unit.
*/
@Override
public int getStoredWater()
{
return this.waterStored;
}
@Override
public int getWaterCapacity()
{
return this.capacity;
}
/**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
this.waterStored = par1NBTTagCompound.getInteger("waterStored");
this.capacity = par1NBTTagCompound.getInteger("capacity");
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("waterStored", this.waterStored);
par1NBTTagCompound.setInteger("capacity", this.capacity);
}
@Override
public boolean canRecieveWater(byte side) {
// TODO Auto-generated method stub
return true;
}
}

View file

@ -0,0 +1,41 @@
package net.minecraft.src.eui.turbine;
import net.minecraft.src.*;
public class ContainerGenerator extends Container
{
private TileEntityGenerator tileEntity;
public ContainerGenerator(InventoryPlayer par1InventoryPlayer, TileEntityGenerator tileEntity)
{
this.tileEntity = tileEntity;
this.addSlot(new Slot(tileEntity, 0, 33, 34));
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));
}
}
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
{
return this.tileEntity.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

@ -0,0 +1,77 @@
package net.minecraft.src.eui.turbine;
import org.lwjgl.opengl.GL11;
import java.math.*;
import java.lang.Integer;
import net.minecraft.src.*;
import net.minecraft.src.universalelectricity.UniversalElectricity;
import net.minecraft.src.universalelectricity.components.ContainerCoalGenerator;
import net.minecraft.src.universalelectricity.components.TileEntityCoalGenerator;
public class GUIGenerator extends GuiContainer
{
private TileEntityGenerator tileEntity;
private int containerWidth;
private int containerHeight;
public GUIGenerator(InventoryPlayer par1InventoryPlayer, TileEntityGenerator tileEntity)
{
super(new ContainerGenerator(par1InventoryPlayer, tileEntity));
this.tileEntity = tileEntity;
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
protected void drawGuiContainerForegroundLayer()
{
this.fontRenderer.drawString("Steam Engine MkI", 55, 6, 4210752);
this.fontRenderer.drawString("MeterReadings", 90, 33, 4210752);
String displayText = "";
String displayText2 = "";
String displayText3 = "";
if(tileEntity.connectedWire == null)
{
displayText = "Not Connected";
}
else if(tileEntity.generateRate*20 <= 0)
{
if(tileEntity.steamStored> 0)
{
displayText = "Power Full";
}
if(tileEntity.steamStored<= 0)
{
displayText = "No Steam";
}
}
else if(tileEntity.generateRate*20 < 20)
{
displayText = "Warming UP: "+(int)(tileEntity.generateRate*100)+"%";
}
else
{
displayText = UniversalElectricity.getWattDisplay((int)(tileEntity.generateRate*20));
}
displayText2 = "water" + "-" + tileEntity.waterStored;
displayText3 = "steam" + "-" + tileEntity.steamStored;
this.fontRenderer.drawString(displayText, (int)(105-displayText.length()*1), 45, 4210752);
this.fontRenderer.drawString(displayText2, (int)(105-displayText.length()*1), 55, 4210752);
this.fontRenderer.drawString(displayText3, (int)(105-displayText.length()*1), 65, 4210752);
this.fontRenderer.drawString(StatCollector.translateToLocal("container.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/SteamGUI.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4);
containerWidth = (this.width - this.xSize) / 2;
containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
}
}

View file

@ -0,0 +1,305 @@
package net.minecraft.src.eui.turbine;
import net.minecraft.src.eui.TileEntityMachine;
import net.minecraft.src.eui.api.*;
import net.minecraft.src.forge.ForgeHooks;
import net.minecraft.src.*;
import net.minecraft.src.universalelectricity.*;
import net.minecraft.src.forge.ISidedInventory;
public class TileEntityGenerator extends TileEntityMachine implements UEIProducer,ISteamConsumer,IWaterProducer, IInventory, ISidedInventory
{
//Maximum possible generation rate of watts in SECONDS
public int maxGenerateRate = 1000;
public int waterStored = 0;
public int steamStored = 0;
public int steamConsumed = 0;
//Current generation rate based on hull heat. In TICKS.
public float generateRate = 0;
public UETileEntityConductor connectedWire = null;
/**
* The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for
*/
public int itemCookTime = 0;
/**
* The ItemStacks that hold the items currently being used in the battery box
*/
private ItemStack[] containingItems = new ItemStack[1];
@Override
public int onProduceElectricity(int maxWatts, int voltage, byte side)
{
//Only produce electricity on the back side.
if(canProduceElectricity(side) && maxWatts > 0)
{
return Math.min(maxWatts, (int)generateRate);
}
return 0;
}
@Override
public boolean canProduceElectricity(byte side)
{
return true;
}
/**
* 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()
{
//Check nearby blocks and see if the conductor is full. If so, then it is connected
TileEntity tileEntity = UEBlockConductor.getUEUnit(this.worldObj, this.xCoord, this.yCoord, this.zCoord, UniversalElectricity.getOrientationFromSide(this.getDirection(), (byte)2));
if(tileEntity instanceof UETileEntityConductor)
{
if(((UETileEntityConductor)tileEntity).closestConsumer != null)
{
this.connectedWire = (UETileEntityConductor)tileEntity;
}
else
{
this.connectedWire = null;
}
}
else
{
this.connectedWire = null;
}
if (!this.worldObj.isRemote)
{
//The top slot is for recharging items. Check if the item is a electric item. If so, recharge it.
if (this.containingItems[0] != null)
{
if(this.containingItems[0].getItem().shiftedIndex == Item.bucketEmpty.shiftedIndex)
{
if(this.waterStored > 0)
{
this.containingItems[0] = new ItemStack(Item.bucketWater,1);
--waterStored;
}
}
}
}
//Starts generating electricity if the device is heated up
if (this.itemCookTime > 0)
{
this.itemCookTime --;
if(this.connectedWire != null && this.connectedWire.getStoredElectricity() < this.connectedWire.getElectricityCapacity())
{
this.generateRate = (float)Math.min(this.generateRate+Math.min((this.generateRate)*0.01+0.015, 0.05F), this.maxGenerateRate/20);
}
}
else
{
if(steamStored > 0)
{
--steamStored;
++steamConsumed;
if(steamConsumed == mod_EUIndustry.steamOutBoiler)
{
++waterStored;
steamConsumed = 0;
}
itemCookTime = itemCookTime + 65;
}
}
if(this.connectedWire == null || this.itemCookTime <= 0)
{
this.generateRate = (float)Math.max(this.generateRate-0.05, 0);
}
}
/**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
this.itemCookTime = par1NBTTagCompound.getInteger("itemCookTime");
this.waterStored = par1NBTTagCompound.getInteger("waterStored");
this.steamConsumed = par1NBTTagCompound.getInteger("steamConsumed");
this.steamStored = par1NBTTagCompound.getInteger("steamStored");
this.generateRate = par1NBTTagCompound.getFloat("generateRate");
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
this.containingItems = 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.containingItems.length)
{
this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("itemCookTime", (int)this.itemCookTime);
par1NBTTagCompound.setInteger("waterStored", (int)this.waterStored);
par1NBTTagCompound.setInteger("steamConsumed", (int)this.steamConsumed);
par1NBTTagCompound.setInteger("steamStored", (int)this.steamStored);
par1NBTTagCompound.setFloat("generateRate", (int)this.generateRate);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.containingItems.length; ++var3)
{
if (this.containingItems[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
this.containingItems[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
par1NBTTagCompound.setTag("Items", var2);
}
@Override
public int getStartInventorySide(int side)
{
if (side == 0)
{
return 1;
}
if (side == 1)
{
return 0;
}
return 2;
}
@Override
public int getSizeInventorySide(int side) { return getSizeInventory(); }
@Override
public int getSizeInventory() { return this.containingItems.length; }
@Override
public ItemStack getStackInSlot(int par1) { return this.containingItems[par1]; }
@Override
public ItemStack decrStackSize(int par1, int par2)
{
if (this.containingItems[par1] != null)
{
ItemStack var3;
if (this.containingItems[par1].stackSize <= par2)
{
var3 = this.containingItems[par1];
this.containingItems[par1] = null;
return var3;
}
else
{
var3 = this.containingItems[par1].splitStack(par2);
if (this.containingItems[par1].stackSize == 0)
{
this.containingItems[par1] = null;
}
return var3;
}
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int par1)
{
if (this.containingItems[par1] != null)
{
ItemStack var2 = this.containingItems[par1];
this.containingItems[par1] = null;
return var2;
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{
this.containingItems[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public String getInvName() {
return "SteamGen";
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
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;
}
@Override
public void openChest() { }
@Override
public void closeChest() { }
@Override
public int onReceiveSteam(int vol, byte side) {
if(steamStored + vol <= 100)
{
steamStored = steamStored + vol;
return 0;
}
return vol;
}
@Override
public boolean canRecieveSteam(byte side) {
return true;
}
@Override
public int getStoredSteam() {
return this.steamStored;
}
@Override
public int getSteamCapacity() {
return 100;
}
@Override
public int onProduceWater(int maxVol, int side) {
if(this.waterStored > 0)
{
--waterStored;
return 1;
}
return 0;
}
@Override
public boolean canProduceWater(byte side) {
return true;
}
@Override
public int getVolts() {
// TODO Auto-generated method stub
return 120;
}
}

View file

@ -0,0 +1,132 @@
package net.minecraft.src;
import net.minecraft.client.Minecraft;
import net.minecraft.src.eui.*;
import net.minecraft.src.eui.steam.RenderPipe;
import net.minecraft.src.eui.steam.RenderPipeWater;
import net.minecraft.src.forge.*;
import net.minecraft.src.universalelectricity.*;
import net.minecraft.src.universalelectricity.components.UniversalComponents;
import java.util.ArrayList;
import java.util.Map;
import java.io.*;
public class mod_EUIndustry extends NetworkMod {
static Configuration config = new Configuration((new File(Minecraft.getMinecraftDir(), "config/EUIndustry/SteamPower.cfg")));
private static int coalID = configurationProperties();
private static int BlockID;
public static int pipeID;
public static int partID;
public static int pipeBlockID;
public static int pipeBlockID2;
public static int genOutput;
public static int steamOutBoiler;
public static int pipeLoss;
public static int boilerHeat;
public static int fireOutput;
public static Block machine = new net.minecraft.src.eui.BlockMachine(BlockID).setBlockName("machine");
public static Block pipe = new net.minecraft.src.eui.steam.BlockPipe(pipeBlockID).setBlockName("pipe");
public static Block pipeW = new net.minecraft.src.eui.steam.BlockPipeWater(pipeBlockID2).setBlockName("pipeW");
public static Item coalNugget = new net.minecraft.src.eui.ItemCoalFuel(coalID);
public static Item pipeItem = new net.minecraft.src.eui.steam.ItemPipe(pipeID);
public static Item parts = new net.minecraft.src.eui.ItemParts(partID);
@Override
public String getVersion() {
// TODO change version on each update ;/
return "0.0.4";
}
public static int configurationProperties()
{
config.load();
coalID = Integer.parseInt(config.getOrCreateIntProperty("coalItems", Configuration.CATEGORY_ITEM, 30439).value);
pipeBlockID = Integer.parseInt(config.getOrCreateIntProperty("PipeS", Configuration.CATEGORY_BLOCK, 128).value);
pipeBlockID2 = Integer.parseInt(config.getOrCreateIntProperty("PipeW", Configuration.CATEGORY_BLOCK, 130).value);
BlockID = Integer.parseInt(config.getOrCreateIntProperty("Machines", Configuration.CATEGORY_BLOCK, 129).value);
pipeID = Integer.parseInt(config.getOrCreateIntProperty("pipes", Configuration.CATEGORY_ITEM, 30433).value);
partID = Integer.parseInt(config.getOrCreateIntProperty("parts", Configuration.CATEGORY_ITEM, 30434).value);
genOutput = Integer.parseInt(config.getOrCreateIntProperty("genOutputWatts", Configuration.CATEGORY_GENERAL, 1000).value);
steamOutBoiler = Integer.parseInt(config.getOrCreateIntProperty("steamOutBoiler", Configuration.CATEGORY_GENERAL, 10).value);
boilerHeat = Integer.parseInt(config.getOrCreateIntProperty("boilerInKJ", Configuration.CATEGORY_GENERAL, 4500).value);
fireOutput = Integer.parseInt(config.getOrCreateIntProperty("fireBoxOutKJ", Configuration.CATEGORY_GENERAL,50).value);
config.save();
return coalID;
}
@Override
public void load() {
//register
UniversalElectricity.registerAddon(this, "0.2.0");
MinecraftForgeClient.preloadTexture("/eui/Blocks.png");
MinecraftForgeClient.preloadTexture("/eui/Items.png");
//Blocks
//gen
//machine
ModLoader.registerBlock(machine,net.minecraft.src.eui.ItemMachine.class);
ModLoader.registerBlock(pipe);
ModLoader.registerBlock(pipeW);
ModLoader.addName((new ItemStack(pipeItem, 1, 0)), "SteamPipe");
ModLoader.addName((new ItemStack(pipeItem, 1, 1)), "WaterPipe");
ModLoader.addName((new ItemStack(machine, 1, 0)), "CoalRefiner");
ModLoader.addName((new ItemStack(machine, 1, 1)), "Boiler");
ModLoader.addName((new ItemStack(machine, 1, 2)), "FireBox");
ModLoader.addName((new ItemStack(machine, 1, 3)), "SteamGen");
ModLoader.addName((new ItemStack(machine, 1, 14)), "WaterCondenser");
ModLoader.addName((new ItemStack(machine, 1, 15)), "EUVampire");
ModLoader.registerTileEntity(net.minecraft.src.eui.grinder.TileEntityGrinder.class, "grinder",new UEBlockRenderer());
ModLoader.registerTileEntity(net.minecraft.src.eui.boiler.TileEntityBoiler.class, "boiler",new UEBlockRenderer());
ModLoader.registerTileEntity(net.minecraft.src.eui.burner.TileEntityFireBox.class, "fireBox",new UEBlockRenderer());
ModLoader.registerTileEntity(net.minecraft.src.eui.turbine.TileEntityGenerator.class, "generator",new UEBlockRenderer());
ModLoader.registerTileEntity(net.minecraft.src.eui.TileEntityCondenser.class, "waterPump",new UEBlockRenderer());
ModLoader.registerTileEntity(net.minecraft.src.eui.TileEntityNuller.class, "EUNuller",new UEBlockRenderer());
ModLoader.registerTileEntity(net.minecraft.src.eui.steam.TileEntityPipe.class, "pipe", new RenderPipe());
ModLoader.registerTileEntity(net.minecraft.src.eui.steam.TileEntityPipeWater.class, "pipeW", new RenderPipeWater());
//Items
ModLoader.addName((new ItemStack(coalNugget, 1, 0)), "CoalNuggets");
ModLoader.addName((new ItemStack(coalNugget, 1, 1)), "CoalPellets");
ModLoader.addName((new ItemStack(coalNugget, 1, 2)), "CoalDust");
ModLoader.addName((new ItemStack(parts, 1, 1)), "Tank");
ModLoader.addName((new ItemStack(parts, 1, 3)), "Valve");
ModLoader.addName((new ItemStack(parts, 1, 4)), "Tube");
ModLoader.addName((new ItemStack(parts, 1, 5)), "Seal");
ModLoader.addName((new ItemStack(parts, 1, 6)), "Rivits");
ModLoader.addName(pipeItem, "SteamPipe");
//fuels
ModLoader.addAllFuel((new ItemStack(coalNugget, 1, 0).itemID), 1000);
//Crafting
ModLoader.addRecipe(new ItemStack(machine, 1, 0), new Object [] {"@S@", "SCW", "@S@",
'S',UniversalComponents.ItemSteelIngot,
'@',new ItemStack(UniversalComponents.ItemSteelPlate),
'C',new ItemStack(UniversalComponents.ItemCircuit,1,1),
'W',UniversalComponents.ItemCopperWire});
ModLoader.addRecipe(new ItemStack(machine, 1, 1), new Object [] {"@T@", "OVO", "@T@",
'T',new ItemStack(parts, 1,1),
'@',new ItemStack(UniversalComponents.ItemSteelPlate),
'O',new ItemStack(parts, 1,4),
'V',new ItemStack(parts, 1,3)});
ModLoader.addRecipe(new ItemStack(machine, 1, 2), new Object [] { "@", "F",
'F',Block.stoneOvenIdle,
'@',new ItemStack(UniversalComponents.ItemSteelPlate)});
ModLoader.addRecipe(new ItemStack(machine, 1, 3), new Object [] {"@T@", "PMP", "@T@",
'T',new ItemStack(parts, 1,4),
'@',new ItemStack(UniversalComponents.ItemSteelPlate),
'P',Block.pistonBase,
'M',new ItemStack(UniversalComponents.ItemMotor)});
ModLoader.addShapelessRecipe(new ItemStack(pipeItem, 4), new Object[] { new ItemStack(parts, 1,6),new ItemStack(parts, 1,4),new ItemStack(UniversalComponents.ItemCopperIngot, 1)});
ModLoader.addShapelessRecipe(new ItemStack(pipeItem, 4), new Object[] { new ItemStack(parts, 1,4),new ItemStack(Block.glass, 1),new ItemStack(UniversalComponents.ItemCopperIngot, 1)});
//crafting parts
ModLoader.addShapelessRecipe(new ItemStack(parts, 2,1), new Object[] { new ItemStack(UniversalComponents.ItemCopperIngot, 1),
new ItemStack(UniversalComponents.ItemCopperIngot, 1),new ItemStack(UniversalComponents.ItemCopperIngot, 1),
new ItemStack(UniversalComponents.ItemCopperIngot, 1), new ItemStack(parts,1,6)});
ModLoader.addRecipe(new ItemStack(parts, 2, 3), new Object [] {" S ", "TTT", " ", 'T',
new ItemStack(parts, 8, 4),'S',UniversalComponents.ItemSteelIngot});
ModLoader.addRecipe(new ItemStack(parts, 8, 4), new Object [] {"@@@", " ", "@@@", '@',
UniversalComponents.ItemBronzeIngot});
ModLoader.addRecipe(new ItemStack(parts, 8, 5), new Object [] {"@@@", "@ @", "@@@", '@',
Item.leather});
ModLoader.addShapelessRecipe(new ItemStack(parts, 4,6), new Object[] { new ItemStack(UniversalComponents.ItemCopperIngot, 1)});
//smelting
}
}