From 9bd0dfee26b1b5aa56ca9b7682468a9029305de4 Mon Sep 17 00:00:00 2001 From: Rseifert Date: Sun, 31 Mar 2013 02:16:29 -0400 Subject: [PATCH] Removed Liquid Data + Cleanup Go rid of LiquidData.class. Had my reasons for its use to store pressure, name, colorcode, etc. However, the new system doesn't need it and there are other ways to store the data i need. As well i no longer need to store the string name as LiquidDictionary can get the name for me --- .../fluidmech/client/render/RenderSink.java | 2 +- .../fluidmech/client/render/RenderTank.java | 2 +- src/minecraft/fluidmech/common/FluidMech.java | 6 +- .../fluidmech/common/block/BlockSink.java | 10 +- .../fluidmech/common/block/BlockTank.java | 10 +- .../common/machines/TileEntityMinorPump.java | 15 +- .../machines/TileEntityReleaseValve.java | 21 +- .../common/machines/TileEntitySink.java | 4 +- .../common/machines/TileEntityTank.java | 80 +----- .../common/machines/pipes/BlockPipe.java | 2 +- .../common/machines/pipes/TileEntityPipe.java | 4 +- src/minecraft/hydraulic/api/ColorCode.java | 94 ++----- .../hydraulic/core/HydraulicLoader.java | 22 -- src/minecraft/hydraulic/core/Hydraulics.java | 69 ------ .../core/liquidNetwork/FluidInfo.java | 139 ----------- .../core/liquidNetwork/LiquidData.java | 47 ---- .../core/liquidNetwork/LiquidHandler.java | 233 ------------------ .../hydraulic/fluidnetwork/FluidHelper.java | 151 ++++++++++++ .../FluidPressurePack.java | 2 +- .../HydraulicNetwork.java | 7 +- .../HydraulicNetworkHelper.java | 3 +- .../IFluidNetworkPart.java | 5 +- .../PathfinderCheckerPipes.java | 2 +- .../hydraulic/helpers/connectionHelper.java | 2 +- .../prefab/tile/TileEntityFluidDevice.java | 13 +- .../prefab/tile/TileEntityFluidStorage.java | 49 ++-- 26 files changed, 245 insertions(+), 749 deletions(-) delete mode 100644 src/minecraft/hydraulic/core/HydraulicLoader.java delete mode 100644 src/minecraft/hydraulic/core/Hydraulics.java delete mode 100644 src/minecraft/hydraulic/core/liquidNetwork/FluidInfo.java delete mode 100644 src/minecraft/hydraulic/core/liquidNetwork/LiquidData.java delete mode 100644 src/minecraft/hydraulic/core/liquidNetwork/LiquidHandler.java create mode 100644 src/minecraft/hydraulic/fluidnetwork/FluidHelper.java rename src/minecraft/hydraulic/{core/liquidNetwork => fluidnetwork}/FluidPressurePack.java (94%) rename src/minecraft/hydraulic/{core/liquidNetwork => fluidnetwork}/HydraulicNetwork.java (99%) rename src/minecraft/hydraulic/{core/liquidNetwork => fluidnetwork}/HydraulicNetworkHelper.java (93%) rename src/minecraft/hydraulic/{api => fluidnetwork}/IFluidNetworkPart.java (93%) rename src/minecraft/hydraulic/{core/path => fluidnetwork}/PathfinderCheckerPipes.java (97%) diff --git a/src/minecraft/fluidmech/client/render/RenderSink.java b/src/minecraft/fluidmech/client/render/RenderSink.java index 34cff1902..252d41e5f 100644 --- a/src/minecraft/fluidmech/client/render/RenderSink.java +++ b/src/minecraft/fluidmech/client/render/RenderSink.java @@ -57,7 +57,7 @@ public class RenderSink extends TileEntitySpecialRenderer break; } model.render(0.0625F); - renderWater(te.getStack()); + renderWater(te.getStoredLiquid()); GL11.glPopMatrix(); } diff --git a/src/minecraft/fluidmech/client/render/RenderTank.java b/src/minecraft/fluidmech/client/render/RenderTank.java index a5f86dadd..bdfeaaaf4 100644 --- a/src/minecraft/fluidmech/client/render/RenderTank.java +++ b/src/minecraft/fluidmech/client/render/RenderTank.java @@ -29,7 +29,7 @@ public class RenderTank extends TileEntitySpecialRenderer { int meta = te.getBlockMetadata(); int guageMeta = meta; - LiquidStack stack = te.getStack(); + LiquidStack stack = te.getStoredLiquid(); int pos = 0; if (stack != null) { diff --git a/src/minecraft/fluidmech/common/FluidMech.java b/src/minecraft/fluidmech/common/FluidMech.java index 1395ace90..75ff33e42 100644 --- a/src/minecraft/fluidmech/common/FluidMech.java +++ b/src/minecraft/fluidmech/common/FluidMech.java @@ -25,7 +25,7 @@ import fluidmech.common.machines.pipes.BlockPipe; import fluidmech.common.machines.pipes.TileEntityPipe; import fluidmech.common.machines.pipes.TileEntityPipe; import hydraulic.api.ColorCode; -import hydraulic.core.liquidNetwork.LiquidHandler; +import hydraulic.fluidnetwork.FluidHelper; import java.io.File; import java.util.logging.Logger; @@ -120,7 +120,7 @@ public class FluidMech extends DummyModContainer { FMLog.setParent(FMLLog.getLogger()); FMLog.info("Initializing..."); - MinecraftForge.EVENT_BUS.register(new LiquidHandler()); + MinecraftForge.EVENT_BUS.register(new FluidHelper()); instance = this; CONFIGURATION.load(); @@ -325,7 +325,7 @@ public class FluidMech extends DummyModContainer // add Default Liquids to current list, done last to let other mods use // there liquid data first if used LiquidStack waste = LiquidDictionary.getOrCreateLiquid("Waste", new LiquidStack(FluidMech.blockWasteLiquid, 1)); - LiquidHandler.addDefaultLiquids(); + FluidHelper.addDefaultLiquids(); FMLog.info("Done Loading"); } } diff --git a/src/minecraft/fluidmech/common/block/BlockSink.java b/src/minecraft/fluidmech/common/block/BlockSink.java index 8638f3814..bb0e5b8a1 100644 --- a/src/minecraft/fluidmech/common/block/BlockSink.java +++ b/src/minecraft/fluidmech/common/block/BlockSink.java @@ -1,6 +1,6 @@ package fluidmech.common.block; -import hydraulic.core.liquidNetwork.LiquidHandler; +import hydraulic.fluidnetwork.FluidHelper; import hydraulic.helpers.MetaGroup; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLiving; @@ -69,7 +69,7 @@ public class BlockSink extends BlockAdvanced if (filled != 0 && !entityplayer.capabilities.isCreativeMode) { - entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, LiquidHandler.consumeItem(current)); + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, FluidHelper.consumeItem(current)); } return true; @@ -85,7 +85,7 @@ public class BlockSink extends BlockAdvanced var13.removeColor(current); return true; } - LiquidStack stack = tank.getStack(); + LiquidStack stack = tank.getStoredLiquid(); if (stack != null) { ItemStack liquidItem = LiquidContainerRegistry.fillLiquidContainer(stack, current); @@ -102,12 +102,12 @@ public class BlockSink extends BlockAdvanced return false; else { - entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, LiquidHandler.consumeItem(current)); + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, FluidHelper.consumeItem(current)); } } else { - entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, LiquidHandler.consumeItem(current)); + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, FluidHelper.consumeItem(current)); entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, liquidItem); } } diff --git a/src/minecraft/fluidmech/common/block/BlockTank.java b/src/minecraft/fluidmech/common/block/BlockTank.java index 286c326d1..08afd11b6 100644 --- a/src/minecraft/fluidmech/common/block/BlockTank.java +++ b/src/minecraft/fluidmech/common/block/BlockTank.java @@ -1,6 +1,6 @@ package fluidmech.common.block; -import hydraulic.core.liquidNetwork.LiquidHandler; +import hydraulic.fluidnetwork.FluidHelper; import java.util.List; @@ -86,7 +86,7 @@ public class BlockTank extends BlockAdvanced if (filled != 0 && !entityplayer.capabilities.isCreativeMode) { - entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, LiquidHandler.consumeItem(current)); + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, FluidHelper.consumeItem(current)); } return true; @@ -96,7 +96,7 @@ public class BlockTank extends BlockAdvanced else { - LiquidStack stack = tank.getStack(); + LiquidStack stack = tank.getStoredLiquid(); if (stack != null) { ItemStack liquidItem = LiquidContainerRegistry.fillLiquidContainer(stack, current); @@ -113,12 +113,12 @@ public class BlockTank extends BlockAdvanced return false; else { - entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, LiquidHandler.consumeItem(current)); + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, FluidHelper.consumeItem(current)); } } else { - entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, LiquidHandler.consumeItem(current)); + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, FluidHelper.consumeItem(current)); entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, liquidItem); } } diff --git a/src/minecraft/fluidmech/common/machines/TileEntityMinorPump.java b/src/minecraft/fluidmech/common/machines/TileEntityMinorPump.java index 3c4a593d0..9b57e8364 100644 --- a/src/minecraft/fluidmech/common/machines/TileEntityMinorPump.java +++ b/src/minecraft/fluidmech/common/machines/TileEntityMinorPump.java @@ -5,8 +5,7 @@ import hydraulic.api.ColorCode; import hydraulic.api.IColorCoded; import hydraulic.api.IPipeConnection; import hydraulic.api.IReadOut; -import hydraulic.core.liquidNetwork.LiquidData; -import hydraulic.core.liquidNetwork.LiquidHandler; +import hydraulic.fluidnetwork.FluidHelper; import hydraulic.helpers.MetaGroup; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; @@ -153,8 +152,6 @@ public class TileEntityMinorPump extends TileEntityElectricityRunnable implement int blockID = worldObj.getBlockId(x, y, z); int meta = worldObj.getBlockMetadata(x, y, z); - LiquidData resource = LiquidHandler.getFromBlockAndMetadata(blockID, meta); - ITankContainer fillTarget = getFillTarget(); // TODO redo this @@ -170,16 +167,12 @@ public class TileEntityMinorPump extends TileEntityElectricityRunnable implement boolean drainBlock(Vector3 loc) { int blockID = worldObj.getBlockId(loc.intX(), loc.intY(), loc.intZ()); - int meta = worldObj.getBlockMetadata(loc.intX(), loc.intY(), loc.intZ()); - LiquidData resource = LiquidHandler.getFromBlockAndMetadata(blockID, meta); - - if (color.isValidLiquid(resource.getStack()) && meta == 0) + LiquidStack stack = FluidHelper.getLiquidFromBlockId(blockID); + if (color.isValidLiquid(stack)) { - - LiquidStack stack = resource.getStack(); stack.amount = LiquidContainerRegistry.BUCKET_VOLUME; - int fillAmmount = getFillTarget().fill(pipeConnection, this.color.getLiquidData().getStack(), true); + int fillAmmount = getFillTarget().fill(pipeConnection, stack, true); if (fillAmmount > 0) { diff --git a/src/minecraft/fluidmech/common/machines/TileEntityReleaseValve.java b/src/minecraft/fluidmech/common/machines/TileEntityReleaseValve.java index fa3594542..76051e45b 100644 --- a/src/minecraft/fluidmech/common/machines/TileEntityReleaseValve.java +++ b/src/minecraft/fluidmech/common/machines/TileEntityReleaseValve.java @@ -5,7 +5,6 @@ import hydraulic.api.ColorCode; import hydraulic.api.IColorCoded; import hydraulic.api.IPipeConnection; import hydraulic.api.IReadOut; -import hydraulic.core.liquidNetwork.LiquidHandler; import hydraulic.helpers.connectionHelper; import hydraulic.prefab.tile.TileEntityFluidDevice; @@ -13,7 +12,6 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; @@ -21,7 +19,6 @@ import net.minecraftforge.liquids.ILiquidTank; import net.minecraftforge.liquids.ITankContainer; import net.minecraftforge.liquids.LiquidContainerRegistry; import net.minecraftforge.liquids.LiquidStack; -import universalelectricity.prefab.tile.TileEntityAdvanced; public class TileEntityReleaseValve extends TileEntityFluidDevice implements IPipeConnection, IReadOut { @@ -130,17 +127,6 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements IPi return false; } - /** - * checks a liquidstack against its color code - * - * @param stack - * @return - */ - public boolean canAcceptLiquid(LiquidStack stack) - { - return !this.isRestricted() || canConnect(ColorCode.get(LiquidHandler.get(stack))); - } - /** * Collects info about the surrounding 6 tiles and orders them into drain-able(ITankContainer) * and fill-able(TileEntityPipes) instances @@ -181,11 +167,8 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements IPi LiquidStack ll = tanks[t].getLiquid(); if (ll != null && ll.amount > 0 && ll.amount > 0) { - if (this.canAcceptLiquid(ll)) - { - this.input.add((ITankContainer) ent); - break; - } + this.input.add((ITankContainer) ent); + break; } } } diff --git a/src/minecraft/fluidmech/common/machines/TileEntitySink.java b/src/minecraft/fluidmech/common/machines/TileEntitySink.java index 9de109098..58a69750e 100644 --- a/src/minecraft/fluidmech/common/machines/TileEntitySink.java +++ b/src/minecraft/fluidmech/common/machines/TileEntitySink.java @@ -5,7 +5,7 @@ import java.util.Random; import fluidmech.common.FluidMech; import hydraulic.api.ColorCode; import hydraulic.api.IColorCoded; -import hydraulic.core.liquidNetwork.LiquidHandler; +import hydraulic.fluidnetwork.FluidHelper; import hydraulic.prefab.tile.TileEntityFluidStorage; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; @@ -95,4 +95,6 @@ public class TileEntitySink extends TileEntityFluidStorage implements IPacketRec { return ColorCode.BLUE; } + + } diff --git a/src/minecraft/fluidmech/common/machines/TileEntityTank.java b/src/minecraft/fluidmech/common/machines/TileEntityTank.java index 6ddf07dae..7c06f4392 100644 --- a/src/minecraft/fluidmech/common/machines/TileEntityTank.java +++ b/src/minecraft/fluidmech/common/machines/TileEntityTank.java @@ -3,33 +3,21 @@ package fluidmech.common.machines; import fluidmech.common.FluidMech; import hydraulic.api.ColorCode; import hydraulic.api.IColorCoded; -import hydraulic.api.IPipeConnection; -import hydraulic.api.IReadOut; -import hydraulic.core.liquidNetwork.LiquidData; -import hydraulic.core.liquidNetwork.LiquidHandler; -import hydraulic.helpers.connectionHelper; -import hydraulic.prefab.tile.TileEntityFluidDevice; +import hydraulic.fluidnetwork.FluidHelper; import hydraulic.prefab.tile.TileEntityFluidStorage; - -import java.util.Random; - import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.liquids.ILiquidTank; import net.minecraftforge.liquids.ITankContainer; import net.minecraftforge.liquids.LiquidContainerRegistry; import net.minecraftforge.liquids.LiquidStack; -import net.minecraftforge.liquids.LiquidTank; import universalelectricity.core.block.IConductor; import universalelectricity.core.block.IConnectionProvider; import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.PacketManager; -import universalelectricity.prefab.tile.TileEntityAdvanced; import com.google.common.io.ByteArrayDataInput; @@ -60,7 +48,7 @@ public class TileEntityTank extends TileEntityFluidStorage implements IPacketRec if (ticks % (random.nextInt(4) * 5 + 10) >= 0) { this.fillTanksAround(); - this.fillTankBellow(); + this.tank.drain(this.fillSide(this.getStoredLiquid(), ForgeDirection.DOWN, true), true); } if ((this.tank.getLiquid() == null && originalVolume != 0) || (this.tank.getLiquid() != null && this.tank.getLiquid().amount != originalVolume)) @@ -80,9 +68,9 @@ public class TileEntityTank extends TileEntityFluidStorage implements IPacketRec @Override public Packet getDescriptionPacket() { - if (this.getStack() != null) + if (this.getStoredLiquid() != null) { - return PacketManager.getPacket(FluidMech.CHANNEL, this, this.getStack().itemID, this.getStack().amount, this.getStack().itemMeta); + return PacketManager.getPacket(FluidMech.CHANNEL, this, this.getStoredLiquid().itemID, this.getStoredLiquid().amount, this.getStoredLiquid().itemMeta); } else { @@ -90,7 +78,7 @@ public class TileEntityTank extends TileEntityFluidStorage implements IPacketRec } } - public LiquidStack getStack() + public LiquidStack getStoredLiquid() { return tank.getLiquid(); } @@ -113,14 +101,7 @@ public class TileEntityTank extends TileEntityFluidStorage implements IPacketRec @Override public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) { - if (resource == null || (this.getColor() != ColorCode.NONE && !getColor().getLiquidData().getStack().isLiquidEqual(resource))) - { - return 0; - } - - LiquidData data = LiquidHandler.get(resource); - - if ((data.getCanFloat() && from == ForgeDirection.DOWN) || !data.getCanFloat() && from == ForgeDirection.UP) + if (resource == null || (this.getColor() != ColorCode.NONE && !getColor().isValidLiquid(resource))) { return 0; } @@ -132,12 +113,7 @@ public class TileEntityTank extends TileEntityFluidStorage implements IPacketRec { if (this.isFull()) { - int change = 1; - if (LiquidHandler.get(resource).getCanFloat()) - { - change = -1; - } - TileEntity tank = worldObj.getBlockTileEntity(xCoord, yCoord + change, zCoord); + TileEntity tank = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord); if (tank instanceof TileEntityTank) { return ((TileEntityTank) tank).fill(0, resource, doFill); @@ -165,7 +141,7 @@ public class TileEntityTank extends TileEntityFluidStorage implements IPacketRec } TileEntity[] ents = this.getAdjacentConnections(); - + /* SUM VOLUME UP FOR ALL CONNECTED TANKS */ int commonVol = this.tank.getLiquid().amount; int equalVol = commonVol; @@ -198,11 +174,11 @@ public class TileEntityTank extends TileEntityFluidStorage implements IPacketRec if (target == null) { - filling = LiquidHandler.getStack(this.tank.getLiquid(), equalVol); + filling = FluidHelper.getStack(this.tank.getLiquid(), equalVol); } else if (target.amount < equalVol) { - filling = LiquidHandler.getStack(this.tank.getLiquid(), equalVol - target.amount); + filling = FluidHelper.getStack(this.tank.getLiquid(), equalVol - target.amount); } else { @@ -215,42 +191,6 @@ public class TileEntityTank extends TileEntityFluidStorage implements IPacketRec } } - /** Will fill the ITankContainer bellow with up to one bucket of liquid a request */ - public void fillTankBellow() - { - if (this.tank.getLiquid() == null || this.tank.getLiquid().amount <= 0) - { - return; - } - /* GET DATA FOR THE LIQUID IN THE INTERNAL TANK */ - LiquidData liquidData = LiquidHandler.get(this.tank.getLiquid()); - - if (liquidData != null) - { - /* GET THE TILE ABOVE OR BELLOW BASE ON LIQUID DATA */ - ForgeDirection fillDirection = liquidData.getCanFloat() ? ForgeDirection.UP : ForgeDirection.DOWN; - TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord, yCoord + fillDirection.offsetY, zCoord); - - if (tileEntity instanceof ITankContainer) - { - /* DO CHECK FOR NON-MATCHING COLOR CODE */ - if (tileEntity instanceof IColorCoded && ((IColorCoded) tileEntity).getColor() != ColorCode.NONE && ((IColorCoded) tileEntity).getColor() != this.getColor()) - { - return; - } - /* CAN ONLY TRADE ONE BUCKET AT A TIME */ - int vol = LiquidContainerRegistry.BUCKET_VOLUME; - if (this.tank.getLiquid().amount < vol) - { - vol = this.tank.getLiquid().amount; - } - /* FILL THE ITANKCONTAINER BELLOW THEN DRAIN THE INTERAL TANK IN THIS */ - int fillAmmount = ((ITankContainer) tileEntity).fill(fillDirection, LiquidHandler.getStack(this.tank.getLiquid(), vol), true); - this.tank.drain(fillAmmount, true); - } - } - } - @Override public void setColor(Object obj) { diff --git a/src/minecraft/fluidmech/common/machines/pipes/BlockPipe.java b/src/minecraft/fluidmech/common/machines/pipes/BlockPipe.java index 41ca31f9f..b8bcce992 100644 --- a/src/minecraft/fluidmech/common/machines/pipes/BlockPipe.java +++ b/src/minecraft/fluidmech/common/machines/pipes/BlockPipe.java @@ -1,6 +1,6 @@ package fluidmech.common.machines.pipes; -import hydraulic.api.IFluidNetworkPart; +import hydraulic.fluidnetwork.IFluidNetworkPart; import java.util.List; diff --git a/src/minecraft/fluidmech/common/machines/pipes/TileEntityPipe.java b/src/minecraft/fluidmech/common/machines/pipes/TileEntityPipe.java index 90910f6bf..10415606a 100644 --- a/src/minecraft/fluidmech/common/machines/pipes/TileEntityPipe.java +++ b/src/minecraft/fluidmech/common/machines/pipes/TileEntityPipe.java @@ -3,10 +3,10 @@ package fluidmech.common.machines.pipes; import fluidmech.common.FluidMech; import hydraulic.api.ColorCode; import hydraulic.api.IColorCoded; -import hydraulic.api.IFluidNetworkPart; import hydraulic.api.IPipeConnection; import hydraulic.api.IReadOut; -import hydraulic.core.liquidNetwork.HydraulicNetwork; +import hydraulic.fluidnetwork.HydraulicNetwork; +import hydraulic.fluidnetwork.IFluidNetworkPart; import java.util.Random; diff --git a/src/minecraft/hydraulic/api/ColorCode.java b/src/minecraft/hydraulic/api/ColorCode.java index 6078ba01d..be1a6a16f 100644 --- a/src/minecraft/hydraulic/api/ColorCode.java +++ b/src/minecraft/hydraulic/api/ColorCode.java @@ -1,11 +1,11 @@ package hydraulic.api; -import hydraulic.core.liquidNetwork.LiquidData; -import hydraulic.core.liquidNetwork.LiquidHandler; +import hydraulic.fluidnetwork.FluidHelper; import java.util.ArrayList; import java.util.List; +import net.minecraftforge.liquids.LiquidDictionary; import net.minecraftforge.liquids.LiquidStack; public enum ColorCode @@ -36,14 +36,6 @@ public enum ColorCode { return ColorCode.values()[((Integer) obj)]; } - else if (obj instanceof LiquidData) - { - return ((LiquidData) obj).getColor(); - } - else if (obj instanceof LiquidStack) - { - return LiquidHandler.get((LiquidStack) obj).getColor(); - } else if (obj instanceof ColorCode) { return (ColorCode) obj; @@ -61,68 +53,12 @@ public enum ColorCode 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; - } - - public List getAllLiquidStack() - { - List validStacks = new ArrayList(); - for (LiquidData data : getAllLiquidData()) - { - validStacks.add(data.getStack()); - } - return validStacks; - } - - public LiquidStack[] getArrayLiquidStacks() - { - List validStacks = new ArrayList(); - for (LiquidData data : getAllLiquidData()) - { - validStacks.add(data.getStack()); - } - LiquidStack[] stacks = new LiquidStack[validStacks.size()]; - for(int i =0; i < validStacks.size();i++) - { - stacks[i] = validStacks.get(i); - } - return stacks; - } - /** * checks to see if the liquidStack is valid for the given color */ public boolean isValidLiquid(LiquidStack stack) { - if (this == NONE || this.getAllLiquidData().size() == 0) + if (this != BLUE && this != RED && this != BLACK && this != YELLOW && this != ORANGE) { return true; } @@ -130,13 +66,25 @@ public enum ColorCode { return false; } - - for (LiquidData data : LiquidHandler.allowedLiquids) + else if (this == BLUE && stack.isLiquidEqual(LiquidDictionary.getCanonicalLiquid("Water"))) { - if (data.getStack().isLiquidEqual(stack) && data.getColor() == this) - { - return true; - } + return true; + } + else if (this == RED && stack.isLiquidEqual(LiquidDictionary.getCanonicalLiquid("Lava"))) + { + return true; + } + else if (this == BLACK && stack.isLiquidEqual(LiquidDictionary.getCanonicalLiquid("Oil"))) + { + return true; + } + else if (this == YELLOW && stack.isLiquidEqual(LiquidDictionary.getCanonicalLiquid("Fuel"))) + { + return true; + } + else if (this == ORANGE && stack.isLiquidEqual(LiquidDictionary.getCanonicalLiquid("Steam"))) + { + return true; } return false; } diff --git a/src/minecraft/hydraulic/core/HydraulicLoader.java b/src/minecraft/hydraulic/core/HydraulicLoader.java deleted file mode 100644 index 38725af5d..000000000 --- a/src/minecraft/hydraulic/core/HydraulicLoader.java +++ /dev/null @@ -1,22 +0,0 @@ -package hydraulic.core; - -import cpw.mods.fml.common.FMLLog; - -public class HydraulicLoader -{ - public static final HydraulicLoader INSTANCE = new HydraulicLoader(); - - public static boolean isInitialized = false; - - public void initiate() - { - if (!isInitialized) - { - // MinecraftForge.EVENT_BUS.register(this); - - FMLLog.finest("Hydraulics v" + Hydraulics.VERSION + " loaded without error!"); - - isInitialized = true; - } - } -} diff --git a/src/minecraft/hydraulic/core/Hydraulics.java b/src/minecraft/hydraulic/core/Hydraulics.java deleted file mode 100644 index c28071e6b..000000000 --- a/src/minecraft/hydraulic/core/Hydraulics.java +++ /dev/null @@ -1,69 +0,0 @@ -package hydraulic.core; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import net.minecraftforge.common.Configuration; -import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.Loader; - -public class Hydraulics -{ - /** - * The version of the Universal Electricity API. - */ - public static final int MAJOR_VERSION = 0; - public static final int MINOR_VERSION = 0; - public static final int REVISION_VERSION = 1; - public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + REVISION_VERSION; - - /** - * The Universal Electricity configuration file. - */ - public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "hydraulics/hydraulics.cfg")); - - - - /** - * A list of all mods Universal Electricity has loaded. - */ - public static final List mods = new ArrayList(); - - /** - * You must register your mod with Universal Electricity. Call this in your mod's - * pre-initialization stage. - */ - public static void register(Object mod, int major, int minor, int revision, boolean strict) - { - if (MAJOR_VERSION != major) - { - throw new RuntimeException("A Hydraulics mod " + mod.getClass().getSimpleName() + " is way too old! Make sure it is update to v" + major + "." + minor + "." + revision); - } - - if (MINOR_VERSION < minor) - { - throw new RuntimeException("A Hydraulics mod " + mod.getClass().getSimpleName() + " is too old! Make sure it is update to v" + major + "." + minor + "." + revision); - } - - if (REVISION_VERSION < revision) - { - if (strict) - { - throw new RuntimeException("A Hydraulics mod " + mod.getClass().getSimpleName() + " is too old! Require v" + major + "." + minor + "." + revision); - } - else - { - FMLLog.warning("The version of Hydraulics detected is not the recommended version by the mod " + mod.getClass().getSimpleName() + ". Odd things might happen. Recommended to try v" + major + "." + minor + "." + revision); - } - } - - mods.add(mod); - - FMLLog.fine(mod.getClass().getSimpleName() + " has been registered to Hydraulics."); - - HydraulicLoader.INSTANCE.initiate(); - } - - -} diff --git a/src/minecraft/hydraulic/core/liquidNetwork/FluidInfo.java b/src/minecraft/hydraulic/core/liquidNetwork/FluidInfo.java deleted file mode 100644 index 207d5b0cc..000000000 --- a/src/minecraft/hydraulic/core/liquidNetwork/FluidInfo.java +++ /dev/null @@ -1,139 +0,0 @@ -package hydraulic.core.liquidNetwork; - -/** - * An easy way to display information on electricity. - * - * @author Calclavia - */ - -public class FluidInfo -{ - public static enum FluidUnits - { - FLOW_Rate("FLOW", "I"), PRESSURE("Psi", "P"), FORCE("Force", "N"), RESISTANCE("Ohm", "R"); - - public String name; - public String symbol; - - private FluidUnits(String name, String symbol) - { - this.name = name; - this.symbol = symbol; - } - - public String getPlural() - { - return this.name + "s"; - } - } - - public static enum MeasurementUnit - { - MICRO("Micro", "u", 0.000001), MILLI("Milli", "m", 0.001), KILO("Kilo", "k", 1000), MEGA("Mega", "M", 1000000); - - public String name; - public String symbol; - public double value; - - private MeasurementUnit(String name, String symbol, double value) - { - this.name = name; - this.symbol = symbol; - this.value = value; - } - - public String getName(boolean isSymbol) - { - if (isSymbol) - { - return symbol; - } - else - { - return name; - } - } - - public double process(double value) - { - return value / this.value; - } - } - - - - /** - * Displays the unit as text. Works only for positive numbers. - */ - public static String getDisplay(double value, FluidUnits unit, int decimalPlaces, boolean isShort) - { - String unitName = unit.name; - - if (isShort) - { - unitName = unit.symbol; - } - else if (value > 1) - { - unitName = unit.getPlural(); - } - - if (value == 0) { return value + " " + unitName; } - - if (value <= MeasurementUnit.MILLI.value) { return roundDecimals(MeasurementUnit.MICRO.process(value), decimalPlaces) + " " + MeasurementUnit.MICRO.getName(isShort) + unitName; } - - if (value < 1) { return roundDecimals(MeasurementUnit.MILLI.process(value), decimalPlaces) + " " + MeasurementUnit.MILLI.getName(isShort) + unitName; } - - if (value > MeasurementUnit.MEGA.value) { return roundDecimals(MeasurementUnit.MEGA.process(value), decimalPlaces) + " " + MeasurementUnit.MEGA.getName(isShort) + unitName; } - - if (value > MeasurementUnit.KILO.value) { return roundDecimals(MeasurementUnit.KILO.process(value), decimalPlaces) + " " + MeasurementUnit.KILO.getName(isShort) + unitName; } - - return roundDecimals(value, decimalPlaces) + " " + unitName; - } - - public static String getDisplay(double value, FluidUnits unit) - { - return getDisplay(value, unit, 2, false); - } - - public static String getDisplayShort(double value, FluidUnits unit) - { - return getDisplay(value, unit, 2, true); - } - - public static String getDisplayShort(double value, FluidUnits unit, int decimalPlaces) - { - return getDisplay(value, unit, decimalPlaces, true); - } - - public static String getDisplaySimple(double value, FluidUnits unit, int decimalPlaces) - { - if (value > 1) - { - if (decimalPlaces < 1) { return (int) value + " " + unit.getPlural(); } - - return roundDecimals(value, decimalPlaces) + " " + unit.getPlural(); - } - - if (decimalPlaces < 1) { return (int) value + " " + unit.name; } - - return roundDecimals(value, decimalPlaces) + " " + unit.name; - } - - /** - * Rounds a number to a specific number place places - * - * @param The number - * @return The rounded number - */ - public static double roundDecimals(double d, int decimalPlaces) - { - int j = (int) (d * Math.pow(10, decimalPlaces)); - return j / (double) Math.pow(10, decimalPlaces); - } - - public static double roundDecimals(double d) - { - return roundDecimals(d, 2); - } -} diff --git a/src/minecraft/hydraulic/core/liquidNetwork/LiquidData.java b/src/minecraft/hydraulic/core/liquidNetwork/LiquidData.java deleted file mode 100644 index 2bb71cc20..000000000 --- a/src/minecraft/hydraulic/core/liquidNetwork/LiquidData.java +++ /dev/null @@ -1,47 +0,0 @@ -package hydraulic.core.liquidNetwork; - -import hydraulic.api.ColorCode; -import net.minecraftforge.liquids.LiquidStack; - -public class LiquidData -{ - private boolean isAGas; - private int defaultPressure; - private LiquidStack sampleStack; - private String name; - private ColorCode color; - - public LiquidData(String name, LiquidStack stack,ColorCode color, boolean gas, int dPressure) - { - this.sampleStack = stack; - this.isAGas = gas; - this.defaultPressure = dPressure; - this.name = name; - this.color = color; - } - - public String getName() - { - if (name != null || !name.equalsIgnoreCase("")) { return name; } - return "unknown"; - } - public int getPressure() - { - return defaultPressure; - } - public LiquidStack getStack() - { - if (sampleStack != null) { return sampleStack; } - return new LiquidStack(0,1); - } - public boolean getCanFloat() - { - return isAGas; - } - public ColorCode getColor() - { - if (color != null) { return color; } - return ColorCode.NONE; - } - -} diff --git a/src/minecraft/hydraulic/core/liquidNetwork/LiquidHandler.java b/src/minecraft/hydraulic/core/liquidNetwork/LiquidHandler.java deleted file mode 100644 index 4b9c9cc67..000000000 --- a/src/minecraft/hydraulic/core/liquidNetwork/LiquidHandler.java +++ /dev/null @@ -1,233 +0,0 @@ -package hydraulic.core.liquidNetwork; - -import hydraulic.api.ColorCode; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.logging.Logger; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraftforge.event.ForgeSubscribe; -import net.minecraftforge.liquids.LiquidDictionary; -import net.minecraftforge.liquids.LiquidStack; -import cpw.mods.fml.common.FMLLog; - -public class LiquidHandler -{ - // Active list of all Liquid that can be used// - public static List allowedLiquids = new ArrayList(); - // PreDefinned Liquids// - public static LiquidData steam; - public static LiquidData water; - public static LiquidData lava; - @Deprecated - public static LiquidData unkown; - public static LiquidData waste; - public static LiquidData milk; - - public static Logger FMLog = Logger.getLogger("LiquidHandler"); - - /** - * Called to add the default liquids to the allowed list - */ - public static void addDefaultLiquids() - { - FMLog.setParent(FMLLog.getLogger()); - water = new LiquidData("water", LiquidDictionary.getOrCreateLiquid("Water", new LiquidStack(Block.waterStill, 1)), ColorCode.BLUE, false, 60); - allowedLiquids.add(water); - - lava = new LiquidData("Lava", LiquidDictionary.getOrCreateLiquid("Lava", new LiquidStack(Block.lavaStill, 1)), ColorCode.RED, false, 40); - allowedLiquids.add(lava); - - unkown = new LiquidData("Unknown", LiquidDictionary.getOrCreateLiquid("Unknown", new LiquidStack(20, 1)), ColorCode.NONE, false, 32); - allowedLiquids.add(unkown); - - FMLog.setParent(FMLLog.getLogger()); - for (LiquidData data : allowedLiquids) - { - FMLog.info(data.getName() + " registered as a liquid"); - } - - } - - @ForgeSubscribe - public void liquidRegisterEvent(LiquidDictionary.LiquidRegisterEvent event) - { - if (event.Name.equalsIgnoreCase("UraniumHexafluoride")) - { - allowedLiquids.add(new LiquidData("UraniumHexafluoride", event.Liquid, ColorCode.GREEN, true, 100)); - } - else if (event.Name.equalsIgnoreCase("methane")) - { - allowedLiquids.add(new LiquidData("methane", event.Liquid, ColorCode.LIME, true, 100)); - } - else if (event.Name.equalsIgnoreCase("oil")) - { - allowedLiquids.add(new LiquidData("oil", event.Liquid, ColorCode.BLACK, true, 50)); - } - else if (event.Name.equalsIgnoreCase("fuel")) - { - allowedLiquids.add(new LiquidData("fuel", event.Liquid, ColorCode.YELLOW, true, 50)); - } - else if (event.Name.equalsIgnoreCase("steam")) - { - steam = new LiquidData("steam", event.Liquid, ColorCode.ORANGE, true, 100); - allowedLiquids.add(steam); - } - else if (event.Name.equalsIgnoreCase("Waste")) - { - waste = new LiquidData("Waste", event.Liquid, ColorCode.BROWN, false, 40); - allowedLiquids.add(waste); - } - else if (event.Name.equalsIgnoreCase("Milk")) - { - milk = new LiquidData("Milk", event.Liquid, ColorCode.WHITE, false, 50); - allowedLiquids.add(milk); - } - } - - /** - * Gets the LiquidData linked to the liquid by name - * - * @param name - String name, not case sensitive - * - * @return the data - * - * Note: @LiquidHandler.unkown is the same as null and should be treated that way. - */ - public static LiquidData get(String name) - { - for (LiquidData data : LiquidHandler.allowedLiquids) - { - if (data.getName().equalsIgnoreCase(name)) - { - return data; - } - } - return unkown; - } - - /** - * Gets the LiquidData linked to the liquidStack - * - * @param stack - @LiquidStack - * @return the data - * - * Note: @LiquidHandler.unkown is the same as null and should be treated that way. - */ - public static LiquidData get(LiquidStack stack) - { - for (LiquidData data : LiquidHandler.allowedLiquids) - { - if (stack.isLiquidEqual(data.getStack())) - { - return data; - } - } - return unkown; - } - - /** - * Gets the name of a LiquidStack using the LiquidData name or Value hidden in the LiquidStack - * map stored at @LiquidDictionary - * - * @param stack - @LiquidStack - * @return - (String) Name of the Stack or unkown if one couldn't be found - */ - public static String getName(LiquidStack stack) - { - if (get(stack) != unkown) - { - return get(stack).getName(); - } - else - { - Map l = LiquidDictionary.getLiquids(); - for (Entry liquid : l.entrySet()) - { - if (liquid.getValue().isLiquidEqual(stack)) - { - return liquid.getKey(); - } - } - } - return "unkown"; - } - - /** - * Creates a new LiquidStack using the sample stack from the data - * - * @param liquidData - liquidData being used to create the stack - * @param vol - amount or volume of the stack - * @return a new @LiquidStack - */ - public static LiquidStack getStack(LiquidData liquidData, int vol) - { - if (liquidData == null) - { - return null; - } - return new LiquidStack(liquidData.getStack().itemID, vol, liquidData.getStack().itemMeta); - } - - /** - * Creates a new LiquidStack using the sample stack - * - * @param stack - liquidLiquid being used to create the stack - * @param vol - amount or volume of the stack - * @return a new @LiquidStack - */ - public static LiquidStack getStack(LiquidStack stack, int vol) - { - if (stack == null) - { - return null; - } - return new LiquidStack(stack.itemID, vol, stack.itemMeta); - } - - /** - * gets the LiquidData from the blockID and metadata - * - * @param blockID - id used to reference the block in @Block - * @param blockMeta - the blocks sub id from 0-15. -1 will ignore metadata - * @return LiquidData if there is one for this block or unkown in place of null/not found - */ - public static LiquidData getFromBlockAndMetadata(int blockID, int blockMeta) - { - for (LiquidData data : allowedLiquids) - { - if (data.getStack().itemID == blockID) - { - return data; - } - } - return unkown; - } - - /** - * Consumes one item of a the ItemStack - */ - public static ItemStack consumeItem(ItemStack stack) - { - if (stack.stackSize == 1) - { - if (stack.getItem().hasContainerItem()) - { - return stack.getItem().getContainerItemStack(stack); - } - else - { - return null; - } - } - else - { - stack.splitStack(1); - return stack; - } - } -} diff --git a/src/minecraft/hydraulic/fluidnetwork/FluidHelper.java b/src/minecraft/hydraulic/fluidnetwork/FluidHelper.java new file mode 100644 index 000000000..fdeafa232 --- /dev/null +++ b/src/minecraft/hydraulic/fluidnetwork/FluidHelper.java @@ -0,0 +1,151 @@ +package hydraulic.fluidnetwork; + +import hydraulic.api.ColorCode; + +import java.util.HashMap; +import java.util.logging.Logger; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.liquids.ILiquid; +import net.minecraftforge.liquids.LiquidContainerRegistry; +import net.minecraftforge.liquids.LiquidDictionary; +import net.minecraftforge.liquids.LiquidStack; + +public class FluidHelper +{ + + private static HashMap getMaxFlowPerRequest = new HashMap(); + + public static Logger FMLog = Logger.getLogger("LiquidHandler"); + + /** + * Called to add the default liquids to the allowed list + */ + public static void addDefaultLiquids() + { + + } + + @ForgeSubscribe + public void liquidRegisterEvent(LiquidDictionary.LiquidRegisterEvent event) + { + if (event.Name.equalsIgnoreCase("UraniumHexafluoride")) + { + getMaxFlowPerRequest.put(event.Liquid, 1000); + } + else if (event.Name.equalsIgnoreCase("methane")) + { + getMaxFlowPerRequest.put(event.Liquid, 1000); + } + else if (event.Name.equalsIgnoreCase("steam")) + { + getMaxFlowPerRequest.put(event.Liquid, 2000); + } + } + + public int getDefaultFlowRate(LiquidStack stack) + { + if (getMaxFlowPerRequest.containsKey(stack)) + { + return getMaxFlowPerRequest.get(stack); + } + return 500; + } + + /** + * Creates a new LiquidStack using the sample stack + * + * @param stack - liquidLiquid being used to create the stack + * @param vol - amount or volume of the stack + * @return a new @LiquidStack + */ + public static LiquidStack getStack(LiquidStack stack, int vol) + { + if (stack == null) + { + return null; + } + return new LiquidStack(stack.itemID, vol, stack.itemMeta); + } + + /** + * Consumes one item of a the ItemStack + */ + public static ItemStack consumeItem(ItemStack stack) + { + if (stack.stackSize == 1) + { + if (stack.getItem().hasContainerItem()) + { + return stack.getItem().getContainerItemStack(stack); + } + else + { + return null; + } + } + else + { + stack.splitStack(1); + return stack; + } + } + + /** + * gets the blockID/ItemID of the Still liquid + * + * @param id - blockID + * @return will return -1 if its not a valid liquid Block + */ + public static int getLiquidId(int id) + { + if (id == Block.waterStill.blockID || id == Block.waterMoving.blockID) + { + return Block.waterStill.blockID; + } + else if (id == Block.lavaStill.blockID || id == Block.lavaMoving.blockID) + { + return Block.lavaStill.blockID; + } + else if (Block.blocksList[id] instanceof ILiquid) + { + return ((ILiquid) Block.blocksList[id]).stillLiquidId(); + } + else + { + return -1; + } + } + + /** + * gets the liquidStack of the block + * + * @param id - block's ID + */ + public static LiquidStack getLiquidFromBlockId(int id) + { + if (id == Block.waterStill.blockID || id == Block.waterMoving.blockID) + { + return new LiquidStack(Block.waterStill.blockID, LiquidContainerRegistry.BUCKET_VOLUME, 0); + } + else if (id == Block.lavaStill.blockID || id == Block.lavaMoving.blockID) + { + return new LiquidStack(Block.lavaStill.blockID, LiquidContainerRegistry.BUCKET_VOLUME, 0); + } + else if (Block.blocksList[id] instanceof ILiquid) + { + ILiquid liquid = (ILiquid) Block.blocksList[id]; + if (liquid.isMetaSensitive()) + { + return new LiquidStack(liquid.stillLiquidId(), LiquidContainerRegistry.BUCKET_VOLUME, liquid.stillLiquidMeta()); + } + else + { + return new LiquidStack(liquid.stillLiquidId(), LiquidContainerRegistry.BUCKET_VOLUME, 0); + } + } + return null; + } +} diff --git a/src/minecraft/hydraulic/core/liquidNetwork/FluidPressurePack.java b/src/minecraft/hydraulic/fluidnetwork/FluidPressurePack.java similarity index 94% rename from src/minecraft/hydraulic/core/liquidNetwork/FluidPressurePack.java rename to src/minecraft/hydraulic/fluidnetwork/FluidPressurePack.java index 259ea373e..786ca010d 100644 --- a/src/minecraft/hydraulic/core/liquidNetwork/FluidPressurePack.java +++ b/src/minecraft/hydraulic/fluidnetwork/FluidPressurePack.java @@ -1,4 +1,4 @@ -package hydraulic.core.liquidNetwork; +package hydraulic.fluidnetwork; import net.minecraftforge.liquids.LiquidStack; diff --git a/src/minecraft/hydraulic/core/liquidNetwork/HydraulicNetwork.java b/src/minecraft/hydraulic/fluidnetwork/HydraulicNetwork.java similarity index 99% rename from src/minecraft/hydraulic/core/liquidNetwork/HydraulicNetwork.java rename to src/minecraft/hydraulic/fluidnetwork/HydraulicNetwork.java index f75fad127..eb71d990a 100644 --- a/src/minecraft/hydraulic/core/liquidNetwork/HydraulicNetwork.java +++ b/src/minecraft/hydraulic/fluidnetwork/HydraulicNetwork.java @@ -1,8 +1,6 @@ -package hydraulic.core.liquidNetwork; +package hydraulic.fluidnetwork; import hydraulic.api.ColorCode; -import hydraulic.api.IFluidNetworkPart; -import hydraulic.core.path.PathfinderCheckerPipes; import hydraulic.helpers.connectionHelper; import java.util.ArrayList; @@ -17,6 +15,7 @@ import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.liquids.ILiquidTank; import net.minecraftforge.liquids.ITankContainer; import net.minecraftforge.liquids.LiquidContainerRegistry; +import net.minecraftforge.liquids.LiquidDictionary; import net.minecraftforge.liquids.LiquidStack; import net.minecraftforge.liquids.LiquidTank; import universalelectricity.core.block.IConnectionProvider; @@ -649,7 +648,7 @@ public class HydraulicNetwork { return "Zero"; } - return String.format("%d/%d %S Stored", combinedStorage.getLiquid().amount / LiquidContainerRegistry.BUCKET_VOLUME, combinedStorage.getCapacity() / LiquidContainerRegistry.BUCKET_VOLUME, LiquidHandler.getName(this.combinedStorage.getLiquid())); + return String.format("%d/%d %S Stored", combinedStorage.getLiquid().amount / LiquidContainerRegistry.BUCKET_VOLUME, combinedStorage.getCapacity() / LiquidContainerRegistry.BUCKET_VOLUME, LiquidDictionary.findLiquidName(this.combinedStorage.getLiquid())); } public ILiquidTank getTank() diff --git a/src/minecraft/hydraulic/core/liquidNetwork/HydraulicNetworkHelper.java b/src/minecraft/hydraulic/fluidnetwork/HydraulicNetworkHelper.java similarity index 93% rename from src/minecraft/hydraulic/core/liquidNetwork/HydraulicNetworkHelper.java rename to src/minecraft/hydraulic/fluidnetwork/HydraulicNetworkHelper.java index 5ec0966c0..b6198c8f0 100644 --- a/src/minecraft/hydraulic/core/liquidNetwork/HydraulicNetworkHelper.java +++ b/src/minecraft/hydraulic/fluidnetwork/HydraulicNetworkHelper.java @@ -1,6 +1,5 @@ -package hydraulic.core.liquidNetwork; +package hydraulic.fluidnetwork; -import hydraulic.api.IFluidNetworkPart; import java.util.ArrayList; import java.util.EnumSet; diff --git a/src/minecraft/hydraulic/api/IFluidNetworkPart.java b/src/minecraft/hydraulic/fluidnetwork/IFluidNetworkPart.java similarity index 93% rename from src/minecraft/hydraulic/api/IFluidNetworkPart.java rename to src/minecraft/hydraulic/fluidnetwork/IFluidNetworkPart.java index e57d66a0d..858b57b1e 100644 --- a/src/minecraft/hydraulic/api/IFluidNetworkPart.java +++ b/src/minecraft/hydraulic/fluidnetwork/IFluidNetworkPart.java @@ -1,7 +1,8 @@ -package hydraulic.api; +package hydraulic.fluidnetwork; import universalelectricity.core.block.IConnectionProvider; -import hydraulic.core.liquidNetwork.HydraulicNetwork; +import hydraulic.api.IColorCoded; +import hydraulic.api.IPipeConnection; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.liquids.ILiquidTank; diff --git a/src/minecraft/hydraulic/core/path/PathfinderCheckerPipes.java b/src/minecraft/hydraulic/fluidnetwork/PathfinderCheckerPipes.java similarity index 97% rename from src/minecraft/hydraulic/core/path/PathfinderCheckerPipes.java rename to src/minecraft/hydraulic/fluidnetwork/PathfinderCheckerPipes.java index 42bcc46c3..11c77444f 100644 --- a/src/minecraft/hydraulic/core/path/PathfinderCheckerPipes.java +++ b/src/minecraft/hydraulic/fluidnetwork/PathfinderCheckerPipes.java @@ -1,4 +1,4 @@ -package hydraulic.core.path; +package hydraulic.fluidnetwork; import hydraulic.api.IPipeConnection; diff --git a/src/minecraft/hydraulic/helpers/connectionHelper.java b/src/minecraft/hydraulic/helpers/connectionHelper.java index e736e0894..154751e89 100644 --- a/src/minecraft/hydraulic/helpers/connectionHelper.java +++ b/src/minecraft/hydraulic/helpers/connectionHelper.java @@ -25,7 +25,7 @@ public class connectionHelper public static TileEntity[] getSurroundingTileEntities(World world, int x, int y, int z) { - TileEntity[] list = new TileEntity[] { null, null, null, null, null, null }; + TileEntity[] list = new TileEntity[6]; for (int i = 0; i < 6; i++) { ForgeDirection direction = ForgeDirection.getOrientation(i); diff --git a/src/minecraft/hydraulic/prefab/tile/TileEntityFluidDevice.java b/src/minecraft/hydraulic/prefab/tile/TileEntityFluidDevice.java index ef2716d1a..a71cec028 100644 --- a/src/minecraft/hydraulic/prefab/tile/TileEntityFluidDevice.java +++ b/src/minecraft/hydraulic/prefab/tile/TileEntityFluidDevice.java @@ -1,20 +1,15 @@ package hydraulic.prefab.tile; +import hydraulic.api.IPipeConnection; +import hydraulic.api.IReadOut; +import hydraulic.fluidnetwork.HydraulicNetworkHelper; + import java.util.Random; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.liquids.ITankContainer; -import net.minecraftforge.liquids.LiquidContainerRegistry; import net.minecraftforge.liquids.LiquidStack; -import hydraulic.api.ColorCode; -import hydraulic.api.IColorCoded; -import hydraulic.api.IPipeConnection; -import hydraulic.api.IReadOut; -import hydraulic.core.liquidNetwork.HydraulicNetworkHelper; -import hydraulic.core.liquidNetwork.LiquidData; -import hydraulic.core.liquidNetwork.LiquidHandler; import universalelectricity.prefab.tile.TileEntityAdvanced; public abstract class TileEntityFluidDevice extends TileEntityAdvanced implements IReadOut, IPipeConnection diff --git a/src/minecraft/hydraulic/prefab/tile/TileEntityFluidStorage.java b/src/minecraft/hydraulic/prefab/tile/TileEntityFluidStorage.java index 99f35d0e2..f7e9157a0 100644 --- a/src/minecraft/hydraulic/prefab/tile/TileEntityFluidStorage.java +++ b/src/minecraft/hydraulic/prefab/tile/TileEntityFluidStorage.java @@ -1,12 +1,12 @@ package hydraulic.prefab.tile; -import java.util.EnumSet; - import fluidmech.common.machines.TileEntityTank; import hydraulic.api.ColorCode; import hydraulic.api.IColorCoded; -import hydraulic.core.liquidNetwork.LiquidData; -import hydraulic.core.liquidNetwork.LiquidHandler; +import hydraulic.fluidnetwork.FluidHelper; + +import java.util.EnumSet; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -14,6 +14,7 @@ import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.liquids.ILiquidTank; import net.minecraftforge.liquids.ITankContainer; import net.minecraftforge.liquids.LiquidContainerRegistry; +import net.minecraftforge.liquids.LiquidDictionary; import net.minecraftforge.liquids.LiquidStack; import net.minecraftforge.liquids.LiquidTank; @@ -24,10 +25,12 @@ public abstract class TileEntityFluidStorage extends TileEntityFluidDevice imple /* FLUID FILL AND DRAIN RULES */ private EnumSet fillableSides = EnumSet.allOf(ForgeDirection.class); private EnumSet drainableSides = EnumSet.allOf(ForgeDirection.class); + /** * gets the max storage limit of the tank */ public abstract int getTankSize(); + @Override public String getMeterReading(EntityPlayer user, ForgeDirection side) { @@ -35,7 +38,7 @@ public abstract class TileEntityFluidStorage extends TileEntityFluidDevice imple { return "Empty"; } - return String.format("%d/%d %S Stored", tank.getLiquid().amount / LiquidContainerRegistry.BUCKET_VOLUME, tank.getCapacity() / LiquidContainerRegistry.BUCKET_VOLUME, LiquidHandler.get(tank.getLiquid()).getName()); + return String.format("%d/%d %S Stored", tank.getLiquid().amount / LiquidContainerRegistry.BUCKET_VOLUME, tank.getCapacity() / LiquidContainerRegistry.BUCKET_VOLUME, LiquidDictionary.findLiquidName(tank.getLiquid())); } @Override @@ -60,27 +63,14 @@ public abstract class TileEntityFluidStorage extends TileEntityFluidDevice imple if (resource == null || tankIndex != 0) { return 0; - }else - if (this.getColor() != ColorCode.NONE && !getColor().getLiquidData().getStack().isLiquidEqual(resource)) - { - return 0; - }else if (this.tank.getLiquid() != null && resource.isLiquidEqual(this.tank.getLiquid())) + } + else if (this.getColor() != ColorCode.NONE && !getColor().isValidLiquid(resource)) { return 0; } - - if (this.isFull()) + else if (this.tank.getLiquid() != null && resource.isLiquidEqual(this.tank.getLiquid())) { - int change = 1; - if (LiquidHandler.get(resource).getCanFloat()) - { - change = -1; - } - TileEntity tank = worldObj.getBlockTileEntity(xCoord, yCoord + change, zCoord); - if (tank instanceof TileEntityTank) - { - return ((TileEntityTank) tank).fill(0, resource, doFill); - } + return 0; } return this.tank.fill(resource, doFill); } @@ -105,7 +95,7 @@ public abstract class TileEntityFluidStorage extends TileEntityFluidDevice imple LiquidStack stack = this.tank.getLiquid(); if (maxDrain < stack.amount) { - stack = LiquidHandler.getStack(stack, maxDrain); + stack = FluidHelper.getStack(stack, maxDrain); } if (doDrain) { @@ -148,10 +138,7 @@ public abstract class TileEntityFluidStorage extends TileEntityFluidDevice imple LiquidStack liquid = new LiquidStack(0, 0, 0); liquid.readFromNBT(nbt.getCompoundTag("stored")); - if (!liquid.isLiquidEqual(LiquidHandler.unkown.getStack())) - { - tank.setLiquid(liquid); - } + tank.setLiquid(liquid); } @Override @@ -176,4 +163,12 @@ public abstract class TileEntityFluidStorage extends TileEntityFluidDevice imple return true; } + /** + * gets the liquidStack stored in the internal tank + */ + public LiquidStack getStoredLiquid() + { + return this.tank.getLiquid(); + } + }