diff --git a/buildnumber.txt b/buildnumber.txt index 88e06824..762a74f0 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -22 +23 diff --git a/info.txt b/info.txt index 0e8194b2..7ec940b1 100644 --- a/info.txt +++ b/info.txt @@ -20,3 +20,4 @@ x Fluid-Mechanics_v0.2.7.19.jar Fluid-Mechanics_v0.2.7.19_api.zip x Fluid-Mechanics_v0.2.7.20.jar Fluid-Mechanics_v0.2.7.20_api.zip x Fluid-Mechanics_v0.2.7.21.jar hydraulic_v0.2.7.21_api.zip @ Fluid-Mechanics_v0.2.7.22.jar hydraulic_v0.2.7.22_api.zip +@ Fluid-Mechanics_v0.2.8.23.jar hydraulic_v0.2.8.23_api.zip diff --git a/modversion.txt b/modversion.txt index 967b33ff..08456a47 100644 --- a/modversion.txt +++ b/modversion.txt @@ -1 +1 @@ -0.2.7 \ No newline at end of file +0.2.8 \ No newline at end of file diff --git a/src/minecraft/fluidmech/common/machines/TileEntityReleaseValve.java b/src/minecraft/fluidmech/common/machines/TileEntityReleaseValve.java index 85d46a84..f9f6e5ee 100644 --- a/src/minecraft/fluidmech/common/machines/TileEntityReleaseValve.java +++ b/src/minecraft/fluidmech/common/machines/TileEntityReleaseValve.java @@ -78,7 +78,6 @@ public class TileEntityReleaseValve extends TileEntityAdvanced implements IPsiCr { ILiquidTank pipeVolume = inputPipe.getTanks(ForgeDirection.UNKNOWN)[0]; int ammountFilled = inputPipe.fill(ForgeDirection.UNKNOWN, stack, true); - System.out.print("/n Amount Drained: "+ammountFilled); drainedTank.drain(ForgeDirection.UNKNOWN, ammountFilled, true); } } @@ -95,7 +94,7 @@ public class TileEntityReleaseValve extends TileEntityAdvanced implements IPsiCr for (TileEntityPipe pipe : output) { ILiquidTank tank = pipe.getTanks(ForgeDirection.UNKNOWN)[0]; - if (LiquidHandler.isEqual(pipe.getColor().getLiquidData().getStack(), stack) && (tank.getLiquid() == null || tank.getLiquid().amount < tank.getCapacity())) + if (pipe.getColor().getLiquidData().getStack().isLiquidEqual(stack) && (tank.getLiquid() == null || tank.getLiquid().amount < tank.getCapacity())) { // return pipe; diff --git a/src/minecraft/fluidmech/common/machines/TileEntitySink.java b/src/minecraft/fluidmech/common/machines/TileEntitySink.java index 58b0402a..b3d480b8 100644 --- a/src/minecraft/fluidmech/common/machines/TileEntitySink.java +++ b/src/minecraft/fluidmech/common/machines/TileEntitySink.java @@ -102,7 +102,7 @@ public class TileEntitySink extends TileEntity implements IPacketReceiver, ITank @Override public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) { - if (resource == null || (!LiquidHandler.isEqual(resource, color.getLiquidData().getStack()))) { return 0; } + if (resource == null || (!color.getLiquidData().getStack().isLiquidEqual(resource))) { return 0; } return this.fill(0, resource, doFill); } diff --git a/src/minecraft/fluidmech/common/machines/TileEntityTank.java b/src/minecraft/fluidmech/common/machines/TileEntityTank.java index 451cda6c..4ab6ffab 100644 --- a/src/minecraft/fluidmech/common/machines/TileEntityTank.java +++ b/src/minecraft/fluidmech/common/machines/TileEntityTank.java @@ -117,7 +117,7 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead @Override public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) { - if (resource == null || (!LiquidHandler.isEqual(resource, color.getLiquidData().getStack()) && this.color != ColorCode.NONE)) { return 0; } + if (resource == null || (!color.getLiquidData().getStack().isLiquidEqual(resource) && this.color != ColorCode.NONE)) { return 0; } return this.fill(0, resource, doFill); } diff --git a/src/minecraft/fluidmech/common/machines/pipes/TileEntityPipe.java b/src/minecraft/fluidmech/common/machines/pipes/TileEntityPipe.java index b7c4fb00..bb23939e 100644 --- a/src/minecraft/fluidmech/common/machines/pipes/TileEntityPipe.java +++ b/src/minecraft/fluidmech/common/machines/pipes/TileEntityPipe.java @@ -202,10 +202,9 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO return 0; } LiquidStack stack = tank.getLiquid(); - if (color != ColorCode.NONE) + if (this.color.isValidLiquid(resource)) { - - if (stack == null || LiquidHandler.isEqual(resource, this.color.getLiquidData())) + if (stack == null || (stack != null && stack.isLiquidEqual(resource))) { return this.fill(0, resource, doFill); } @@ -215,17 +214,7 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO } } - else - { - if (stack == null || LiquidHandler.isEqual(stack, resource)) - { - return this.fill(0, resource, doFill); - } - else - { - return this.causeMix(stack, resource); - } - } + return 0; } @Override @@ -245,12 +234,12 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO return 0; } // water flowing into lava creates obby - if (LiquidHandler.isEqual(stored, LiquidHandler.lava) && LiquidHandler.isEqual(fill, LiquidHandler.water)) + if (fill.isLiquidEqual(LiquidHandler.lava.getStack()) && fill.isLiquidEqual(LiquidHandler.water.getStack())) { worldObj.setBlockWithNotify(xCoord, yCoord, zCoord, Block.obsidian.blockID); return fill.amount; }// lava flowing into water creates cobble - else if (LiquidHandler.isEqual(stored, LiquidHandler.water) && LiquidHandler.isEqual(fill, LiquidHandler.lava)) + else if (fill.isLiquidEqual(LiquidHandler.water.getStack()) && fill.isLiquidEqual(LiquidHandler.lava.getStack())) { worldObj.setBlockWithNotify(xCoord, yCoord, zCoord, Block.cobblestone.blockID); return fill.amount; @@ -287,6 +276,10 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IReadO @Override public ILiquidTank getTank(ForgeDirection direction, LiquidStack type) { + if(this.color.isValidLiquid(type)) + { + return this.tank; + } return null; } diff --git a/src/minecraft/hydraulic/core/implement/ColorCode.java b/src/minecraft/hydraulic/core/implement/ColorCode.java index b50f68d0..4bb44ba4 100644 --- a/src/minecraft/hydraulic/core/implement/ColorCode.java +++ b/src/minecraft/hydraulic/core/implement/ColorCode.java @@ -1,74 +1,111 @@ package hydraulic.core.implement; +import java.util.ArrayList; +import java.util.List; + +import net.minecraftforge.liquids.LiquidStack; import hydraulic.core.liquids.LiquidData; import hydraulic.core.liquids.LiquidHandler; - public enum ColorCode { - BLACK("Black"), - RED("Red"), - GREEN("Green"), - BROWN("Brown"), - BLUE("Blue"), - PURPLE("Purple"), - CYAN("Cyan"), - SILVER("Silver"), - GREY("Grey"), - PINK("Pink"), - LIME("Lime"), - YELLOW("Yellow"), - LIGHTBLUE("LightBlue"), - WHITE("White"), - ORANGE("Orange"), - NONE(""); - - String name; + BLACK("Black"), RED("Red"), GREEN("Green"), BROWN("Brown"), BLUE("Blue"), PURPLE("Purple"), CYAN("Cyan"), SILVER("Silver"), GREY("Grey"), PINK("Pink"), LIME("Lime"), YELLOW("Yellow"), LIGHTBLUE("LightBlue"), WHITE("White"), ORANGE("Orange"), NONE(""); - private ColorCode(String name) - { - this.name = name; - } + String name; - public String getName() - { - return this.name; - } + private ColorCode(String name) + { + this.name = name; + } - /** gets a ColorCode from any of the following - * - * @param obj - * - Integer,String,LiquidData,ColorCode - * @return Color NONE if it can't find it */ - public static ColorCode get(Object obj) - { - if (obj instanceof Integer && ((Integer) obj) < ColorCode.values().length) - { - return ColorCode.values()[((Integer) obj)]; - } else if (obj instanceof LiquidData) - { - return ((LiquidData) obj).getColor(); - } else if (obj instanceof ColorCode) - { - return (ColorCode) obj; - } else if (obj instanceof String) - { - for (int i = 0; i < ColorCode.values().length; i++) - { - if (((String) obj).equalsIgnoreCase(ColorCode.get(i).getName())) { return ColorCode.get(i); } - } - } - return NONE; - } + public String getName() + { + return this.name; + } - /** 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) - { - if (data.getColor() == this) { return data; } - } - return LiquidHandler.unkown; - } + /** + * gets a ColorCode from any of the following + * + * @param obj - Integer,String,LiquidData,ColorCode + * @return Color NONE if it can't find it + */ + public static ColorCode get(Object obj) + { + if (obj instanceof Integer && ((Integer) obj) < ColorCode.values().length) + { + return ColorCode.values()[((Integer) obj)]; + } + else if (obj instanceof LiquidData) + { + return ((LiquidData) obj).getColor(); + } + else if (obj instanceof ColorCode) + { + return (ColorCode) obj; + } + else if (obj instanceof String) + { + for (int i = 0; i < ColorCode.values().length; i++) + { + if (((String) obj).equalsIgnoreCase(ColorCode.get(i).getName())) + { + return ColorCode.get(i); + } + } + } + return NONE; + } + + /** + * gets the liquidData linked with this color + */ + public LiquidData getLiquidData() + { + for (LiquidData data : LiquidHandler.allowedLiquids) + { + if (data.getColor() == this) + { + return data; + } + } + return LiquidHandler.unkown; + } + /** + * Gets a list of LiquidData that are linked with the color + */ + public List getAllLiquidData() + { + List validLiquids = new ArrayList(); + for (LiquidData data : LiquidHandler.allowedLiquids) + { + if (data.getColor() == this && !validLiquids.contains(data)) + { + validLiquids.add(data); + } + } + return validLiquids; + } + + /** + * checks to see if the liquidStack is valid for the given color + */ + public boolean isValidLiquid(LiquidStack stack) + { + if (stack == null) + { + return false; + } + if (this == NONE) + { + return true; + } + for (LiquidData data : LiquidHandler.allowedLiquids) + { + if (data.getStack().isLiquidEqual(stack) && data.getColor() == this) + { + return true; + } + } + return false; + } } diff --git a/src/minecraft/hydraulic/core/liquids/HydraulicNetwork.java b/src/minecraft/hydraulic/core/liquids/HydraulicNetwork.java index 48166742..9fae2fd5 100644 --- a/src/minecraft/hydraulic/core/liquids/HydraulicNetwork.java +++ b/src/minecraft/hydraulic/core/liquids/HydraulicNetwork.java @@ -35,7 +35,7 @@ public class HydraulicNetwork */ public void startProducing(TileEntity tileEntity, FluidPacket pack) { - if (tileEntity != null && pack.liquidStack != null && LiquidHandler.isEqual(stack, pack.liquidStack)) + if (tileEntity != null && pack.liquidStack != null && stack.isLiquidEqual(pack.liquidStack)) { this.producers.put(tileEntity, pack); } @@ -64,7 +64,7 @@ public class HydraulicNetwork */ public void startRequesting(TileEntity tileEntity, FluidPacket pack) { - if (tileEntity != null && pack.liquidStack != null && LiquidHandler.isEqual(stack, pack.liquidStack)) + if (tileEntity != null && pack.liquidStack != null && stack.isLiquidEqual(pack.liquidStack)) { this.consumers.put(tileEntity, pack); } diff --git a/src/minecraft/hydraulic/core/liquids/LiquidHandler.java b/src/minecraft/hydraulic/core/liquids/LiquidHandler.java index 32f6fced..84f51e99 100644 --- a/src/minecraft/hydraulic/core/liquids/LiquidHandler.java +++ b/src/minecraft/hydraulic/core/liquids/LiquidHandler.java @@ -103,7 +103,7 @@ public class LiquidHandler { for (LiquidData data : LiquidHandler.allowedLiquids) { - if (isEqual(stack, data)) { return data; } + if (stack.isLiquidEqual(data.getStack())) { return data; } } return unkown; } @@ -123,8 +123,7 @@ public class LiquidHandler Map l = LiquidDictionary.getLiquids(); for (Entry liquid : l.entrySet()) { - LiquidStack t = liquid.getValue(); - if (isEqual(t, stack)) { return liquid.getKey(); } + if (liquid.getValue().isLiquidEqual(stack)) { return liquid.getKey(); } } } return "unkown"; @@ -166,27 +165,7 @@ public class LiquidHandler if (data.getStack().itemID == id) { return data; } } return unkown; - } - - /** - * Compares a liquidStack to a sample stack stored in the LiquidData - */ - public static boolean isEqual(LiquidStack stack, LiquidData type) - { - if (stack == null || type == null) { return false; } - if (type.getStack().itemID == stack.itemID && type.getStack().itemMeta == stack.itemMeta) { return true; } - return false; - } - /** - * Compares one liquidStack to another LiquidStack - */ - public static boolean isEqual(LiquidStack stack, LiquidStack stack2) - { - if (stack == null || stack2 == null) - return false; - if (stack2.itemID == stack.itemID && stack2.itemMeta == stack.itemMeta) { return true; } - return false; - } + } /** * Consumes one item of a the ItemStack */