getting Closer to being done
I'm getting closer to making this mod more universal for all liquids. Right now after a bit of coding i can say i have: *Fixed Pipes *Fixed Tanks *Removed Mengenta as a color(no need for another simi red/pinkish color) *Create a IColor interface for future use with other color selective blocks *Created a object feed version of get for PipeColor so you can use numbers, Strings, or LiquidData to ID a color. Useful for setColor(Object obj) *Worked on some textures however i need to either make a better model for tanks or find a texture artist for help *Found the tank model files so they can be edited Issues still to be worked on *Lang file, still item names are not working *Release Valve *Pipe Changer tool, not sure if i should use a GUI with the tool or have 15 color brushs. The ladder seems wasteful *Block, and bucket for Waste Liquid *Textures need some help, especial Tanks so i can add the rest of the colored version to the creative menu *Crafting for all Pipes, Tanks, and items need redone or added for the new system *Pumps needs reworked to have a diffrent version for lava,water, and large area pumping. Small version for filling system, large for draining source pools for constuction. Lava pump will fall under large. Might add an oil pump, or create one for oil craft using the same design. *Tanks still need to be tested and fixed to create pressure for Pipes if side == down and liquid || side == up and gas *LiquidHandler needs worked on to pre catch and add liquids to the allowed List similar to how e methain, oil, fuel are register.
16
minecraft/liquidmechanics/api/IColor.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package liquidmechanics.api;
|
||||
|
||||
import liquidmechanics.api.helpers.PipeColor;
|
||||
|
||||
public interface IColor
|
||||
{
|
||||
/**
|
||||
* gets the pipeColor being used by this object
|
||||
*/
|
||||
public PipeColor getColor();
|
||||
/**
|
||||
* sets the pipeColor to be used by this object *
|
||||
* @param obj-can be anything must be sorted
|
||||
*/
|
||||
public void setColor(Object obj);
|
||||
}
|
|
@ -5,25 +5,26 @@ import liquidmechanics.common.handlers.LiquidHandler;
|
|||
|
||||
public enum PipeColor
|
||||
{
|
||||
BLACK("Black"),
|
||||
RED("Red"),
|
||||
GREEN("Green"),
|
||||
BLACK("Black"),
|
||||
RED("Red"),
|
||||
GREEN("Green"),
|
||||
BROWN("Brown"),
|
||||
BLUE("Blue"),
|
||||
PURPLE("Purple"),
|
||||
CYAN("Cyan"),
|
||||
BLUE("Blue"),
|
||||
PURPLE("Purple"),
|
||||
CYAN("Cyan"),
|
||||
SILVER("Silver"),
|
||||
GREY("Grey"),
|
||||
PINK("Pink"),
|
||||
LIME("Lime"),
|
||||
GREY("Grey"),
|
||||
PINK("Pink"),
|
||||
LIME("Lime"),
|
||||
YELLOW("Yellow"),
|
||||
LIGHTBLUE("LightBlue"),
|
||||
MAGENTA("Magenta"),
|
||||
ORANGE("Orange"),
|
||||
LIGHTBLUE("LightBlue"),
|
||||
WHITE("White"),
|
||||
ORANGE("Orange"),
|
||||
NONE("");
|
||||
|
||||
String name;
|
||||
|
||||
PipeColor(String name)
|
||||
private PipeColor(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -33,9 +34,37 @@ public enum PipeColor
|
|||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the liquidData linked with this color
|
||||
*/
|
||||
/** gets a pipeColor from any of the following
|
||||
*
|
||||
* @param obj
|
||||
* - Integer,String,LiquidData,PipeColor
|
||||
* @return Color NONE if it can't find it */
|
||||
public static PipeColor get(Object obj)
|
||||
{
|
||||
if (obj instanceof Integer && ((Integer) obj) < PipeColor.values().length)
|
||||
{
|
||||
return PipeColor.values()[((Integer) obj)];
|
||||
} else if (obj instanceof LiquidData)
|
||||
{
|
||||
LiquidData data = (LiquidData) obj;
|
||||
if (data == LiquidHandler.lava) { return RED; }
|
||||
if (data == LiquidHandler.steam) { return ORANGE; }
|
||||
if (data == LiquidHandler.water) { return BLUE; }
|
||||
} else if (obj instanceof PipeColor)
|
||||
{
|
||||
return (PipeColor) obj;
|
||||
} else if (obj instanceof String)
|
||||
{
|
||||
for (int i = 0; i < PipeColor.values().length; i++)
|
||||
{
|
||||
if (((String) obj).equalsIgnoreCase(PipeColor.get(i).getName())) { return PipeColor.get(i); }
|
||||
}
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
|
||||
/** gets the liquidData linked with this color. in rare cases there could be
|
||||
* more than one, but first instance will be returned */
|
||||
public LiquidData getLiquidData()
|
||||
{
|
||||
for (LiquidData data : LiquidHandler.allowedLiquids)
|
||||
|
@ -44,24 +73,4 @@ public enum PipeColor
|
|||
}
|
||||
return LiquidHandler.unkown;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a color based on liquid Data
|
||||
*/
|
||||
public static PipeColor get(LiquidData data)
|
||||
{
|
||||
if (data == LiquidHandler.lava) { return RED; }
|
||||
if (data == LiquidHandler.steam) { return ORANGE; }
|
||||
if (data == LiquidHandler.water) { return BLUE; }
|
||||
return NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a color based on number(0-15)
|
||||
*/
|
||||
public static PipeColor get(int num)
|
||||
{
|
||||
if (num < PipeColor.values().length) { return PipeColor.values()[num]; }
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package liquidmechanics.client.render;
|
||||
|
||||
import liquidmechanics.api.helpers.PipeColor;
|
||||
import liquidmechanics.api.helpers.connectionHelper;
|
||||
import liquidmechanics.client.model.ModelLiquidTank;
|
||||
import liquidmechanics.client.model.ModelLiquidTankCorner;
|
||||
|
@ -29,7 +30,16 @@ public class RenderTank extends TileEntitySpecialRenderer
|
|||
public void renderAModelAt(TileEntityTank te, double d, double d1, double d2, float f)
|
||||
{
|
||||
int meta = te.getBlockMetadata();
|
||||
pos = Math.min((te.volume / LiquidContainerRegistry.BUCKET_VOLUME), 4);
|
||||
int guageMeta = meta;
|
||||
if(te.tank.getLiquid() != null)
|
||||
{
|
||||
pos = Math.min((te.tank.getLiquid().amount / LiquidContainerRegistry.BUCKET_VOLUME), 4);
|
||||
if(meta == PipeColor.NONE.ordinal())
|
||||
{
|
||||
guageMeta = PipeColor.get(te.tank.getLiquid()).ordinal();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
|
||||
|
@ -60,7 +70,7 @@ public class RenderTank extends TileEntitySpecialRenderer
|
|||
{
|
||||
bindTextureByName(this.getTankTexture(meta));
|
||||
model.renderMain(0.0625F);
|
||||
bindTextureByName(this.getGuageTexture(meta, pos));
|
||||
bindTextureByName(this.getGuageTexture(guageMeta, pos));
|
||||
model.renderMeter(te, 0.0625F);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
|
@ -71,13 +81,22 @@ public class RenderTank extends TileEntitySpecialRenderer
|
|||
{
|
||||
String type = "";
|
||||
switch (meta)
|
||||
{
|
||||
case 1:type = "Red";break;
|
||||
case 14:type = "Orange";break;
|
||||
default:type = "";break;
|
||||
{
|
||||
case 1:
|
||||
type = "Lava";
|
||||
break;
|
||||
case 4:
|
||||
type = "Water";
|
||||
break;
|
||||
case 14:
|
||||
type = "Steam";
|
||||
break;
|
||||
default:
|
||||
type = "";
|
||||
break;
|
||||
}
|
||||
|
||||
return LiquidMechanics.RESOURCE_PATH + "tanks/" + type + "Tank.png";
|
||||
return LiquidMechanics.RESOURCE_PATH + "tanks/" + type + "Tank.png";
|
||||
|
||||
}
|
||||
|
||||
|
@ -86,8 +105,12 @@ public class RenderTank extends TileEntitySpecialRenderer
|
|||
String type = "";
|
||||
switch (meta)
|
||||
{
|
||||
case 1:type = "Lava";break;
|
||||
case 12:type = "Fuel";break;
|
||||
case 1:
|
||||
type = "Lava";
|
||||
break;
|
||||
case 12:
|
||||
type = "Fuel";
|
||||
break;
|
||||
default:
|
||||
type = "";
|
||||
break;
|
||||
|
|
|
@ -89,14 +89,21 @@ public class LiquidHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* gets a liquid stack of type & volume
|
||||
* creates a new LiquidStack using type and vol
|
||||
*/
|
||||
public static LiquidStack getStack(LiquidData type, int vol)
|
||||
{
|
||||
if (type == null) return null;
|
||||
return new LiquidStack(type.getStack().itemID, vol, type.getStack().itemMeta);
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new LiquidStack using a liquidStack and vol
|
||||
*/
|
||||
public static LiquidStack getStack(LiquidStack stack, int vol)
|
||||
{
|
||||
if(stack == null){return null;}
|
||||
return new LiquidStack(stack.itemID,vol,stack.itemMeta);
|
||||
}
|
||||
public static int getMeta(LiquidData type)
|
||||
{
|
||||
if (type == LiquidHandler.steam) return 0;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package liquidmechanics.common.tileentity;
|
||||
|
||||
import liquidmechanics.api.IColor;
|
||||
import liquidmechanics.api.IReadOut;
|
||||
import liquidmechanics.api.IPressure;
|
||||
import liquidmechanics.api.helpers.PipeColor;
|
||||
|
@ -27,7 +28,7 @@ import universalelectricity.prefab.network.PacketManager;
|
|||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntityPipe extends TileEntity implements ITankContainer, IReadOut
|
||||
public class TileEntityPipe extends TileEntity implements ITankContainer, IReadOut,IColor
|
||||
{
|
||||
private PipeColor color = PipeColor.NONE;
|
||||
|
||||
|
@ -59,24 +60,23 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
|||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
||||
int moved = 0;
|
||||
|
||||
if (connectedBlocks[i] instanceof ITankContainer)
|
||||
{
|
||||
if (connectedBlocks[i] instanceof TileEntityPipe)
|
||||
{
|
||||
if (((TileEntityPipe) connectedBlocks[i]).presure < this.presure)
|
||||
{
|
||||
moved = ((TileEntityPipe) connectedBlocks[i]).stored.fill(stack, true);
|
||||
stored.drain(((TileEntityPipe) connectedBlocks[i]).stored.fill(stack, true), true);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
moved = ((ITankContainer) connectedBlocks[i]).fill(dir.getOpposite(), stack, true);
|
||||
stored.drain(((ITankContainer) connectedBlocks[i]).fill(dir.getOpposite(), stack, true), true);
|
||||
}
|
||||
}
|
||||
stored.drain(moved, true);
|
||||
// FMLLog.warning("Moved "+moved+ " "+ i);
|
||||
|
||||
if (stack == null || stack.amount <= 0)
|
||||
{
|
||||
break;
|
||||
|
@ -90,6 +90,7 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
|||
/**
|
||||
* gets the current color mark of the pipe
|
||||
*/
|
||||
@Override
|
||||
public PipeColor getColor()
|
||||
{
|
||||
return this.color;
|
||||
|
@ -98,9 +99,10 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
|||
/**
|
||||
* sets the current color mark of the pipe
|
||||
*/
|
||||
public void setColor(PipeColor cc)
|
||||
@Override
|
||||
public void setColor(Object cc)
|
||||
{
|
||||
this.color = cc;
|
||||
this.color = PipeColor.get(cc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,6 +124,7 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
|||
{
|
||||
super.readFromNBT(nbt);
|
||||
UpdateConverter.convert(this, nbt);
|
||||
|
||||
LiquidStack liquid = new LiquidStack(0, 0, 0);
|
||||
liquid.readFromNBT(nbt.getCompoundTag("stored"));
|
||||
stored.setLiquid(liquid);
|
||||
|
@ -251,16 +254,14 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
|||
TileEntity ent = connectedBlocks[i];
|
||||
if (ent instanceof ITankContainer)
|
||||
{
|
||||
if (this.color != PipeColor.NONE)
|
||||
if (ent instanceof TileEntityPipe && color != ((TileEntityPipe) ent).getColor())
|
||||
{
|
||||
if (ent instanceof TileEntityPipe && color != ((TileEntityPipe) ent).getColor())
|
||||
{
|
||||
connectedBlocks[i] = null;
|
||||
}
|
||||
else if (ent instanceof TileEntityTank && color != ((TileEntityTank) ent).getColor())
|
||||
{
|
||||
connectedBlocks[i] = null;
|
||||
}
|
||||
connectedBlocks[i] = null;
|
||||
}
|
||||
|
||||
if (this.color != PipeColor.NONE && ent instanceof TileEntityTank && color != ((TileEntityTank) ent).getColor())
|
||||
{
|
||||
connectedBlocks[i] = null;
|
||||
}
|
||||
}
|
||||
else if (ent instanceof IPressure)
|
||||
|
|
|
@ -2,6 +2,7 @@ package liquidmechanics.common.tileentity;
|
|||
|
||||
import javax.swing.colorchooser.ColorSelectionModel;
|
||||
|
||||
import liquidmechanics.api.IColor;
|
||||
import liquidmechanics.api.IReadOut;
|
||||
import liquidmechanics.api.IPressure;
|
||||
import liquidmechanics.api.helpers.PipeColor;
|
||||
|
@ -28,28 +29,21 @@ import universalelectricity.prefab.network.PacketManager;
|
|||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntityTank extends TileEntity implements IPacketReceiver, IReadOut, IPressure, ITankContainer
|
||||
public class TileEntityTank extends TileEntity implements IPacketReceiver, IReadOut, IPressure, ITankContainer, IColor
|
||||
{
|
||||
public TileEntity[] cc = { null, null, null, null, null, null };
|
||||
|
||||
public LiquidData type = LiquidHandler.unkown;
|
||||
|
||||
private PipeColor color = PipeColor.NONE;
|
||||
|
||||
public static final int LMax = 4;
|
||||
private int count, count2 = 0;
|
||||
|
||||
public int volume;
|
||||
public int pVolume = 0;
|
||||
|
||||
public int pVolume = 0;
|
||||
|
||||
public LiquidTank tank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME * LMax);
|
||||
|
||||
public void updateEntity()
|
||||
{
|
||||
if (tank.getLiquid() == null && type != LiquidHandler.unkown)
|
||||
{
|
||||
tank.setLiquid(LiquidHandler.getStack(this.type, 1));
|
||||
}
|
||||
|
||||
LiquidStack liquid = tank.getLiquid();
|
||||
this.color = PipeColor.get(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
|
@ -59,15 +53,18 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
|||
this.cc = connectionHelper.getSurroundings(worldObj, xCoord, yCoord, zCoord);
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
this.type = color.getLiquidData();
|
||||
|
||||
this.tradeDown();
|
||||
this.tradeArround();
|
||||
volume = liquid.amount;
|
||||
int volume = liquid.amount;
|
||||
|
||||
if (volume != pVolume)
|
||||
{
|
||||
Packet packet = PacketManager.getPacket(LiquidMechanics.CHANNEL, this, new Object[] { volume });
|
||||
LiquidStack stack = new LiquidStack(0,0,0);
|
||||
if(this.tank.getLiquid() != null)
|
||||
{
|
||||
stack = this.tank.getLiquid();
|
||||
}
|
||||
Packet packet = PacketManager.getPacket(LiquidMechanics.CHANNEL, this, new Object[] {stack.itemID,stack.amount,stack.itemMeta});
|
||||
PacketManager.sendPacketToClients(packet, worldObj, new Vector3(this), 20);
|
||||
}
|
||||
pVolume = volume;
|
||||
|
@ -79,8 +76,9 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
|||
@Override
|
||||
public String getMeterReading(EntityPlayer user, ForgeDirection side)
|
||||
{
|
||||
if (volume == 0) { return "Empty"; }
|
||||
return (volume / LiquidContainerRegistry.BUCKET_VOLUME) + "/" + (tank.getCapacity() / LiquidContainerRegistry.BUCKET_VOLUME) + " " + type.getName();
|
||||
if (tank.getLiquid() == null) { return "Empty"; }
|
||||
return (tank.getLiquid().amount/ LiquidContainerRegistry.BUCKET_VOLUME) + "/" + (tank.getCapacity() / LiquidContainerRegistry.BUCKET_VOLUME)
|
||||
+ " " + LiquidHandler.get(tank.getLiquid()).getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -88,6 +86,7 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
|||
{
|
||||
super.readFromNBT(nbt);
|
||||
UpdateConverter.convert(this, nbt);
|
||||
|
||||
LiquidStack liquid = new LiquidStack(0, 0, 0);
|
||||
liquid.readFromNBT(nbt.getCompoundTag("stored"));
|
||||
tank.setLiquid(liquid);
|
||||
|
@ -108,7 +107,7 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
|||
{
|
||||
try
|
||||
{
|
||||
this.volume = data.readInt();
|
||||
this.tank.setLiquid(new LiquidStack(data.readInt(),data.readInt(),data.readInt()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -118,32 +117,18 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
|||
|
||||
}
|
||||
|
||||
// ----------------------------
|
||||
// Liquid stuff
|
||||
// ----------------------------
|
||||
public void setType(LiquidData dm)
|
||||
{
|
||||
this.type = dm;
|
||||
|
||||
}
|
||||
|
||||
public LiquidData getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null || !LiquidHandler.isEqual(resource, type)) { return 0; }
|
||||
if (resource == null || (!LiquidHandler.isEqual(resource, color.getLiquidData().getStack())&& this.color != PipeColor.NONE)) { return 0; }
|
||||
return this.fill(0, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null || tankIndex != 0)
|
||||
return 0;
|
||||
if (resource == null || tankIndex != 0) { return 0; }
|
||||
|
||||
if (this.isFull())
|
||||
{
|
||||
int change = 1;
|
||||
|
@ -152,60 +137,21 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
|||
change = -1;
|
||||
}
|
||||
TileEntity tank = worldObj.getBlockTileEntity(xCoord, yCoord + change, zCoord);
|
||||
if (tank instanceof TileEntityTank) { return ((TileEntityTank) tank).fill(0,resource, doFill); }
|
||||
if (tank instanceof TileEntityTank) { return ((TileEntityTank) tank).fill(0, resource, doFill); }
|
||||
}
|
||||
return this.tank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
/**
|
||||
* find out if this tank is actual full or not
|
||||
/** find out if this tank is actual full or not
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
* @return */
|
||||
public boolean isFull()
|
||||
{
|
||||
if (this.tank.getLiquid() == null)
|
||||
return false;
|
||||
if (this.tank.getLiquid().amount > 0 && this.tank.getLiquid().amount < this.tank.getCapacity())
|
||||
return false;
|
||||
if (this.tank.getLiquid() == null) { return false; }
|
||||
if (this.tank.getLiquid().amount > 0 && this.tank.getLiquid().amount < this.tank.getCapacity()) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* finds the first fillable tank in either direction
|
||||
*
|
||||
* @param top
|
||||
* - search up
|
||||
* @return
|
||||
*/
|
||||
public TileEntityTank getFillAbleTank(boolean top)
|
||||
{
|
||||
TileEntityTank tank = this;
|
||||
boolean stop = false;
|
||||
int y = tank.yCoord;
|
||||
while (y > 6 && y < 255)
|
||||
{
|
||||
if (top)
|
||||
{
|
||||
y += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
y -= 1;
|
||||
}
|
||||
TileEntity ent = tank.worldObj.getBlockTileEntity(xCoord, y, zCoord);
|
||||
if (ent instanceof TileEntityTank && ((TileEntityTank) ent).getType() == this.type && !((TileEntityTank) ent).isFull())
|
||||
{
|
||||
tank = (TileEntityTank) ent;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return tank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
|
@ -215,11 +161,11 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
|||
@Override
|
||||
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (tankIndex != 0) { return null; }
|
||||
if (tankIndex != 0 || this.tank.getLiquid() == null) { return null; }
|
||||
LiquidStack stack = this.tank.getLiquid();
|
||||
if (maxDrain <= this.tank.getLiquid().amount)
|
||||
if (maxDrain < this.tank.getLiquid().amount)
|
||||
{
|
||||
stack = LiquidHandler.getStack(type, maxDrain);
|
||||
stack = LiquidHandler.getStack(stack, maxDrain);
|
||||
}
|
||||
if (doDrain)
|
||||
{
|
||||
|
@ -243,7 +189,7 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
|||
@Override
|
||||
public int presureOutput(LiquidData type, ForgeDirection dir)
|
||||
{
|
||||
if (type == this.type)
|
||||
if (type == color.getLiquidData() || type == LiquidHandler.unkown)
|
||||
{
|
||||
if (type.getCanFloat() && dir == ForgeDirection.DOWN)
|
||||
return type.getPressure();
|
||||
|
@ -256,7 +202,7 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
|||
@Override
|
||||
public boolean canPressureToo(LiquidData type, ForgeDirection dir)
|
||||
{
|
||||
if (type == this.type)
|
||||
if (type == color.getLiquidData() || type == LiquidHandler.unkown)
|
||||
{
|
||||
if (type.getCanFloat() && dir == ForgeDirection.DOWN)
|
||||
return true;
|
||||
|
@ -266,32 +212,30 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* cause this TE to trade liquid down if the liquid is in liquid state or up
|
||||
* if in gas state.
|
||||
*/
|
||||
/** cause this TE to trade liquid down if the liquid is in liquid state or up
|
||||
* if in gas state. */
|
||||
public void tradeDown()
|
||||
{
|
||||
if (this.tank.getLiquid() == null || this.tank.getLiquid().amount <= 0)
|
||||
return;
|
||||
TileEntity ent = worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord);
|
||||
if (ent instanceof TileEntityTank && ((TileEntityTank) ent).type == this.type && !((TileEntityTank) ent).isFull())
|
||||
if (ent instanceof TileEntityTank && ((TileEntityTank) ent).getColor() == this.color && !((TileEntityTank) ent).isFull())
|
||||
{
|
||||
int f = ((TileEntityTank) ent).tank.fill(this.tank.getLiquid(), true);
|
||||
this.tank.drain(f, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cause this TE to trade liquid with the Tanks around it to level off
|
||||
*/
|
||||
/** Cause this TE to trade liquid with the Tanks around it to level off */
|
||||
public void tradeArround()
|
||||
{
|
||||
if (this.tank.getLiquid() == null || this.tank.getLiquid().amount <= 0)
|
||||
return;
|
||||
if (this.tank.getLiquid() == null || this.tank.getLiquid().amount <= 0) { return; }
|
||||
|
||||
TileEntity[] ents = connectionHelper.getSurroundings(worldObj, xCoord, yCoord, zCoord);
|
||||
|
||||
int commonVol = this.tank.getLiquid().amount;
|
||||
int tanks = 1;
|
||||
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
if (ents[i] instanceof TileEntityTank && ((TileEntityTank) ents[i]).color == this.color)
|
||||
|
@ -303,23 +247,28 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
int equalVol = commonVol / tanks;
|
||||
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
if (this.tank.getLiquid() == null || this.tank.getLiquid().amount <= equalVol)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (ents[i] instanceof TileEntityTank && ((TileEntityTank) ents[i]).color == this.color && !((TileEntityTank) ents[i]).isFull())
|
||||
{
|
||||
LiquidStack stack = ((TileEntityTank) ents[i]).tank.getLiquid();
|
||||
LiquidStack target = ((TileEntityTank) ents[i]).tank.getLiquid();
|
||||
LiquidStack filling = this.tank.getLiquid();
|
||||
if (stack == null)
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
filling = LiquidHandler.getStack(this.type, equalVol);
|
||||
filling = LiquidHandler.getStack(this.tank.getLiquid(), equalVol);
|
||||
}
|
||||
else if (stack.amount < equalVol)
|
||||
else if (target.amount < equalVol)
|
||||
{
|
||||
filling = LiquidHandler.getStack(this.type, equalVol - stack.amount);
|
||||
filling = LiquidHandler.getStack(this.tank.getLiquid(), equalVol - target.amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -332,12 +281,14 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
|||
}
|
||||
}
|
||||
|
||||
public void setColor(PipeColor pipeColor)
|
||||
@Override
|
||||
public void setColor(Object obj)
|
||||
{
|
||||
this.color = pipeColor;
|
||||
this.color = PipeColor.get(cc);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PipeColor getColor()
|
||||
{
|
||||
return color;
|
||||
|
|
Before Width: | Height: | Size: 922 B After Width: | Height: | Size: 960 B |
BIN
minecraft/liquidmechanics/resource/pipes/WhitePipe.png
Normal file
After Width: | Height: | Size: 942 B |
BIN
minecraft/liquidmechanics/resource/tanks/LavaTank.png
Normal file
After Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 1 KiB |