resonant-induction/common/dark/BasicUtilities/machines/TileEntityValve.java
Rseifert 680203f2b6 more rewriting of the base mod
most of this is just continued rewrites in an attempt to better the mod.
Some of the basic changes are:
removed HeatProducer / merged it with IProducer
removed Liquid from some of the interfaces name
renamed IMehcanical to IForce
moved around files
add generator from steampower to where it should be
and finally normal ctrl+shift+f formating
2012-12-02 00:30:56 -05:00

109 lines
2.1 KiB
Java

package dark.BasicUtilities.machines;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import dark.BasicUtilities.api.IConsumer;
import dark.BasicUtilities.api.Liquid;
import dark.BasicUtilities.api.MHelper;
import dark.BasicUtilities.pipes.TileEntityPipe;
public class TileEntityValve extends TileEntity implements IConsumer {
Liquid type = Liquid.DEFUALT;
int liquidStored = 0;
int lMax = 1;
int tickCount = 0;
TileEntity[] connected = {null,null,null,null,null,null};
boolean on = false;
@Override
public void updateEntity()
{
tickCount++;
if(tickCount >= 10)
{
int deltaX = 0;
int deltaZ = 0;
int deltaY = 0;
int facing = 0;
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
if(meta == 0 && meta == 8)
{
facing = 2;
}
if(meta == 1 && meta == 9)
{
facing = 5;
}
if(meta == 2 && meta == 10)
{
facing = 3;
}
if(meta == 3 && meta == 11)
{
facing = 4;
}
if((meta > 3 && meta < 8)&&(meta> 11 && meta < 16))
{
facing = 0;
}
switch(facing)
{
case 0: deltaY++;break;
case 1: deltaY--;break;
case 2: deltaZ--;break;
case 5: deltaZ++;break;
case 3: deltaX--;break;
case 4: deltaX++;break;
}
connected = MHelper.getSourounding(worldObj,xCoord, yCoord, zCoord);
for(int i = 0;i<6;i++)
{
if(!(connected[i] instanceof TileEntityPipe))
{
connected[i] = null;
}
}
if(!worldObj.isRemote)
{
//TODO send packet
}
tickCount = 0;
}
}
@Override
public int onReceiveLiquid(Liquid type, int vol, ForgeDirection side) {
if(this.type == Liquid.DEFUALT)
{
this.type = type;
}
return vol;
}
@Override
public boolean canRecieveLiquid(Liquid type, ForgeDirection forgeDirection) {
if(type == this.type)
{
return true;
}
return false;
}
@Override
public int getStoredLiquid(Liquid type) {
if(type == this.type)
{
return liquidStored;
}
return 0;
}
@Override
public int getLiquidCapacity(Liquid type) {
if(type == this.type)
{
return lMax;
}
return 0;
}
}