changes/fixed stuff
*Finished basic version of new release valve *Fixed a tank render issue *Changed PipeColor to ColorCode
This commit is contained in:
parent
1e5c47ad3f
commit
064ef38db9
12 changed files with 132 additions and 138 deletions
|
@ -1,13 +1,13 @@
|
||||||
package liquidmechanics.api;
|
package liquidmechanics.api;
|
||||||
|
|
||||||
import liquidmechanics.api.helpers.PipeColor;
|
import liquidmechanics.api.helpers.ColorCode;
|
||||||
|
|
||||||
public interface IColor
|
public interface IColorCoded
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* gets the pipeColor being used by this object
|
* gets the pipeColor being used by this object
|
||||||
*/
|
*/
|
||||||
public PipeColor getColor();
|
public ColorCode getColor();
|
||||||
/**
|
/**
|
||||||
* sets the pipeColor to be used by this object *
|
* sets the pipeColor to be used by this object *
|
||||||
* @param obj-can be anything must be sorted
|
* @param obj-can be anything must be sorted
|
|
@ -1,7 +1,7 @@
|
||||||
package liquidmechanics.api.helpers;
|
package liquidmechanics.api.helpers;
|
||||||
|
|
||||||
|
|
||||||
public enum PipeColor
|
public enum ColorCode
|
||||||
{
|
{
|
||||||
BLACK("Black"),
|
BLACK("Black"),
|
||||||
RED("Red"),
|
RED("Red"),
|
||||||
|
@ -22,7 +22,7 @@ public enum PipeColor
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
private PipeColor(String name)
|
private ColorCode(String name)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
@ -37,25 +37,25 @@ public enum PipeColor
|
||||||
* @param obj
|
* @param obj
|
||||||
* - Integer,String,LiquidData,PipeColor
|
* - Integer,String,LiquidData,PipeColor
|
||||||
* @return Color NONE if it can't find it */
|
* @return Color NONE if it can't find it */
|
||||||
public static PipeColor get(Object obj)
|
public static ColorCode get(Object obj)
|
||||||
{
|
{
|
||||||
if (obj instanceof Integer && ((Integer) obj) < PipeColor.values().length)
|
if (obj instanceof Integer && ((Integer) obj) < ColorCode.values().length)
|
||||||
{
|
{
|
||||||
return PipeColor.values()[((Integer) obj)];
|
return ColorCode.values()[((Integer) obj)];
|
||||||
} else if (obj instanceof LiquidData)
|
} else if (obj instanceof LiquidData)
|
||||||
{
|
{
|
||||||
LiquidData data = (LiquidData) obj;
|
LiquidData data = (LiquidData) obj;
|
||||||
if (data == LiquidHandler.lava) { return RED; }
|
if (data == LiquidHandler.lava) { return RED; }
|
||||||
if (data == LiquidHandler.steam) { return ORANGE; }
|
if (data == LiquidHandler.steam) { return ORANGE; }
|
||||||
if (data == LiquidHandler.water) { return BLUE; }
|
if (data == LiquidHandler.water) { return BLUE; }
|
||||||
} else if (obj instanceof PipeColor)
|
} else if (obj instanceof ColorCode)
|
||||||
{
|
{
|
||||||
return (PipeColor) obj;
|
return (ColorCode) obj;
|
||||||
} else if (obj instanceof String)
|
} else if (obj instanceof String)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < PipeColor.values().length; i++)
|
for (int i = 0; i < ColorCode.values().length; i++)
|
||||||
{
|
{
|
||||||
if (((String) obj).equalsIgnoreCase(PipeColor.get(i).getName())) { return PipeColor.get(i); }
|
if (((String) obj).equalsIgnoreCase(ColorCode.get(i).getName())) { return ColorCode.get(i); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NONE;
|
return NONE;
|
|
@ -8,9 +8,9 @@ public class LiquidData
|
||||||
private int defaultPressure;
|
private int defaultPressure;
|
||||||
private LiquidStack sampleStack;
|
private LiquidStack sampleStack;
|
||||||
private String name;
|
private String name;
|
||||||
private PipeColor color;
|
private ColorCode color;
|
||||||
|
|
||||||
public LiquidData(String name, LiquidStack stack,PipeColor color, boolean gas, int dPressure)
|
public LiquidData(String name, LiquidStack stack,ColorCode color, boolean gas, int dPressure)
|
||||||
{
|
{
|
||||||
this.sampleStack = stack;
|
this.sampleStack = stack;
|
||||||
this.isAGas = gas;
|
this.isAGas = gas;
|
||||||
|
@ -37,10 +37,10 @@ public class LiquidData
|
||||||
{
|
{
|
||||||
return isAGas;
|
return isAGas;
|
||||||
}
|
}
|
||||||
public PipeColor getColor()
|
public ColorCode getColor()
|
||||||
{
|
{
|
||||||
if (color != null) { return color; }
|
if (color != null) { return color; }
|
||||||
return PipeColor.NONE;
|
return ColorCode.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,11 @@ public class LiquidHandler
|
||||||
*/
|
*/
|
||||||
public static void addDefaultLiquids()
|
public static void addDefaultLiquids()
|
||||||
{
|
{
|
||||||
water = new LiquidData("water", LiquidDictionary.getOrCreateLiquid("Water", new LiquidStack(Block.waterStill, 1)), PipeColor.BLUE, false, 32);
|
water = new LiquidData("water", LiquidDictionary.getOrCreateLiquid("Water", new LiquidStack(Block.waterStill, 1)), ColorCode.BLUE, false, 32);
|
||||||
allowedLiquids.add(water);
|
allowedLiquids.add(water);
|
||||||
lava = new LiquidData("Lava", LiquidDictionary.getOrCreateLiquid("Lava", new LiquidStack(Block.lavaStill, 1)), PipeColor.RED, false, 20);
|
lava = new LiquidData("Lava", LiquidDictionary.getOrCreateLiquid("Lava", new LiquidStack(Block.lavaStill, 1)), ColorCode.RED, false, 20);
|
||||||
allowedLiquids.add(lava);
|
allowedLiquids.add(lava);
|
||||||
unkown = new LiquidData("Unknown", LiquidDictionary.getOrCreateLiquid("Unknown", new LiquidStack(20, 1)), PipeColor.NONE, false, 0);
|
unkown = new LiquidData("Unknown", LiquidDictionary.getOrCreateLiquid("Unknown", new LiquidStack(20, 1)), ColorCode.NONE, false, 32);
|
||||||
allowedLiquids.add(unkown);
|
allowedLiquids.add(unkown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,22 +45,22 @@ public class LiquidHandler
|
||||||
// or something along the lines of IDing liquids for use
|
// or something along the lines of IDing liquids for use
|
||||||
if (event.Name.equalsIgnoreCase("methane"))
|
if (event.Name.equalsIgnoreCase("methane"))
|
||||||
{
|
{
|
||||||
this.allowedLiquids.add(new LiquidData("methane", event.Liquid, PipeColor.LIME, true, 100));
|
this.allowedLiquids.add(new LiquidData("methane", event.Liquid, ColorCode.LIME, true, 100));
|
||||||
}
|
}
|
||||||
else if (event.Name.equalsIgnoreCase("oil"))
|
else if (event.Name.equalsIgnoreCase("oil"))
|
||||||
{
|
{
|
||||||
this.allowedLiquids.add(new LiquidData("oil", event.Liquid, PipeColor.BLACK, true, 50));
|
this.allowedLiquids.add(new LiquidData("oil", event.Liquid, ColorCode.BLACK, true, 50));
|
||||||
}
|
}
|
||||||
else if (event.Name.equalsIgnoreCase("fuel"))
|
else if (event.Name.equalsIgnoreCase("fuel"))
|
||||||
{
|
{
|
||||||
this.allowedLiquids.add(new LiquidData("fuel", event.Liquid, PipeColor.YELLOW, true, 50));
|
this.allowedLiquids.add(new LiquidData("fuel", event.Liquid, ColorCode.YELLOW, true, 50));
|
||||||
}
|
}
|
||||||
else if (event.Name.equalsIgnoreCase("steam"))
|
else if (event.Name.equalsIgnoreCase("steam"))
|
||||||
{
|
{
|
||||||
this.steam = new LiquidData("steam", event.Liquid, PipeColor.ORANGE, true, 100);
|
this.steam = new LiquidData("steam", event.Liquid, ColorCode.ORANGE, true, 100);
|
||||||
}else if(event.Name.equalsIgnoreCase("Waste"))
|
}else if(event.Name.equalsIgnoreCase("Waste"))
|
||||||
{
|
{
|
||||||
this.waste = new LiquidData("Waste", event.Liquid, PipeColor.BROWN, false, 40);
|
this.waste = new LiquidData("Waste", event.Liquid, ColorCode.BROWN, false, 40);
|
||||||
this.allowedLiquids.add(waste);
|
this.allowedLiquids.add(waste);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package liquidmechanics.client.render;
|
package liquidmechanics.client.render;
|
||||||
|
|
||||||
import liquidmechanics.api.helpers.PipeColor;
|
import liquidmechanics.api.helpers.ColorCode;
|
||||||
import liquidmechanics.client.model.ModelLargePipe;
|
import liquidmechanics.client.model.ModelLargePipe;
|
||||||
import liquidmechanics.common.LiquidMechanics;
|
import liquidmechanics.common.LiquidMechanics;
|
||||||
import liquidmechanics.common.tileentity.TileEntityPipe;
|
import liquidmechanics.common.tileentity.TileEntityPipe;
|
||||||
|
@ -37,7 +37,7 @@ public class RenderPipe extends TileEntitySpecialRenderer
|
||||||
}
|
}
|
||||||
public static String getPipeTexture(int meta)
|
public static String getPipeTexture(int meta)
|
||||||
{
|
{
|
||||||
return LiquidMechanics.RESOURCE_PATH + "pipes/"+PipeColor.get(meta).getName()+"Pipe.png";
|
return LiquidMechanics.RESOURCE_PATH + "pipes/"+ColorCode.get(meta).getName()+"Pipe.png";
|
||||||
}
|
}
|
||||||
public void render(int meta, TileEntity[] ents)
|
public void render(int meta, TileEntity[] ents)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@ package liquidmechanics.client.render;
|
||||||
|
|
||||||
import liquidmechanics.api.helpers.LiquidData;
|
import liquidmechanics.api.helpers.LiquidData;
|
||||||
import liquidmechanics.api.helpers.LiquidHandler;
|
import liquidmechanics.api.helpers.LiquidHandler;
|
||||||
import liquidmechanics.api.helpers.PipeColor;
|
import liquidmechanics.api.helpers.ColorCode;
|
||||||
import liquidmechanics.api.helpers.connectionHelper;
|
import liquidmechanics.api.helpers.connectionHelper;
|
||||||
import liquidmechanics.client.model.ModelLiquidTank;
|
import liquidmechanics.client.model.ModelLiquidTank;
|
||||||
import liquidmechanics.client.model.ModelLiquidTankCorner;
|
import liquidmechanics.client.model.ModelLiquidTankCorner;
|
||||||
|
@ -11,15 +11,15 @@ import liquidmechanics.common.tileentity.TileEntityTank;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.liquids.LiquidContainerRegistry;
|
import net.minecraftforge.liquids.LiquidContainerRegistry;
|
||||||
|
import net.minecraftforge.liquids.LiquidStack;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
public class RenderTank extends TileEntitySpecialRenderer
|
public class RenderTank extends TileEntitySpecialRenderer
|
||||||
{
|
{
|
||||||
private LiquidData type = LiquidHandler.unkown;
|
|
||||||
private ModelLiquidTank model;
|
private ModelLiquidTank model;
|
||||||
private ModelLiquidTankCorner modelC;
|
private ModelLiquidTankCorner modelC;
|
||||||
private int pos = 0;
|
|
||||||
|
|
||||||
public RenderTank()
|
public RenderTank()
|
||||||
{
|
{
|
||||||
|
@ -31,12 +31,14 @@ public class RenderTank extends TileEntitySpecialRenderer
|
||||||
{
|
{
|
||||||
int meta = te.getBlockMetadata();
|
int meta = te.getBlockMetadata();
|
||||||
int guageMeta = meta;
|
int guageMeta = meta;
|
||||||
if(te.tank.getLiquid() != null)
|
LiquidStack stack = te.getStack();
|
||||||
|
int pos = 0;
|
||||||
|
if(stack != null)
|
||||||
{
|
{
|
||||||
pos = Math.min((te.tank.getLiquid().amount / LiquidContainerRegistry.BUCKET_VOLUME), 4);
|
pos = Math.min((stack.amount / LiquidContainerRegistry.BUCKET_VOLUME), 4);
|
||||||
if(meta == PipeColor.NONE.ordinal())
|
if(meta == ColorCode.NONE.ordinal())
|
||||||
{
|
{
|
||||||
guageMeta = PipeColor.get(te.tank.getLiquid()).ordinal();
|
guageMeta = ColorCode.get(stack).ordinal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.io.File;
|
||||||
|
|
||||||
import liquidmechanics.api.helpers.LiquidData;
|
import liquidmechanics.api.helpers.LiquidData;
|
||||||
import liquidmechanics.api.helpers.LiquidHandler;
|
import liquidmechanics.api.helpers.LiquidHandler;
|
||||||
import liquidmechanics.api.helpers.PipeColor;
|
import liquidmechanics.api.helpers.ColorCode;
|
||||||
import liquidmechanics.common.block.BlockGenerator;
|
import liquidmechanics.common.block.BlockGenerator;
|
||||||
import liquidmechanics.common.block.BlockPumpMachine;
|
import liquidmechanics.common.block.BlockPumpMachine;
|
||||||
import liquidmechanics.common.block.BlockPipe;
|
import liquidmechanics.common.block.BlockPipe;
|
||||||
|
@ -219,12 +219,12 @@ public class LiquidMechanics extends DummyModContainer
|
||||||
new ItemStack(itemParts, 1, Parts.Seal.ordinal()) });
|
new ItemStack(itemParts, 1, Parts.Seal.ordinal()) });
|
||||||
|
|
||||||
// steam tank
|
// steam tank
|
||||||
GameRegistry.addShapelessRecipe(new ItemStack(blockTank, 1, PipeColor.ORANGE.ordinal()), new Object[] {
|
GameRegistry.addShapelessRecipe(new ItemStack(blockTank, 1, ColorCode.ORANGE.ordinal()), new Object[] {
|
||||||
new ItemStack(itemParts, 1, Parts.Tank.ordinal()),
|
new ItemStack(itemParts, 1, Parts.Tank.ordinal()),
|
||||||
new ItemStack(itemParts, 1, Parts.Seal.ordinal()),
|
new ItemStack(itemParts, 1, Parts.Seal.ordinal()),
|
||||||
new ItemStack(Item.dyePowder, 1, PipeColor.ORANGE.ordinal()) });
|
new ItemStack(Item.dyePowder, 1, ColorCode.ORANGE.ordinal()) });
|
||||||
// lava tank
|
// lava tank
|
||||||
GameRegistry.addRecipe(new ItemStack(blockTank, 1, PipeColor.RED.ordinal()), new Object[] {
|
GameRegistry.addRecipe(new ItemStack(blockTank, 1, ColorCode.RED.ordinal()), new Object[] {
|
||||||
" @ ", "@T@", " @ ",
|
" @ ", "@T@", " @ ",
|
||||||
'T', new ItemStack(itemParts, 1, Parts.Tank.ordinal()),
|
'T', new ItemStack(itemParts, 1, Parts.Tank.ordinal()),
|
||||||
'@', Block.obsidian, });
|
'@', Block.obsidian, });
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class BlockTank extends BlockMachine
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
LiquidStack stack = tank.tank.getLiquid();
|
LiquidStack stack = tank.getStack();
|
||||||
if (stack != null)
|
if (stack != null)
|
||||||
{
|
{
|
||||||
ItemStack liquidItem = LiquidContainerRegistry.fillLiquidContainer(stack, current);
|
ItemStack liquidItem = LiquidContainerRegistry.fillLiquidContainer(stack, current);
|
||||||
|
@ -110,7 +110,7 @@ public class BlockTank extends BlockMachine
|
||||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, liquidItem);
|
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, liquidItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tank.tank.drain(liquid.amount, true);
|
tank.drain(null, liquid.amount, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package liquidmechanics.common.handlers;
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import liquidmechanics.api.helpers.LiquidHandler;
|
import liquidmechanics.api.helpers.LiquidHandler;
|
||||||
import liquidmechanics.api.helpers.PipeColor;
|
import liquidmechanics.api.helpers.ColorCode;
|
||||||
import liquidmechanics.common.tileentity.TileEntityPipe;
|
import liquidmechanics.common.tileentity.TileEntityPipe;
|
||||||
import liquidmechanics.common.tileentity.TileEntityTank;
|
import liquidmechanics.common.tileentity.TileEntityTank;
|
||||||
|
|
||||||
|
@ -17,11 +17,11 @@ public class UpdateConverter
|
||||||
Boolean converted25 = nbt.getBoolean("converted025");
|
Boolean converted25 = nbt.getBoolean("converted025");
|
||||||
if (!converted24)
|
if (!converted24)
|
||||||
{
|
{
|
||||||
pipe.setColor(PipeColor.get(LiquidHandler.getFromMeta(nbt.getInteger("type"))));
|
pipe.setColor(ColorCode.get(LiquidHandler.getFromMeta(nbt.getInteger("type"))));
|
||||||
}
|
}
|
||||||
else if (converted24 && !converted25)
|
else if (converted24 && !converted25)
|
||||||
{
|
{
|
||||||
pipe.setColor(PipeColor.get(LiquidHandler.get(nbt.getString("name"))));
|
pipe.setColor(ColorCode.get(LiquidHandler.get(nbt.getString("name"))));
|
||||||
}
|
}
|
||||||
nbt.setBoolean("converted", true);
|
nbt.setBoolean("converted", true);
|
||||||
nbt.setBoolean("converted025", true);
|
nbt.setBoolean("converted025", true);
|
||||||
|
@ -32,11 +32,11 @@ public class UpdateConverter
|
||||||
Boolean converted25 = nbt.getBoolean("converted025");
|
Boolean converted25 = nbt.getBoolean("converted025");
|
||||||
if (!converted24)
|
if (!converted24)
|
||||||
{
|
{
|
||||||
pipe.setColor(PipeColor.get(LiquidHandler.getFromMeta(nbt.getInteger("type"))));
|
pipe.setColor(ColorCode.get(LiquidHandler.getFromMeta(nbt.getInteger("type"))));
|
||||||
}
|
}
|
||||||
else if (converted24 && !converted25)
|
else if (converted24 && !converted25)
|
||||||
{
|
{
|
||||||
pipe.setColor(PipeColor.get(LiquidHandler.get(nbt.getString("name"))));
|
pipe.setColor(ColorCode.get(LiquidHandler.get(nbt.getString("name"))));
|
||||||
}
|
}
|
||||||
nbt.setBoolean("converted", true);
|
nbt.setBoolean("converted", true);
|
||||||
nbt.setBoolean("converted025", true);
|
nbt.setBoolean("converted025", true);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package liquidmechanics.common.tileentity;
|
package liquidmechanics.common.tileentity;
|
||||||
|
|
||||||
import liquidmechanics.api.IColor;
|
import liquidmechanics.api.IColorCoded;
|
||||||
import liquidmechanics.api.IReadOut;
|
import liquidmechanics.api.IReadOut;
|
||||||
import liquidmechanics.api.IPressure;
|
import liquidmechanics.api.IPressure;
|
||||||
import liquidmechanics.api.helpers.LiquidData;
|
import liquidmechanics.api.helpers.LiquidData;
|
||||||
import liquidmechanics.api.helpers.LiquidHandler;
|
import liquidmechanics.api.helpers.LiquidHandler;
|
||||||
import liquidmechanics.api.helpers.PipeColor;
|
import liquidmechanics.api.helpers.ColorCode;
|
||||||
import liquidmechanics.api.helpers.connectionHelper;
|
import liquidmechanics.api.helpers.connectionHelper;
|
||||||
import liquidmechanics.common.LiquidMechanics;
|
import liquidmechanics.common.LiquidMechanics;
|
||||||
import liquidmechanics.common.handlers.UpdateConverter;
|
import liquidmechanics.common.handlers.UpdateConverter;
|
||||||
|
@ -28,9 +28,9 @@ import universalelectricity.prefab.network.PacketManager;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
public class TileEntityPipe extends TileEntity implements ITankContainer, IReadOut,IColor
|
public class TileEntityPipe extends TileEntity implements ITankContainer, IReadOut,IColorCoded
|
||||||
{
|
{
|
||||||
private PipeColor color = PipeColor.NONE;
|
private ColorCode color = ColorCode.NONE;
|
||||||
|
|
||||||
private int count = 40;
|
private int count = 40;
|
||||||
private int count2, presure = 0;
|
private int count2, presure = 0;
|
||||||
|
@ -47,7 +47,7 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
||||||
{
|
{
|
||||||
|
|
||||||
this.validataConnections();
|
this.validataConnections();
|
||||||
this.color = PipeColor.get(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
this.color = ColorCode.get(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||||
if (!worldObj.isRemote && ++count >= 40)
|
if (!worldObj.isRemote && ++count >= 40)
|
||||||
{
|
{
|
||||||
count = 0;
|
count = 0;
|
||||||
|
@ -91,7 +91,7 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
||||||
* gets the current color mark of the pipe
|
* gets the current color mark of the pipe
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PipeColor getColor()
|
public ColorCode getColor()
|
||||||
{
|
{
|
||||||
return this.color;
|
return this.color;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
||||||
@Override
|
@Override
|
||||||
public void setColor(Object cc)
|
public void setColor(Object cc)
|
||||||
{
|
{
|
||||||
this.color = PipeColor.get(cc);
|
this.color = ColorCode.get(cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,9 +110,9 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
||||||
*/
|
*/
|
||||||
public void setColor(int i)
|
public void setColor(int i)
|
||||||
{
|
{
|
||||||
if (i < PipeColor.values().length)
|
if (i < ColorCode.values().length)
|
||||||
{
|
{
|
||||||
this.color = PipeColor.values()[i];
|
this.color = ColorCode.values()[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,9 +157,9 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
||||||
{
|
{
|
||||||
if (resource == null) { return 0; }
|
if (resource == null) { return 0; }
|
||||||
LiquidStack stack = stored.getLiquid();
|
LiquidStack stack = stored.getLiquid();
|
||||||
if (color != PipeColor.NONE)
|
if (color != ColorCode.NONE)
|
||||||
{
|
{
|
||||||
if (color != PipeColor.get(LiquidHandler.get(resource)) || !LiquidHandler.isEqual(stack, resource))
|
if (color != ColorCode.get(LiquidHandler.get(resource)) || !LiquidHandler.isEqual(stack, resource))
|
||||||
{
|
{
|
||||||
this.causeMix(stack, resource);
|
this.causeMix(stack, resource);
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO
|
||||||
connectedBlocks[i] = null;
|
connectedBlocks[i] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.color != PipeColor.NONE && ent instanceof TileEntityTank && color != ((TileEntityTank) ent).getColor())
|
if (this.color != ColorCode.NONE && ent instanceof TileEntityTank && color != ((TileEntityTank) ent).getColor())
|
||||||
{
|
{
|
||||||
connectedBlocks[i] = null;
|
connectedBlocks[i] = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,13 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.FMLLog;
|
||||||
|
|
||||||
import liquidmechanics.api.IPressure;
|
import liquidmechanics.api.IPressure;
|
||||||
import liquidmechanics.api.IReadOut;
|
import liquidmechanics.api.IReadOut;
|
||||||
import liquidmechanics.api.helpers.LiquidData;
|
import liquidmechanics.api.helpers.LiquidData;
|
||||||
import liquidmechanics.api.helpers.LiquidHandler;
|
import liquidmechanics.api.helpers.LiquidHandler;
|
||||||
import liquidmechanics.api.helpers.PipeColor;
|
import liquidmechanics.api.helpers.ColorCode;
|
||||||
import liquidmechanics.api.helpers.connectionHelper;
|
import liquidmechanics.api.helpers.connectionHelper;
|
||||||
import liquidmechanics.common.block.BlockReleaseValve;
|
import liquidmechanics.common.block.BlockReleaseValve;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -27,7 +29,7 @@ import universalelectricity.prefab.implement.IRedstoneReceptor;
|
||||||
|
|
||||||
public class TileEntityReleaseValve extends TileEntity implements IPressure, IReadOut, IRedstoneReceptor, IInventory
|
public class TileEntityReleaseValve extends TileEntity implements IPressure, IReadOut, IRedstoneReceptor, IInventory
|
||||||
{
|
{
|
||||||
public boolean[] allowed = new boolean[PipeColor.values().length];
|
public boolean[] allowed = new boolean[ColorCode.values().length - 1];
|
||||||
public TileEntity[] connected = new TileEntity[6];
|
public TileEntity[] connected = new TileEntity[6];
|
||||||
|
|
||||||
private List<TileEntityPipe> output = new ArrayList<TileEntityPipe>();
|
private List<TileEntityPipe> output = new ArrayList<TileEntityPipe>();
|
||||||
|
@ -45,70 +47,72 @@ public class TileEntityReleaseValve extends TileEntity implements IPressure, IRe
|
||||||
{
|
{
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
if (!this.worldObj.isRemote && ticks++ == 10)
|
if (!this.worldObj.isRemote && ticks++ >= 40)
|
||||||
{
|
{
|
||||||
|
ticks = 0;
|
||||||
BlockReleaseValve.checkForPower(worldObj, xCoord, yCoord, zCoord);
|
BlockReleaseValve.checkForPower(worldObj, xCoord, yCoord, zCoord);
|
||||||
validateNBuildList();
|
validateNBuildList();
|
||||||
// start the draining process
|
// start the draining process
|
||||||
if (this.input.size() > 0 && this.output.size() > 0)
|
if (this.input.size() > 0 && this.output.size() > 0)
|
||||||
{
|
{
|
||||||
Iterator itr = input.iterator();
|
for (ILiquidTank tank : input)
|
||||||
// testing out Iterators :p
|
|
||||||
while (itr.hasNext())
|
|
||||||
{
|
{
|
||||||
Object element = itr.next();
|
|
||||||
if (element instanceof ILiquidTank)
|
if (tank.getLiquid() != null && tank.getLiquid().amount > 0)
|
||||||
{
|
|
||||||
ILiquidTank tank = (ILiquidTank) element;
|
|
||||||
if (tank.getLiquid() != null && tank.getLiquid().amount < tank.getCapacity())
|
|
||||||
{
|
{
|
||||||
|
FMLLog.warning("Tank: " + LiquidHandler.getName(tank.getLiquid()) + " Vol: " + tank.getLiquid().amount);
|
||||||
TileEntityPipe pipe = this.findValidPipe(tank.getLiquid());
|
TileEntityPipe pipe = this.findValidPipe(tank.getLiquid());
|
||||||
if (pipe != null)
|
if (pipe != null)
|
||||||
{
|
{
|
||||||
|
FMLLog.warning("Pipe: " + pipe.getColor() + " Vol: " + (pipe.stored.getLiquid() != null ? pipe.stored.getLiquid().amount : 0000));
|
||||||
int drain = pipe.stored.fill(tank.getLiquid(), true);
|
int drain = pipe.stored.fill(tank.getLiquid(), true);
|
||||||
tank.drain(drain, true);
|
tank.drain(drain, true);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
}
|
||||||
* used to find a valid pipe for filling of the liquid type
|
}
|
||||||
*/
|
|
||||||
|
/** used to find a valid pipe for filling of the liquid type */
|
||||||
public TileEntityPipe findValidPipe(LiquidStack stack)
|
public TileEntityPipe findValidPipe(LiquidStack stack)
|
||||||
{
|
{
|
||||||
LiquidData data = LiquidHandler.get(stack);
|
|
||||||
if (data != LiquidHandler.unkown)
|
// find normal color selective pipe first
|
||||||
{
|
|
||||||
for (TileEntityPipe pipe : output)
|
for (TileEntityPipe pipe : output)
|
||||||
{
|
{
|
||||||
if (pipe.getColor() == data.getColor() && (pipe.stored.getLiquid() == null || pipe.stored.getLiquid().amount < pipe.stored.getCapacity())) { return pipe; }
|
if (LiquidHandler.isEqual(pipe.getColor().getLiquidData().getStack(),stack) && (pipe.stored.getLiquid() == null || pipe.stored.getLiquid().amount < pipe.stored.getCapacity()))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return pipe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if no color selective pipe is found look for generic pipes
|
||||||
|
for (TileEntityPipe pipe : output)
|
||||||
|
{
|
||||||
|
if (pipe.getColor() == ColorCode.NONE) { return pipe; }
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** sees if it can connect to a pipe of some color */
|
||||||
* sees if it can connect to a pipe of some color
|
public boolean canConnect(ColorCode cc)
|
||||||
*/
|
{
|
||||||
public boolean canConnect(PipeColor cc)
|
if (this.isRestricted())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < this.allowed.length; i++)
|
for (int i = 0; i < this.allowed.length; i++)
|
||||||
{
|
{
|
||||||
if (allowed[i] && i == cc.ordinal()) { return true; }
|
if (i == cc.ordinal()) { return allowed[i]; }
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** if any of allowed list is true
|
||||||
* if any of allowed list is true
|
|
||||||
*
|
*
|
||||||
* @return true
|
* @return true */
|
||||||
*/
|
|
||||||
public boolean isRestricted()
|
public boolean isRestricted()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < this.allowed.length; i++)
|
for (int i = 0; i < this.allowed.length; i++)
|
||||||
|
@ -118,15 +122,18 @@ public class TileEntityReleaseValve extends TileEntity implements IPressure, IRe
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** checks a liquidstack against its color code
|
||||||
|
*
|
||||||
|
* @param stack
|
||||||
|
* @return */
|
||||||
public boolean canAcceptLiquid(LiquidStack stack)
|
public boolean canAcceptLiquid(LiquidStack stack)
|
||||||
{
|
{
|
||||||
return canConnect(PipeColor.get(LiquidHandler.get(stack)));
|
if (!this.isRestricted()) { return true; }
|
||||||
|
return canConnect(ColorCode.get(LiquidHandler.get(stack)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Collects info about the surrounding 6 tiles and orders them into
|
||||||
* Collects info about the surrounding 6 tiles and orders them into
|
* drain-able(ITankContainer) and fill-able(TileEntityPipes) instances */
|
||||||
* drain-able(ITankContainer) and fill-able(TileEntityPipes) instances
|
|
||||||
*/
|
|
||||||
public void validateNBuildList()
|
public void validateNBuildList()
|
||||||
{
|
{
|
||||||
// cleanup
|
// cleanup
|
||||||
|
@ -160,21 +167,13 @@ public class TileEntityReleaseValve extends TileEntity implements IPressure, IRe
|
||||||
for (int t = 0; t < tanks.length; t++)
|
for (int t = 0; t < tanks.length; t++)
|
||||||
{
|
{
|
||||||
LiquidStack ll = tanks[t].getLiquid();
|
LiquidStack ll = tanks[t].getLiquid();
|
||||||
if (ll != null && ll.amount > 0 && ll.amount < tanks[t].getCapacity())
|
if (ll != null && ll.amount > 0 && ll.amount > 0)
|
||||||
{
|
|
||||||
// if restricted check for type match
|
|
||||||
if (this.isRestricted())
|
|
||||||
{
|
{
|
||||||
if (this.canAcceptLiquid(ll))
|
if (this.canAcceptLiquid(ll))
|
||||||
{
|
{
|
||||||
this.input.add(tanks[t]);
|
this.input.add(tanks[t]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
this.input.add(tanks[t]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -234,9 +233,7 @@ public class TileEntityReleaseValve extends TileEntity implements IPressure, IRe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Writes a tile entity to NBT. */
|
||||||
* Writes a tile entity to NBT.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt)
|
public void writeToNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
|
@ -266,18 +263,14 @@ public class TileEntityReleaseValve extends TileEntity implements IPressure, IRe
|
||||||
return this.inventory.length;
|
return this.inventory.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Returns the stack in slot i */
|
||||||
* Returns the stack in slot i
|
|
||||||
*/
|
|
||||||
public ItemStack getStackInSlot(int par1)
|
public ItemStack getStackInSlot(int par1)
|
||||||
{
|
{
|
||||||
return this.inventory[par1];
|
return this.inventory[par1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Removes from an inventory slot (first arg) up to a specified number
|
||||||
* Removes from an inventory slot (first arg) up to a specified number
|
* (second arg) of items and returns them in a new stack. */
|
||||||
* (second arg) of items and returns them in a new stack.
|
|
||||||
*/
|
|
||||||
public ItemStack decrStackSize(int par1, int par2)
|
public ItemStack decrStackSize(int par1, int par2)
|
||||||
{
|
{
|
||||||
if (this.inventory[par1] != null)
|
if (this.inventory[par1] != null)
|
||||||
|
@ -308,11 +301,9 @@ public class TileEntityReleaseValve extends TileEntity implements IPressure, IRe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** When some containers are closed they call this on each slot, then drop
|
||||||
* 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
|
* whatever it returns as an EntityItem - like when you close a workbench
|
||||||
* GUI.
|
* GUI. */
|
||||||
*/
|
|
||||||
public ItemStack getStackInSlotOnClosing(int par1)
|
public ItemStack getStackInSlotOnClosing(int par1)
|
||||||
{
|
{
|
||||||
if (this.inventory[par1] != null)
|
if (this.inventory[par1] != null)
|
||||||
|
@ -327,10 +318,8 @@ public class TileEntityReleaseValve extends TileEntity implements IPressure, IRe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Sets the given item stack to the specified slot in the inventory (can be
|
||||||
* Sets the given item stack to the specified slot in the inventory (can be
|
* crafting or armor sections). */
|
||||||
* crafting or armor sections).
|
|
||||||
*/
|
|
||||||
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
|
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
|
||||||
{
|
{
|
||||||
this.inventory[par1] = par2ItemStack;
|
this.inventory[par1] = par2ItemStack;
|
||||||
|
|
|
@ -2,12 +2,12 @@ package liquidmechanics.common.tileentity;
|
||||||
|
|
||||||
import javax.swing.colorchooser.ColorSelectionModel;
|
import javax.swing.colorchooser.ColorSelectionModel;
|
||||||
|
|
||||||
import liquidmechanics.api.IColor;
|
import liquidmechanics.api.IColorCoded;
|
||||||
import liquidmechanics.api.IReadOut;
|
import liquidmechanics.api.IReadOut;
|
||||||
import liquidmechanics.api.IPressure;
|
import liquidmechanics.api.IPressure;
|
||||||
import liquidmechanics.api.helpers.LiquidData;
|
import liquidmechanics.api.helpers.LiquidData;
|
||||||
import liquidmechanics.api.helpers.LiquidHandler;
|
import liquidmechanics.api.helpers.LiquidHandler;
|
||||||
import liquidmechanics.api.helpers.PipeColor;
|
import liquidmechanics.api.helpers.ColorCode;
|
||||||
import liquidmechanics.api.helpers.connectionHelper;
|
import liquidmechanics.api.helpers.connectionHelper;
|
||||||
import liquidmechanics.common.LiquidMechanics;
|
import liquidmechanics.common.LiquidMechanics;
|
||||||
import liquidmechanics.common.handlers.UpdateConverter;
|
import liquidmechanics.common.handlers.UpdateConverter;
|
||||||
|
@ -29,24 +29,24 @@ import universalelectricity.prefab.network.PacketManager;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
public class TileEntityTank extends TileEntity implements IPacketReceiver, IReadOut, IPressure, ITankContainer, IColor
|
public class TileEntityTank extends TileEntity implements IPacketReceiver, IReadOut, IPressure, ITankContainer, IColorCoded
|
||||||
{
|
{
|
||||||
public TileEntity[] cc = { null, null, null, null, null, null };
|
public TileEntity[] cc = { null, null, null, null, null, null };
|
||||||
|
|
||||||
private PipeColor color = PipeColor.NONE;
|
private ColorCode color = ColorCode.NONE;
|
||||||
|
|
||||||
public static final int LMax = 4;
|
public static final int LMax = 4;
|
||||||
private int count, count2 = 0;
|
private int count, count2 = 0;
|
||||||
|
|
||||||
public int pVolume = 0;
|
public int pVolume = 0;
|
||||||
|
|
||||||
public LiquidTank tank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME * LMax);
|
private LiquidTank tank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME * LMax);
|
||||||
|
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
{
|
{
|
||||||
|
|
||||||
LiquidStack liquid = tank.getLiquid();
|
LiquidStack liquid = tank.getLiquid();
|
||||||
this.color = PipeColor.get(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
this.color = ColorCode.get(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||||
if (++count >= 40 && liquid != null)
|
if (++count >= 40 && liquid != null)
|
||||||
{
|
{
|
||||||
count = 0;
|
count = 0;
|
||||||
|
@ -73,7 +73,10 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public LiquidStack getStack()
|
||||||
|
{
|
||||||
|
return tank.getLiquid();
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public String getMeterReading(EntityPlayer user, ForgeDirection side)
|
public String getMeterReading(EntityPlayer user, ForgeDirection side)
|
||||||
{
|
{
|
||||||
|
@ -121,7 +124,7 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
||||||
@Override
|
@Override
|
||||||
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
|
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
|
||||||
{
|
{
|
||||||
if (resource == null || (!LiquidHandler.isEqual(resource, color.getLiquidData().getStack()) && this.color != PipeColor.NONE)) { return 0; }
|
if (resource == null || (!LiquidHandler.isEqual(resource, color.getLiquidData().getStack()) && this.color != ColorCode.NONE)) { return 0; }
|
||||||
return this.fill(0, resource, doFill);
|
return this.fill(0, resource, doFill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,8 +301,8 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
||||||
TileEntity ent = worldObj.getBlockTileEntity(xCoord, yCoord + change, zCoord);
|
TileEntity ent = worldObj.getBlockTileEntity(xCoord, yCoord + change, zCoord);
|
||||||
if (ent instanceof TileEntityPipe)
|
if (ent instanceof TileEntityPipe)
|
||||||
{
|
{
|
||||||
PipeColor c = ((TileEntityPipe) ent).getColor();
|
ColorCode c = ((TileEntityPipe) ent).getColor();
|
||||||
if (c == PipeColor.NONE || c == this.color)
|
if (c == ColorCode.NONE || c == this.color)
|
||||||
{
|
{
|
||||||
int vol = LiquidContainerRegistry.BUCKET_VOLUME;
|
int vol = LiquidContainerRegistry.BUCKET_VOLUME;
|
||||||
if (this.tank.getLiquid().amount < vol)
|
if (this.tank.getLiquid().amount < vol)
|
||||||
|
@ -316,12 +319,12 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
|
||||||
@Override
|
@Override
|
||||||
public void setColor(Object obj)
|
public void setColor(Object obj)
|
||||||
{
|
{
|
||||||
this.color = PipeColor.get(cc);
|
this.color = ColorCode.get(cc);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PipeColor getColor()
|
public ColorCode getColor()
|
||||||
{
|
{
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue