diff --git a/src/minecraft/dark/core/power/PowerSystems.java b/src/minecraft/dark/core/PowerSystems.java similarity index 97% rename from src/minecraft/dark/core/power/PowerSystems.java rename to src/minecraft/dark/core/PowerSystems.java index 64b779170..abb12ed21 100644 --- a/src/minecraft/dark/core/power/PowerSystems.java +++ b/src/minecraft/dark/core/PowerSystems.java @@ -1,4 +1,4 @@ -package dark.core.power; +package dark.core; import cpw.mods.fml.common.Loader; diff --git a/src/minecraft/dark/core/api/ColorCode.java b/src/minecraft/dark/core/api/ColorCode.java index 1fb7ceca0..8d3712b9c 100644 --- a/src/minecraft/dark/core/api/ColorCode.java +++ b/src/minecraft/dark/core/api/ColorCode.java @@ -1,6 +1,5 @@ package dark.core.api; -import net.minecraftforge.liquids.LiquidStack; public enum ColorCode { diff --git a/src/minecraft/dark/core/api/thermal/IHeatObject.java b/src/minecraft/dark/core/api/IHeatObject.java similarity index 95% rename from src/minecraft/dark/core/api/thermal/IHeatObject.java rename to src/minecraft/dark/core/api/IHeatObject.java index 22777315f..71acf3a80 100644 --- a/src/minecraft/dark/core/api/thermal/IHeatObject.java +++ b/src/minecraft/dark/core/api/IHeatObject.java @@ -1,4 +1,4 @@ -package dark.core.api.thermal; +package dark.core.api; import net.minecraftforge.common.ForgeDirection; diff --git a/src/minecraft/dark/core/api/thermal/IHeatProducer.java b/src/minecraft/dark/core/api/IHeatProducer.java similarity index 90% rename from src/minecraft/dark/core/api/thermal/IHeatProducer.java rename to src/minecraft/dark/core/api/IHeatProducer.java index ba246d2f6..18181b054 100644 --- a/src/minecraft/dark/core/api/thermal/IHeatProducer.java +++ b/src/minecraft/dark/core/api/IHeatProducer.java @@ -1,4 +1,4 @@ -package dark.core.api.thermal; +package dark.core.api; import net.minecraftforge.common.ForgeDirection; diff --git a/src/minecraft/dark/core/api/network/INetworkPart.java b/src/minecraft/dark/core/api/INetworkPart.java similarity index 86% rename from src/minecraft/dark/core/api/network/INetworkPart.java rename to src/minecraft/dark/core/api/INetworkPart.java index 5a1d246cb..5230f5c69 100644 --- a/src/minecraft/dark/core/api/network/INetworkPart.java +++ b/src/minecraft/dark/core/api/INetworkPart.java @@ -1,7 +1,7 @@ -package dark.core.api.network; +package dark.core.api; -import dark.core.hydraulic.network.NetworkTileEntities; import net.minecraft.tileentity.TileEntity; +import dark.core.tile.network.NetworkTileEntities; public interface INetworkPart extends ITileConnector { diff --git a/src/minecraft/dark/core/api/presure/IPsiReciever.java b/src/minecraft/dark/core/api/IPsiReciever.java similarity index 83% rename from src/minecraft/dark/core/api/presure/IPsiReciever.java rename to src/minecraft/dark/core/api/IPsiReciever.java index 8a8e52176..4872636a1 100644 --- a/src/minecraft/dark/core/api/presure/IPsiReciever.java +++ b/src/minecraft/dark/core/api/IPsiReciever.java @@ -1,6 +1,5 @@ -package dark.core.api.presure; +package dark.core.api; -import dark.core.api.network.ITileConnector; /** diff --git a/src/minecraft/dark/core/api/terminal/IScroll.java b/src/minecraft/dark/core/api/IScroll.java similarity index 89% rename from src/minecraft/dark/core/api/terminal/IScroll.java rename to src/minecraft/dark/core/api/IScroll.java index 22c144f08..1a82ddbe4 100644 --- a/src/minecraft/dark/core/api/terminal/IScroll.java +++ b/src/minecraft/dark/core/api/IScroll.java @@ -1,4 +1,4 @@ -package dark.core.api.terminal; +package dark.core.api; public interface IScroll { diff --git a/src/minecraft/dark/core/api/terminal/ISpecialAccess.java b/src/minecraft/dark/core/api/ISpecialAccess.java similarity index 97% rename from src/minecraft/dark/core/api/terminal/ISpecialAccess.java rename to src/minecraft/dark/core/api/ISpecialAccess.java index ede8c63d3..db9a3fe45 100644 --- a/src/minecraft/dark/core/api/terminal/ISpecialAccess.java +++ b/src/minecraft/dark/core/api/ISpecialAccess.java @@ -1,4 +1,4 @@ -package dark.core.api.terminal; +package dark.core.api; import java.util.List; diff --git a/src/minecraft/dark/core/api/terminal/ITerminal.java b/src/minecraft/dark/core/api/ITerminal.java similarity index 90% rename from src/minecraft/dark/core/api/terminal/ITerminal.java rename to src/minecraft/dark/core/api/ITerminal.java index 115543f5a..ac5498fbd 100644 --- a/src/minecraft/dark/core/api/terminal/ITerminal.java +++ b/src/minecraft/dark/core/api/ITerminal.java @@ -1,4 +1,4 @@ -package dark.core.api.terminal; +package dark.core.api; import java.util.List; diff --git a/src/minecraft/dark/core/api/network/ITileConnector.java b/src/minecraft/dark/core/api/ITileConnector.java similarity index 89% rename from src/minecraft/dark/core/api/network/ITileConnector.java rename to src/minecraft/dark/core/api/ITileConnector.java index 6100719ef..533ed28cc 100644 --- a/src/minecraft/dark/core/api/network/ITileConnector.java +++ b/src/minecraft/dark/core/api/ITileConnector.java @@ -1,4 +1,4 @@ -package dark.core.api.network; +package dark.core.api; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; diff --git a/src/minecraft/dark/core/api/tools/IReadOut.java b/src/minecraft/dark/core/api/IToolReadOut.java similarity index 76% rename from src/minecraft/dark/core/api/tools/IReadOut.java rename to src/minecraft/dark/core/api/IToolReadOut.java index 84e1ef4ad..b576abd89 100644 --- a/src/minecraft/dark/core/api/tools/IReadOut.java +++ b/src/minecraft/dark/core/api/IToolReadOut.java @@ -1,9 +1,9 @@ -package dark.core.api.tools; +package dark.core.api; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.ForgeDirection; -public interface IReadOut +public interface IToolReadOut { /** * Grabs the message displayed to the user on right click of the machine with the pipe gauge @@ -13,5 +13,11 @@ public interface IReadOut * @return - a string to be displayed to the player for a reading. automatically adds ReadOut: * to the beginning */ - public String getMeterReading(EntityPlayer user, ForgeDirection side); + public String getMeterReading(EntityPlayer user, ForgeDirection side, EnumTools tool); + + public static enum EnumTools + { + PIPE_GUAGE(), + MULTI_METER(); + } } diff --git a/src/minecraft/dark/core/api/faction/IFactionObject.java b/src/minecraft/dark/core/api/faction/IFactionObject.java deleted file mode 100644 index dff2c7fef..000000000 --- a/src/minecraft/dark/core/api/faction/IFactionObject.java +++ /dev/null @@ -1,13 +0,0 @@ -package dark.core.api.faction; - -import dark.core.faction.FactionInstance; - -public interface IFactionObject -{ - /** - * Gets the faction this is linked too. Will return Neutral rather than null - */ - public FactionInstance getFaction(); - - public boolean setFaction(FactionInstance faction, boolean override); -} diff --git a/src/minecraft/dark/core/api/hydraulic/IDrain.java b/src/minecraft/dark/core/api/hydraulic/IDrain.java deleted file mode 100644 index 8e0777801..000000000 --- a/src/minecraft/dark/core/api/hydraulic/IDrain.java +++ /dev/null @@ -1,44 +0,0 @@ -package dark.core.api.hydraulic; - -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.liquids.ITankContainer; -import net.minecraftforge.liquids.LiquidStack; - -/** - * Interface to make or use the TileEntityDrain. In real life a drain would do nothing but act as an - * input or output for a pipe system. In code in order to interact with the pump the drain actual - * has to do the filling/draining for the pump. The pump only need to find the drain and tell it to - * fill or drain an area. - * - * The use of ITankContainer is optional but is need for the drain to be added to a Fluid Network - */ -public interface IDrain extends ITankContainer -{ - /** - * In the drain you can use the ITankContainer.fill methods or use this to get the drain to - * place a liquid into the world - * - * @param stack - valid LiquidStack that has a Liquid Block for it - * @param doFill - actual do the action of filling or check if it can - * @return amount of liquid used - */ - public int fillArea(LiquidStack stack, boolean doFill); - - /** - * Requests that this drain give the pump this liquid. The pump will have to decide if it can - * accept, request, and maintain this demand - * - * @param pump - requesting pump - * @param stack - liquid this pump wants for this request - */ - public void requestLiquid(TileEntity pump, LiquidStack stack); - - /** - * Request that this drain no longer supply the pump with a volume. By default a request will be - * removed from the request map after being filled. However, this can be used too stop a request - * short if the pump becomes full before the request is filled - * - * @param tileEntity - requesting pump - */ - public void stopRequesting(TileEntity tileEntity); -} diff --git a/src/minecraft/dark/core/api/network/fluid/INetworkFluidPart.java b/src/minecraft/dark/core/api/network/fluid/INetworkFluidPart.java deleted file mode 100644 index 5764e6fd5..000000000 --- a/src/minecraft/dark/core/api/network/fluid/INetworkFluidPart.java +++ /dev/null @@ -1,21 +0,0 @@ -package dark.core.api.network.fluid; - -import dark.core.api.IColorCoded; -import dark.core.api.network.INetworkPart; -import net.minecraftforge.liquids.ILiquidTank; -import net.minecraftforge.liquids.ITankContainer; -import net.minecraftforge.liquids.LiquidStack; -import net.minecraftforge.liquids.LiquidTank; - -public interface INetworkFluidPart extends IColorCoded, ITankContainer, INetworkPart -{ - /** - * Gets the part's main tank for shared storage - */ - public ILiquidTank getTank(); - - /** - * Sets the content of the part's main tank - */ - public void setTankContent(LiquidStack stack); -} diff --git a/src/minecraft/dark/core/api/network/fluid/INetworkPipe.java b/src/minecraft/dark/core/api/network/fluid/INetworkPipe.java deleted file mode 100644 index 01cca97b2..000000000 --- a/src/minecraft/dark/core/api/network/fluid/INetworkPipe.java +++ /dev/null @@ -1,37 +0,0 @@ -package dark.core.api.network.fluid; - -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.liquids.LiquidStack; - -/** - * A machine that acts as one with the liquid network using the networks pressure for some function - * that doesn't change the over all network pressure. So pipes, gauges, tubes, buffers, decor - * blocks. - */ -public interface INetworkPipe extends INetworkFluidPart -{ - /** - * Gets the parts max pressure limit it can handle - * - * Note this is not recommended max limit by rather actual breaking point of the part - */ - public double getMaxPressure(ForgeDirection side); - - /** - * Max flow rate of liquid flow this part from the side for the liquid type that his part will - * allow - * - * @return limit in bucket parts(1/1000 of a bucket) - */ - public int getMaxFlowRate(LiquidStack stack, ForgeDirection side); - - /** - * Called when the pressure on the machine goes beyond max limits. Suggest doing random chance - * of damage or break too simulate real chances of pipe going beyond designed limits - * - * @param damageAllowed - can this tileEntity cause grief damage - * @return true if the device over pressured and destroyed itself - */ - public boolean onOverPressure(Boolean damageAllowed); - -} diff --git a/src/minecraft/dark/core/faction/FactionCreationEvent.java b/src/minecraft/dark/core/faction/FactionCreationEvent.java deleted file mode 100644 index e4a5f4213..000000000 --- a/src/minecraft/dark/core/faction/FactionCreationEvent.java +++ /dev/null @@ -1,6 +0,0 @@ -package dark.core.faction; - -public class FactionCreationEvent -{ - -} diff --git a/src/minecraft/dark/core/faction/FactionInstance.java b/src/minecraft/dark/core/faction/FactionInstance.java deleted file mode 100644 index 7b16df157..000000000 --- a/src/minecraft/dark/core/faction/FactionInstance.java +++ /dev/null @@ -1,124 +0,0 @@ -package dark.core.faction; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; - -import net.minecraft.nbt.NBTTagCompound; -import dark.helpers.Pair; -import dark.helpers.Time; -import dark.library.access.AccessLevel; -import dark.library.access.GlobalAccessManager; -import dark.library.access.UserAccess; - -/** - * Class used to track and manage a player/NPC faction - * - * @author DarkGuardsman - */ -public class FactionInstance -{ - public List userList; - public String name; - public String creator; - public String date = "unkown"; - public String prefix; - - public FactionInstance(String prefix, String name, String maker, Pair date) - { - if (this.name == null || this.name.isEmpty()) - { - this.name = "Faction" + date.getValue().getMonth() + date.getValue().getDay(); - } - else - { - this.name = name; - } - - if (maker == null || maker.isEmpty()) - { - this.creator = "World"; - } - else - { - this.creator = maker; - } - - if (prefix == null) - { - this.prefix = name.substring(0, 4); - } - else if (prefix.length() > 6) - { - this.prefix = prefix.substring(0, 6); - } - else - { - this.prefix = prefix; - } - - if (date == null) - { - date = Time.getCurrentTimeStamp(); - } - this.date = date.getKey(); - - userList = GlobalAccessManager.getOrCreateList(name, maker); - if (userList == null) - { - userList = new ArrayList(); - userList.add(new UserAccess(this.creator, AccessLevel.OWNER, true)); - } - } - - public String getCreationDate() - { - return this.date; - } - - /** - * The person who original created the faction - */ - public String getCreator() - { - return (creator != null && !creator.isEmpty()) ? this.creator : "World"; - } - - /** - * The name of the faction - */ - public String getName() - { - return (name != null && !name.isEmpty()) ? this.name : "FactionName"; - } - - public NBTTagCompound write() - { - NBTTagCompound tag = new NBTTagCompound(); - tag.setString("name", this.getName()); - tag.setString("creator", this.creator); - return tag; - } - - public void read(NBTTagCompound tag) - { - - } - - public boolean isEqual(FactionInstance faction) - { - - return faction != null && faction.name.equalsIgnoreCase(this.name) && faction.creator.equalsIgnoreCase(this.creator); - } - - public boolean isInvalid() - { - return this.wasPlayerCreated() && this.userList.isEmpty(); - } - - public boolean wasPlayerCreated() - { - return !this.creator.equalsIgnoreCase("World"); - } -} diff --git a/src/minecraft/dark/core/faction/FactionMain.java b/src/minecraft/dark/core/faction/FactionMain.java deleted file mode 100644 index dfb4939c4..000000000 --- a/src/minecraft/dark/core/faction/FactionMain.java +++ /dev/null @@ -1,6 +0,0 @@ -package dark.core.faction; - -public class FactionMain -{ - -} diff --git a/src/minecraft/dark/core/faction/FactionManager.java b/src/minecraft/dark/core/faction/FactionManager.java deleted file mode 100644 index 05a5c4247..000000000 --- a/src/minecraft/dark/core/faction/FactionManager.java +++ /dev/null @@ -1,48 +0,0 @@ -package dark.core.faction; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import dark.core.api.faction.IFactionObject; - -public class FactionManager -{ - - /* LIST OF FACTION CURRENTLY OR RECNETLY LOADED */ - public static List cachedFactions = new ArrayList(); - /* LIST OF CURRENTLY OR RECENTLY LOADED PLAYERS AND THERE FACTIONS */ - public static HashMap cachedAllegance = new HashMap(); - - public static FactionInstance NEUTRIAL = new FactionInstance("NAN", "Neutrial", "World", null); - public static FactionInstance GUARDSMAN = new FactionInstance("GSM", "GUARDSMAN", "DARKGUARDSMAN", null); - public static FactionInstance DARK = new FactionInstance("DARK", "DARK", "DARKGUARDSMAN", null); - - public boolean isPartOfFaction(Object entity, FactionInstance faction) - { - if (faction == null || entity == null) - { - return false; - } - if (entity instanceof IFactionObject) - { - return faction.isEqual(((IFactionObject) entity).getFaction()); - } - return false; - } - - public static FactionInstance loadFaction(String name) - { - if (name != null && !name.isEmpty()) - { - - } - return NEUTRIAL; - - } - - public static void saveFaction(FactionInstance faction) - { - - } -} diff --git a/src/minecraft/dark/core/faction/entity/CharStats.java b/src/minecraft/dark/core/faction/entity/CharStats.java deleted file mode 100644 index f8916c5f3..000000000 --- a/src/minecraft/dark/core/faction/entity/CharStats.java +++ /dev/null @@ -1,13 +0,0 @@ -package dark.core.faction.entity; - -public enum CharStats -{ - Strength("Strength"), endurance("endurance"), dexterity("dexterity"), Intelligence("intelligence"), wit("wits"), memor("recall"), willpower("Will"), perception("charm"), luck("Luck"); - - public String name; - - private CharStats(String name) - { - this.name = name; - } -} diff --git a/src/minecraft/dark/core/faction/entity/EntityNpc.java b/src/minecraft/dark/core/faction/entity/EntityNpc.java deleted file mode 100644 index b2680d981..000000000 --- a/src/minecraft/dark/core/faction/entity/EntityNpc.java +++ /dev/null @@ -1,116 +0,0 @@ -package dark.core.faction.entity; - -import java.util.Random; - -import net.minecraft.entity.EntityCreature; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import dark.core.api.faction.IFactionObject; -import dark.core.faction.FactionInstance; -import dark.core.faction.FactionManager; -import dark.library.math.MathHelper; - -/** - * NPC that simulate being players in an empire controlled environment - * - * @author Darkguardsman - */ -public class EntityNpc extends EntityCreature implements IFactionObject -{ - protected Random random = new Random(); - - /* FACTION STUFF */ - protected FactionInstance faction; - protected String factionName = "NEUTRIAL"; - - /* CHARACTER STUFF */ - protected String humanName = "NPC"; - protected boolean female; - protected int[] stats; - - public EntityNpc(World world) - { - super(world); - this.stats = MathHelper.generateRandomIntArray(random, 100, 8); - this.female = random.nextBoolean(); - } - - /** - * @param stats - Strength, endurance, dexterity, Intelligence, wit, memory, willpower, - * perception, luck http://en.wikipedia.org/wiki/Attribute_(role-playing_games) - */ - public EntityNpc(World world, int... stats) - { - this(world); - this.stats = MathHelper.generateRandomIntArray(random, 100, 8); - for (int i = 0; i < stats.length && i < stats.length; i++) - { - if (stats[i] != -1) - { - this.stats[i] = stats[i]; - } - } - } - - /** - * Gets the value of the stat - */ - public int getStat(CharStats stat) - { - if (this.stats == null) - { - this.stats = MathHelper.generateRandomIntArray(random, 100, 8); - } - return stat.ordinal() < this.stats.length ? this.stats[stat.ordinal()] : 10; - - } - - @Override - public int getMaxHealth() - { - return 10 + this.getStat(CharStats.endurance); - } - - public String getName() - { - return humanName; - } - - @Override - public void writeEntityToNBT(NBTTagCompound nbt) - { - super.writeEntityToNBT(nbt); - nbt.setString("humanName", this.humanName); - nbt.setString("factionName", this.faction != null ? this.faction.name : "NEUTRIAL"); - } - - @Override - public void readEntityFromNBT(NBTTagCompound nbt) - { - super.readEntityFromNBT(nbt); - this.humanName = nbt.getString("humanName"); - this.factionName = nbt.getString("factionName"); - } - - @Override - public FactionInstance getFaction() - { - if (this.faction == null || this.faction.isInvalid()) - { - this.faction = FactionManager.loadFaction(this.factionName); - } - return this.faction != null ? this.faction : FactionManager.NEUTRIAL; - } - - @Override - public boolean setFaction(FactionInstance faction, boolean override) - { - if (override || this.faction == null || this.faction.isInvalid()) - { - this.faction = faction; - return true; - } - return false; - } - -} diff --git a/src/minecraft/dark/core/hydraulic/network/NetworkFluidContainers.java b/src/minecraft/dark/core/hydraulic/network/NetworkFluidContainers.java deleted file mode 100644 index b03ceb506..000000000 --- a/src/minecraft/dark/core/hydraulic/network/NetworkFluidContainers.java +++ /dev/null @@ -1,165 +0,0 @@ -package dark.core.hydraulic.network; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.liquids.LiquidStack; -import dark.core.api.ColorCode; -import dark.core.api.network.INetworkPart; -import dark.core.api.network.fluid.INetworkFluidPart; -import dark.core.hydraulic.network.fluid.NetworkFluidTiles; - -/** - * Side note: the network should act like this when done {@link http - * ://www.e4training.com/hydraulic_calculators/B1.htm} as well as stay compatible with the forge - * Liquids - * - * @author Rseifert - * - */ -public class NetworkFluidContainers extends NetworkFluidTiles -{ - - public NetworkFluidContainers(ColorCode color, INetworkPart... parts) - { - super(color, parts); - } - - @Override - // TODO change this to place liquids at the bottom first - public void balanceColletiveTank(boolean sumParts) - { - int volume = 0, itemID = 0, itemMeta = 0; - - if (sumParts) - { - for (INetworkPart par : this.networkMember) - { - if (par instanceof INetworkFluidPart) - { - INetworkFluidPart part = ((INetworkFluidPart) par); - if (part.getTank() != null && part.getTank().getLiquid() != null) - { - if (itemID == 0) - { - itemID = part.getTank().getLiquid().itemID; - itemMeta = part.getTank().getLiquid().itemMeta; - } - volume += part.getTank().getLiquid().amount; - } - } - } - this.combinedStorage().setLiquid(new LiquidStack(itemID, volume, itemMeta)); - this.loadedLiquids = true; - } - if (this.combinedStorage().getLiquid() != null && this.getNetworkMemebers().size() > 0) - { - this.cleanUpConductors(); - - int lowestY = 255; - int highestY = 0; - for (INetworkPart part : this.getNetworkMemebers()) - { - if (part instanceof TileEntity && ((TileEntity) part).yCoord < lowestY) - { - lowestY = ((TileEntity) part).yCoord; - } - if (part instanceof TileEntity && ((TileEntity) part).yCoord > highestY) - { - highestY = ((TileEntity) part).yCoord; - } - } - itemID = this.combinedStorage().getLiquid().itemID; - itemMeta = this.combinedStorage().getLiquid().itemMeta; - volume = this.combinedStorage().getLiquid().amount; - - for (int y = lowestY; y <= highestY; y++) - { - List parts = new ArrayList(); - for (INetworkPart part : this.getNetworkMemebers()) - { - if (part instanceof INetworkFluidPart && ((TileEntity) part).yCoord == y) - { - parts.add((INetworkFluidPart) part); - } - } - int fillvolume = volume / parts.size(); - - for (INetworkFluidPart part : parts) - { - part.setTankContent(null); - int fill = Math.min(fillvolume, part.getTank().getCapacity()); - part.setTankContent(new LiquidStack(itemID, fill, itemMeta)); - volume -= fill; - } - if (volume <= 0) - { - break; - } - } - } - - } - - @Override - public int storeFluidInSystem(LiquidStack stack, boolean doFill) - { - int vol = this.combinedStorage().getLiquid() != null ? this.combinedStorage().getLiquid().amount : 0; - int filled = super.storeFluidInSystem(stack, doFill); - if (vol != filled) - { - for (INetworkPart part : this.getNetworkMemebers()) - { - if (part instanceof TileEntity) - { - TileEntity ent = ((TileEntity) part); - ent.worldObj.markBlockForUpdate(ent.xCoord, ent.yCoord, ent.zCoord); - } - } - } - return filled; - } - - @Override - public LiquidStack drainFluidFromSystem(int maxDrain, boolean doDrain) - { - LiquidStack vol = this.combinedStorage().getLiquid(); - LiquidStack stack = super.drainFluidFromSystem(maxDrain, doDrain); - boolean flag = false; - if (vol != null) - { - if (stack == null) - { - flag = true; - } - else if (stack.amount != vol.amount) - { - flag = true; - } - } - if (flag) - { - for (INetworkPart part : this.getNetworkMemebers()) - { - if (part instanceof TileEntity) - { - TileEntity ent = ((TileEntity) part); - ent.worldObj.markBlockForUpdate(ent.xCoord, ent.yCoord, ent.zCoord); - } - } - } - return stack; - } - - @Override - public void postMergeProcessing(NetworkTileEntities network) - { - NetworkFluidContainers newNetwork = new NetworkFluidContainers(this.color); - newNetwork.getNetworkMemebers().addAll(this.getNetworkMemebers()); - newNetwork.getNetworkMemebers().addAll(network.getNetworkMemebers()); - - newNetwork.cleanUpConductors(); - newNetwork.balanceColletiveTank(true); - } -} diff --git a/src/minecraft/dark/core/hydraulic/network/fluid/FluidPressurePack.java b/src/minecraft/dark/core/hydraulic/network/fluid/FluidPressurePack.java deleted file mode 100644 index f73adcf3a..000000000 --- a/src/minecraft/dark/core/hydraulic/network/fluid/FluidPressurePack.java +++ /dev/null @@ -1,31 +0,0 @@ -package dark.core.hydraulic.network.fluid; - -import net.minecraftforge.liquids.LiquidStack; - -public class FluidPressurePack implements Cloneable -{ - public LiquidStack liquidStack; - public double pressure; - - public FluidPressurePack(LiquidStack liquidStack, double voltage) - { - this.liquidStack = liquidStack; - this.pressure = voltage; - } - - public FluidPressurePack() - { - this(new LiquidStack(0, 0, 0), 0); - } - - @Override - public FluidPressurePack clone() - { - return new FluidPressurePack(this.liquidStack, this.pressure); - } - - public boolean isEqual(FluidPressurePack electricityPack) - { - return this.liquidStack.isLiquidEqual(electricityPack.liquidStack) && this.pressure == electricityPack.pressure; - } -} diff --git a/src/minecraft/dark/core/hydraulic/network/fluid/HydraulicNetworkHelper.java b/src/minecraft/dark/core/hydraulic/network/fluid/HydraulicNetworkHelper.java deleted file mode 100644 index fdf5d5f88..000000000 --- a/src/minecraft/dark/core/hydraulic/network/fluid/HydraulicNetworkHelper.java +++ /dev/null @@ -1,43 +0,0 @@ -package dark.core.hydraulic.network.fluid; - -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.liquids.ITankContainer; -import universalelectricity.core.vector.Vector3; -import universalelectricity.core.vector.VectorHelper; -import dark.core.api.hydraulic.IDrain; -import dark.core.api.network.INetworkPart; -import dark.core.hydraulic.network.NetworkTileEntities; - -public class HydraulicNetworkHelper -{ - - /** - * Invalidates a TileEntity - */ - public static void invalidate(TileEntity tileEntity) - { - for (int i = 0; i < 6; i++) - { - ForgeDirection direction = ForgeDirection.getOrientation(i); - TileEntity checkTile = VectorHelper.getConnectorFromSide(tileEntity.worldObj, new Vector3(tileEntity), direction); - - if (checkTile instanceof INetworkPart) - { - NetworkTileEntities network = ((INetworkPart) checkTile).getTileNetwork(); - - if (network != null && network instanceof NetworkFluidTiles) - { - network.removeEntity(tileEntity); - for (ITankContainer tank : ((NetworkFluidTiles) network).connectedTanks) - { - if (tank instanceof IDrain) - { - ((IDrain) tank).stopRequesting(tileEntity); - } - } - } - } - } - } -} diff --git a/src/minecraft/dark/core/hydraulic/network/fluid/NetworkFluidTiles.java b/src/minecraft/dark/core/hydraulic/network/fluid/NetworkFluidTiles.java deleted file mode 100644 index 380b22907..000000000 --- a/src/minecraft/dark/core/hydraulic/network/fluid/NetworkFluidTiles.java +++ /dev/null @@ -1,347 +0,0 @@ -package dark.core.hydraulic.network.fluid; - - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -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.path.Pathfinder; -import universalelectricity.core.vector.Vector3; -import dark.core.api.ColorCode; -import dark.core.api.network.INetworkPart; -import dark.core.api.network.fluid.INetworkFluidPart; -import dark.core.hydraulic.helpers.FluidHelper; -import dark.core.hydraulic.network.NetworkPathFinder; -import dark.core.hydraulic.network.NetworkTileEntities; - -public class NetworkFluidTiles extends NetworkTileEntities -{ - /* MACHINES THAT ARE FLUID BASED AND CONNECTED BUT NOT PART OF THE NETWORK ** */ - public final List connectedTanks = new ArrayList(); - - /* COMBINED TEMP STORAGE FOR ALL PIPES IN THE NETWORK */ - public LiquidTank sharedTank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME); - - public ColorCode color = ColorCode.NONE; - protected boolean loadedLiquids = false; - - public NetworkFluidTiles(ColorCode color, INetworkPart... parts) - { - super(parts); - this.color = color; - } - - public LiquidTank combinedStorage() - { - if (this.sharedTank == null) - { - this.sharedTank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME); - this.balanceColletiveTank(true); - } - return this.sharedTank; - } - - /** - * Stores Fluid in this network's collective tank - */ - public int storeFluidInSystem(LiquidStack stack, boolean doFill) - { - if (stack == null || this.combinedStorage().containsValidLiquid() && (this.combinedStorage().getLiquid() != null && !this.combinedStorage().getLiquid().isLiquidEqual(stack))) - { - return 0; - } - if (!loadedLiquids) - { - this.balanceColletiveTank(true); - } - if (this.combinedStorage().getLiquid() == null || this.combinedStorage().getLiquid().amount < this.combinedStorage().getCapacity()) - { - int filled = this.combinedStorage().fill(stack, doFill); - if (doFill) - { - this.balanceColletiveTank(false); - } - return filled; - } - return 0; - } - - /** - * Drains the network's collective tank - */ - public LiquidStack drainFluidFromSystem(int maxDrain, boolean doDrain) - { - if (!loadedLiquids) - { - this.balanceColletiveTank(true); - } - LiquidStack stack = this.combinedStorage().getLiquid(); - if (stack != null) - { - stack = this.combinedStorage().getLiquid().copy(); - if (maxDrain < stack.amount) - { - stack = FluidHelper.getStack(stack, maxDrain); - } - stack = this.combinedStorage().drain(maxDrain, doDrain); - if (doDrain) - { - this.balanceColletiveTank(false); - } - } - return stack; - } - - /** - * Moves the volume stored in the network to the parts or sums up the volume from the parts and - * loads it to the network. Assumes that all liquidStacks stored are equal - * - * @param sumParts - loads the volume from the parts before leveling out the volumes - */ - public void balanceColletiveTank(boolean sumParts) - { - int volume = 0, itemID = 0, itemMeta = 0; - - if (sumParts) - { - for (INetworkPart par : this.networkMember) - { - if (par instanceof INetworkFluidPart) - { - INetworkFluidPart part = ((INetworkFluidPart) par); - if (part.getTank() != null && part.getTank().getLiquid() != null) - { - if (itemID == 0) - { - itemID = part.getTank().getLiquid().itemID; - itemMeta = part.getTank().getLiquid().itemMeta; - } - volume += part.getTank().getLiquid().amount; - } - } - } - this.combinedStorage().setLiquid(new LiquidStack(itemID, volume, itemMeta)); - this.loadedLiquids = true; - } - - if (this.combinedStorage().getLiquid() != null && this.networkMember.size() > 0) - { - volume = this.combinedStorage().getLiquid().amount / this.networkMember.size(); - itemID = this.combinedStorage().getLiquid().itemID; - itemMeta = this.combinedStorage().getLiquid().itemMeta; - - for (INetworkPart par : this.networkMember) - { - if (par instanceof INetworkFluidPart) - { - INetworkFluidPart part = ((INetworkFluidPart) par); - part.setTankContent(null); - part.setTankContent(new LiquidStack(itemID, volume, itemMeta)); - } - } - } - } - - @Override - public void removeEntity(TileEntity ent) - { - super.removeEntity(ent); - this.connectedTanks.remove(ent); - } - - @Override - public boolean addEntity(TileEntity ent, boolean member) - { - if (!(super.addEntity(ent, member)) && ent instanceof ITankContainer && !connectedTanks.contains(ent)) - { - connectedTanks.add((ITankContainer) ent); - return true; - } - return false; - } - - /** - * Checks too see if the tileEntity is part of or connected too the network - */ - public boolean isConnected(TileEntity tileEntity) - { - return this.connectedTanks.contains(tileEntity); - } - - public boolean isPartOfNetwork(TileEntity ent) - { - return super.isPartOfNetwork(ent) || this.connectedTanks.contains(ent); - } - - public void causingMixing(INetworkPart Fluid, LiquidStack stack, LiquidStack stack2) - { - // TODO cause mixing of liquids based on types and volume. Also apply damage to pipes/parts - // as needed - } - - public void splitNetwork(World world, INetworkPart splitPoint) - { - if (splitPoint instanceof TileEntity) - { - this.getNetworkMemebers().remove(splitPoint); - this.balanceColletiveTank(false); - /** - * Loop through the connected blocks and attempt to see if there are connections between - * the two points elsewhere. - */ - TileEntity[] connectedBlocks = splitPoint.getNetworkConnections(); - - for (int i = 0; i < connectedBlocks.length; i++) - { - TileEntity connectedBlockA = connectedBlocks[i]; - - if (connectedBlockA instanceof INetworkPart) - { - for (int pipeCount = 0; pipeCount < connectedBlocks.length; pipeCount++) - { - final TileEntity connectedBlockB = connectedBlocks[pipeCount]; - - if (connectedBlockA != connectedBlockB && connectedBlockB instanceof INetworkPart) - { - Pathfinder finder = new NetworkPathFinder(world, (INetworkPart) connectedBlockB, splitPoint); - finder.init(new Vector3(connectedBlockA)); - - if (finder.results.size() > 0) - { - /* STILL CONNECTED SOMEWHERE ELSE */ - for (Vector3 node : finder.closedSet) - { - TileEntity entity = node.getTileEntity(world); - if (entity instanceof INetworkPart) - { - if (node != splitPoint) - { - ((INetworkPart) entity).setTileNetwork(this); - } - } - } - } - else - { - /* NO LONGER CONNECTED ELSE WHERE SO SPLIT AND REFRESH */ - NetworkPipes newNetwork = new NetworkPipes(this.color); - int parts = 0; - for (Vector3 node : finder.closedSet) - { - TileEntity entity = node.getTileEntity(world); - if (entity instanceof INetworkPart) - { - if (node != splitPoint) - { - newNetwork.getNetworkMemebers().add((INetworkPart) entity); - parts++; - } - } - } - - newNetwork.cleanUpConductors(); - newNetwork.balanceColletiveTank(true); - } - } - } - } - } - } - } - - @Override - public boolean preMergeProcessing(NetworkTileEntities net, INetworkPart part) - { - if (net instanceof NetworkFluidTiles && ((NetworkFluidTiles) net).color == this.color) - { - NetworkFluidTiles network = (NetworkFluidTiles) net; - - this.balanceColletiveTank(true); - network.balanceColletiveTank(true); - - LiquidStack stack = new LiquidStack(0, 0, 0); - - if (this.combinedStorage().getLiquid() != null && network.combinedStorage().getLiquid() != null && this.combinedStorage().getLiquid().isLiquidEqual(network.combinedStorage().getLiquid())) - { - stack = this.combinedStorage().getLiquid(); - stack.amount += network.combinedStorage().getLiquid().amount; - } - else if (this.combinedStorage().getLiquid() == null && network.combinedStorage().getLiquid() != null) - { - stack = network.combinedStorage().getLiquid(); - } - else if (this.combinedStorage().getLiquid() != null && network.combinedStorage().getLiquid() == null) - { - stack = this.combinedStorage().getLiquid(); - } - return true; - } - return false; - } - - @Override - public void postMergeProcessing(NetworkTileEntities network) - { - NetworkFluidTiles newNetwork = new NetworkFluidTiles(this.color); - newNetwork.getNetworkMemebers().addAll(this.getNetworkMemebers()); - newNetwork.getNetworkMemebers().addAll(network.getNetworkMemebers()); - - newNetwork.cleanUpConductors(); - newNetwork.balanceColletiveTank(true); - } - - @Override - public void cleanUpConductors() - { - if (!loadedLiquids) - { - this.balanceColletiveTank(true); - } - Iterator it = this.networkMember.iterator(); - int capacity = 0; - while (it.hasNext()) - { - INetworkPart part = it.next(); - if (!this.isValidMember(part)) - { - it.remove(); - } - else - { - part.setTileNetwork(this); - if (part instanceof INetworkFluidPart) - { - capacity += ((INetworkFluidPart) part).getTank().getCapacity(); - } - } - } - this.combinedStorage().setCapacity(capacity); - } - - @Override - public boolean isValidMember(INetworkPart part) - { - return super.isValidMember(part) && part instanceof INetworkFluidPart && ((INetworkFluidPart) part).getColor() == this.color; - } - - @Override - public String toString() - { - return "FluidNetwork[" + this.hashCode() + "|parts:" + this.networkMember.size() + "]"; - } - - public String getNetworkFluid() - { - int cap = combinedStorage().getCapacity() / LiquidContainerRegistry.BUCKET_VOLUME; - int vol = combinedStorage().getLiquid() != null ? (combinedStorage().getLiquid().amount / LiquidContainerRegistry.BUCKET_VOLUME) : 0; - String name = LiquidDictionary.findLiquidName(this.combinedStorage().getLiquid()) != null ? LiquidDictionary.findLiquidName(this.combinedStorage().getLiquid()) : "Unkown"; - return String.format("%d/%d %S Stored", vol, cap, name); - } -} diff --git a/src/minecraft/dark/core/hydraulic/network/fluid/NetworkPipes.java b/src/minecraft/dark/core/hydraulic/network/fluid/NetworkPipes.java deleted file mode 100644 index 241172ff3..000000000 --- a/src/minecraft/dark/core/hydraulic/network/fluid/NetworkPipes.java +++ /dev/null @@ -1,368 +0,0 @@ -package dark.core.hydraulic.network.fluid; - - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.liquids.ILiquidTank; -import net.minecraftforge.liquids.ITankContainer; -import net.minecraftforge.liquids.LiquidStack; -import dark.core.api.ColorCode; -import dark.core.api.network.INetworkPart; -import dark.core.api.network.fluid.INetworkPipe; -import dark.core.hydraulic.helpers.FluidRestrictionHandler; -import dark.helpers.ConnectionHelper; - -/** - * Side note: the network should act like this when done {@link http - * ://www.e4training.com/hydraulic_calculators/B1.htm} as well as stay compatible with the forge - * Liquids - * - * @author Rseifert - * - */ -public class NetworkPipes extends NetworkFluidTiles -{ - - /* MACHINES THAT USE THE PRESSURE SYSTEM TO DO WORK ** */ - private final HashMap pressureProducers = new HashMap(); - private final HashMap pressureLoads = new HashMap(); - - /* PRESSURE OF THE NETWORK AS A TOTAL. ZERO AS IN NO PRESSURE */ - public double pressureProduced = 0, pressureLoad = 0; - - /* IS IT PROCESSING AN ADD LIQUID EVENT */ - private boolean processingRequest = false; - - public NetworkPipes(ColorCode color, INetworkPart... parts) - { - super(color, parts); - } - - public boolean isPartOfNetwork(TileEntity ent) - { - return super.isPartOfNetwork(ent) || this.pressureLoads.containsKey(ent) || this.pressureProducers.containsKey(ent); - } - - /** - * sets this tileEntity to produce a pressure and flow rate in the network - */ - public void startProducingPressure(TileEntity tileEntity, FluidPressurePack fluidPack) - { - if (tileEntity != null && fluidPack.liquidStack != null) - { - if ((this.combinedStorage().getLiquid() == null || fluidPack.liquidStack.isLiquidEqual(this.combinedStorage().getLiquid())) && fluidPack.liquidStack.amount > 0) - { - this.pressureProducers.put(tileEntity, fluidPack); - } - } - } - - /** - * sets this tileEntity to produce a pressure and flow rate in the network - */ - public void startProducingPressure(TileEntity tileEntity, LiquidStack stack, double pressure) - { - this.startProducingPressure(tileEntity, new FluidPressurePack(stack, pressure)); - } - - /** - * is this tile entity producing a pressure - */ - public boolean isProducingPressure(TileEntity tileEntity) - { - return this.pressureProducers.containsKey(tileEntity); - } - - /** - * Sets this tile entity to act as a load on the system - */ - public void addLoad(TileEntity tileEntity, FluidPressurePack fluidPack) - { - if (tileEntity != null && fluidPack.liquidStack != null && fluidPack.liquidStack.amount > 0) - { - this.pressureLoads.put(tileEntity, fluidPack); - } - } - - /** - * Sets this tile entity to act as a load on the system - */ - public void addLoad(TileEntity tileEntity, LiquidStack stack, double pressure) - { - this.addLoad(tileEntity, new FluidPressurePack(stack, pressure)); - } - - /** - * is this tileEntity a load in the network - */ - public boolean isLoad(TileEntity tileEntity) - { - return this.pressureLoads.containsKey(tileEntity); - } - - /** - * @param ignoreTiles The TileEntities to ignore during this calculation. Null will make it not - * ignore any. - * @return The electricity produced in this electricity network - */ - public double getPressureProduced(TileEntity... ignoreTiles) - { - // TODO pressure is not added as a sum but rather as a collective sum of the largest - // pressures. IF the pressure is to small it will be ignored and stop producing pressure. - int totalPressure = 0; - - Iterator it = this.pressureProducers.entrySet().iterator(); - - loop: - while (it.hasNext()) - { - Map.Entry pairs = (Map.Entry) it.next(); - - if (pairs != null) - { - TileEntity tileEntity = (TileEntity) pairs.getKey(); - - if (tileEntity == null) - { - it.remove(); - continue; - } - - if (tileEntity.isInvalid()) - { - it.remove(); - continue; - } - - if (tileEntity.worldObj.getBlockTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord) != tileEntity) - { - it.remove(); - continue; - } - - if (ignoreTiles != null) - { - for (TileEntity ignoreTile : ignoreTiles) - { - if (tileEntity == ignoreTile) - { - continue loop; - } - } - } - - FluidPressurePack pack = (FluidPressurePack) pairs.getValue(); - - if (pairs.getKey() != null && pairs.getValue() != null && pack != null) - { - totalPressure += pack.pressure; - } - } - } - - return totalPressure; - } - - @Override - public void removeEntity(TileEntity ent) - { - super.removeEntity(ent); - this.pressureLoads.remove(ent); - this.pressureProducers.remove(ent); - } - - /** - * Adds FLuid to this network from one of the connected Pipes - * - * @param source - Were this liquid came from - * @param stack - LiquidStack to be sent - * @param doFill - actually fill the tank or just check numbers - * @return the amount of liquid consumed from the init stack - */ - public int addFluidToNetwork(TileEntity source, LiquidStack stack, boolean doFill) - { - return this.addFluidToNetwork(source, stack, doFill, false); - } - - /** - * Adds FLuid to this network from one of the connected Pipes - * - * @param source - Were this liquid came from - * @param stack - LiquidStack to be sent - * @param doFill - actually fill the tank or just check numbers - * @param allowStore - allows the network to store this liquid in the pipes - * @return the amount of liquid consumed from the init stack - */ - public int addFluidToNetwork(TileEntity source, LiquidStack sta, boolean doFill, boolean allowStore) - { - int used = 0; - LiquidStack prevCombined = this.combinedStorage().getLiquid(); - LiquidStack stack = sta.copy(); - - if (!this.processingRequest && stack != null && FluidRestrictionHandler.isValidLiquid(color,stack)) - { - this.processingRequest = true; - - if (this.combinedStorage().getLiquid() != null && !stack.isLiquidEqual(this.combinedStorage().getLiquid())) - { - this.causingMixing(null,this.combinedStorage().getLiquid(), stack); - } - if (stack.amount > this.getMaxFlow(stack)) - { - stack = new LiquidStack(stack.itemID, this.getMaxFlow(stack), stack.itemMeta); - } - - /* Main fill target to try to fill with the stack */ - ITankContainer primaryFill = null; - int volume = Integer.MAX_VALUE; - ForgeDirection fillDir = ForgeDirection.UNKNOWN; - - /* Secondary fill target if the main target is not found */ - ITankContainer secondayFill = null; - int mostFill = 0; - ForgeDirection otherFillDir = ForgeDirection.UNKNOWN; - - boolean found = false; - - /* FIND THE FILL TARGET FROM THE LIST OF FLUID RECIEVERS */ - for (ITankContainer tankContainer : connectedTanks) - { - if (tankContainer instanceof TileEntity && tankContainer != source && !(tankContainer instanceof INetworkPipe)) - { - TileEntity[] connectedTiles = ConnectionHelper.getSurroundingTileEntities((TileEntity) tankContainer); - - for (int i = 0; i < 6; i++) - { - if (connectedTiles[i] instanceof INetworkPipe && ((INetworkPipe) connectedTiles[i]).getTileNetwork() == this) - { - ForgeDirection dir = ForgeDirection.getOrientation(i).getOpposite(); - ILiquidTank targetTank = tankContainer.getTank(dir, stack); - int fill = tankContainer.fill(dir, stack, false); - - /* USE GET TANK FROM SIDE METHOD FIRST */ - if (targetTank != null) - { - LiquidStack stackStored = targetTank.getLiquid(); - if (stackStored == null) - { - primaryFill = tankContainer; - found = true; - fillDir = dir; - break; - } - else if (stackStored.amount < targetTank.getCapacity() && stackStored.amount < volume) - { - primaryFill = tankContainer; - volume = stackStored.amount; - } - }/* USE FILL METHOD IF GET TANK == NULL */ - else if (fill > 0 && fill > mostFill) - { - secondayFill = tankContainer; - mostFill = fill; - otherFillDir = dir; - } - } - } - } - if (found) - { - break; - } - }// End of tank finder - - boolean filledMain = false; - if (primaryFill != null) - { - used = primaryFill.fill(fillDir, stack, doFill); - // System.out.println("Primary Target " + used + doFill); - } - else if (secondayFill != null) - { - used = secondayFill.fill(fillDir, stack, doFill); - // System.out.println("Seconday Target " + used + doFill); - } - else if (allowStore) - { - used = this.storeFluidInSystem(stack, doFill); - // System.out.println("Network Target filled for " + used + doFill); - filledMain = true; - } - - /* IF THE COMBINED STORAGE OF THE PIPES HAS LIQUID MOVE IT FIRST */ - if (!filledMain && used > 0 && this.combinedStorage().getLiquid() != null && this.combinedStorage().getLiquid().amount > 0) - { - - LiquidStack drainStack = new LiquidStack(0, 0, 0); - if (this.combinedStorage().getLiquid().amount >= used) - { - drainStack = this.combinedStorage().drain(used, doFill); - used = 0; - } - else - { - int pUsed = used; - used = Math.min(used, Math.max(used - this.combinedStorage().getLiquid().amount, 0)); - drainStack = this.combinedStorage().drain(pUsed - used, doFill); - } - // System.out.println("Pulling " + (drainStack != null ? drainStack.amount : 0) + - // " from combined leaving " + (this.combinedStorage.getLiquid() != null ? - // this.combinedStorage.getLiquid().amount : 0)); - - } - if (prevCombined != null && this.combinedStorage().getLiquid() != null && prevCombined.amount != this.combinedStorage().getLiquid().amount) - { - this.balanceColletiveTank(false); - } - } - this.processingRequest = false; - return used; - } - - /** - * Gets the flow rate of the system using the lowest flow rate - */ - public int getMaxFlow(LiquidStack stack) - { - int flow = 1000; - for (INetworkPart conductor : this.networkMember) - { - if (conductor instanceof INetworkPipe) - { - int cFlow = ((INetworkPipe) conductor).getMaxFlowRate(stack, ForgeDirection.UNKNOWN); - if (cFlow < flow) - { - flow = cFlow; - } - } - } - return flow; - } - - /** - * Updates after the pressure has changed a good bit - */ - public void onPresureChange() - { - this.cleanUpConductors(); - - for (int i = 0; i < networkMember.size(); i++) - { - if (networkMember.get(i) instanceof INetworkPipe) - { - INetworkPipe part = (INetworkPipe) networkMember.get(i); - if (part.getMaxPressure(ForgeDirection.UNKNOWN) < this.pressureProduced && part.onOverPressure(true)) - { - this.networkMember.remove(part); - this.cleanUpConductors(); - } - } - - } - } - -} diff --git a/src/minecraft/dark/core/hydraulic/network/NetworkPathFinder.java b/src/minecraft/dark/core/tile/network/NetworkPathFinder.java similarity index 80% rename from src/minecraft/dark/core/hydraulic/network/NetworkPathFinder.java rename to src/minecraft/dark/core/tile/network/NetworkPathFinder.java index 408d8ed27..d4f876330 100644 --- a/src/minecraft/dark/core/hydraulic/network/NetworkPathFinder.java +++ b/src/minecraft/dark/core/tile/network/NetworkPathFinder.java @@ -1,5 +1,4 @@ -package dark.core.hydraulic.network; - +package dark.core.tile.network; import java.util.Arrays; import java.util.HashSet; @@ -11,8 +10,8 @@ import net.minecraftforge.common.ForgeDirection; import universalelectricity.core.path.IPathCallBack; import universalelectricity.core.path.Pathfinder; import universalelectricity.core.vector.Vector3; -import dark.core.api.network.INetworkPart; -import dark.core.api.network.fluid.INetworkPipe; +import dark.core.api.INetworkPart; +import dark.core.api.ITileConnector; /** * Check if a conductor connects with another. @@ -34,9 +33,9 @@ public class NetworkPathFinder extends Pathfinder Vector3 position = currentNode.clone().modifyPositionFromSide(direction); TileEntity connectedBlock = position.getTileEntity(world); - if (connectedBlock instanceof INetworkPipe && !Arrays.asList(splitPoint).contains(connectedBlock)) + if (connectedBlock instanceof ITileConnector && !Arrays.asList(splitPoint).contains(connectedBlock)) { - if (((INetworkPipe) connectedBlock).canTileConnect(connectedBlock, direction.getOpposite())) + if (((ITileConnector) connectedBlock).canTileConnect(connectedBlock, direction.getOpposite())) { neighbors.add(position); } diff --git a/src/minecraft/dark/core/hydraulic/network/NetworkTileEntities.java b/src/minecraft/dark/core/tile/network/NetworkTileEntities.java similarity index 98% rename from src/minecraft/dark/core/hydraulic/network/NetworkTileEntities.java rename to src/minecraft/dark/core/tile/network/NetworkTileEntities.java index 6cdf599ad..f06bdf0c9 100644 --- a/src/minecraft/dark/core/hydraulic/network/NetworkTileEntities.java +++ b/src/minecraft/dark/core/tile/network/NetworkTileEntities.java @@ -1,4 +1,4 @@ -package dark.core.hydraulic.network; +package dark.core.tile.network; import java.util.ArrayList; @@ -11,7 +11,7 @@ import net.minecraft.world.World; import universalelectricity.core.path.Pathfinder; import universalelectricity.core.vector.Vector3; import cpw.mods.fml.common.FMLLog; -import dark.core.api.network.INetworkPart; +import dark.core.api.INetworkPart; public class NetworkTileEntities { diff --git a/src/minecraft/dark/library/files/FileManager.java b/src/minecraft/dark/library/files/FileManager.java deleted file mode 100644 index e10157ecb..000000000 --- a/src/minecraft/dark/library/files/FileManager.java +++ /dev/null @@ -1,63 +0,0 @@ -package dark.library.files; - -import java.io.File; - -import net.minecraft.client.Minecraft; -import net.minecraft.server.MinecraftServer; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.registry.LanguageRegistry; -import cpw.mods.fml.relauncher.Side; - -public class FileManager -{ - public static final String directory = (Loader.instance().getConfigDir().toString() + File.separator + "Dark"); - public static final String langFile = directory + File.separator + "language"; - public static final String npc = directory + File.separator + "npc"; - - /** - * Gets all files in a directory - */ - public static File[] ListFilesInDir(String dir) - { - File folder = new File(dir); - - if (!folder.exists()) - { - folder.mkdirs(); - } - - File[] listOfFiles = folder.listFiles(); - - return listOfFiles; - } - /** - * Loads language files - */ - public static int loadLangFiles(File[] files) - { - int unofficialLanguages = 0; - - try - { - for (File langFile : files) - { - if (langFile.exists()) - { - String name = langFile.getName(); - if (name.endsWith(".lang")) - { - String lang = name.substring(0, name.length() - 4); - LanguageRegistry.instance().loadLocalization(langFile.toString(), lang, false); - unofficialLanguages++; - } - } - } - } - catch (Exception e) - { - // the folder is likely empty, so what... - } - - return unofficialLanguages; - } -} diff --git a/src/minecraft/dark/library/gui/GuiGlobalList.java b/src/minecraft/dark/library/gui/GuiGlobalList.java index f356c9130..f80dbe99c 100644 --- a/src/minecraft/dark/library/gui/GuiGlobalList.java +++ b/src/minecraft/dark/library/gui/GuiGlobalList.java @@ -18,7 +18,7 @@ import universalelectricity.core.vector.Vector2; import universalelectricity.prefab.GuiBase; import universalelectricity.prefab.vector.Region2; import dark.core.DarkMain; -import dark.core.api.terminal.IScroll; +import dark.core.api.IScroll; import dark.library.access.UserAccess; public class GuiGlobalList extends GuiBase implements IScroll diff --git a/src/minecraft/dark/library/inv/ISlotPickResult.java b/src/minecraft/dark/library/gui/ISlotPickResult.java similarity index 95% rename from src/minecraft/dark/library/inv/ISlotPickResult.java rename to src/minecraft/dark/library/gui/ISlotPickResult.java index 11634eeb7..e3bf0cd3d 100644 --- a/src/minecraft/dark/library/inv/ISlotPickResult.java +++ b/src/minecraft/dark/library/gui/ISlotPickResult.java @@ -1,4 +1,4 @@ -package dark.library.inv; +package dark.library.gui; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; diff --git a/src/minecraft/dark/library/inv/ISlotWatcher.java b/src/minecraft/dark/library/gui/ISlotWatcher.java similarity index 90% rename from src/minecraft/dark/library/inv/ISlotWatcher.java rename to src/minecraft/dark/library/gui/ISlotWatcher.java index d62031154..cb47e5e2c 100644 --- a/src/minecraft/dark/library/inv/ISlotWatcher.java +++ b/src/minecraft/dark/library/gui/ISlotWatcher.java @@ -1,4 +1,4 @@ -package dark.library.inv; +package dark.library.gui; /** * Add this to a container class if using WatchedSlot to trigger the container on slot change diff --git a/src/minecraft/dark/library/inv/SlotCraftingResult.java b/src/minecraft/dark/library/gui/SlotCraftingResult.java similarity index 93% rename from src/minecraft/dark/library/inv/SlotCraftingResult.java rename to src/minecraft/dark/library/gui/SlotCraftingResult.java index 996796a37..46a7d59f1 100644 --- a/src/minecraft/dark/library/inv/SlotCraftingResult.java +++ b/src/minecraft/dark/library/gui/SlotCraftingResult.java @@ -1,7 +1,6 @@ -package dark.library.inv; +package dark.library.gui; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; diff --git a/src/minecraft/dark/library/inv/SlotRestricted.java b/src/minecraft/dark/library/gui/SlotRestricted.java similarity index 96% rename from src/minecraft/dark/library/inv/SlotRestricted.java rename to src/minecraft/dark/library/gui/SlotRestricted.java index 876ca3cf2..7182a9dcf 100644 --- a/src/minecraft/dark/library/inv/SlotRestricted.java +++ b/src/minecraft/dark/library/gui/SlotRestricted.java @@ -1,4 +1,4 @@ -package dark.library.inv; +package dark.library.gui; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; diff --git a/src/minecraft/dark/library/inv/WatchedSlot.java b/src/minecraft/dark/library/gui/WatchedSlot.java similarity index 95% rename from src/minecraft/dark/library/inv/WatchedSlot.java rename to src/minecraft/dark/library/gui/WatchedSlot.java index f82355483..abaef5670 100644 --- a/src/minecraft/dark/library/inv/WatchedSlot.java +++ b/src/minecraft/dark/library/gui/WatchedSlot.java @@ -1,4 +1,4 @@ -package dark.library.inv; +package dark.library.gui; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; diff --git a/src/minecraft/dark/library/machine/crafting/AutoCraftingManager.java b/src/minecraft/dark/library/machine/AutoCraftingManager.java similarity index 99% rename from src/minecraft/dark/library/machine/crafting/AutoCraftingManager.java rename to src/minecraft/dark/library/machine/AutoCraftingManager.java index 35a202f78..2a0e87a4e 100644 --- a/src/minecraft/dark/library/machine/crafting/AutoCraftingManager.java +++ b/src/minecraft/dark/library/machine/AutoCraftingManager.java @@ -1,4 +1,4 @@ -package dark.library.machine.crafting; +package dark.library.machine; import java.util.ArrayList; import java.util.List; diff --git a/src/minecraft/dark/library/machine/crafting/IAutoCrafter.java b/src/minecraft/dark/library/machine/IAutoCrafter.java similarity index 76% rename from src/minecraft/dark/library/machine/crafting/IAutoCrafter.java rename to src/minecraft/dark/library/machine/IAutoCrafter.java index 19fc24e74..236c9ff8e 100644 --- a/src/minecraft/dark/library/machine/crafting/IAutoCrafter.java +++ b/src/minecraft/dark/library/machine/IAutoCrafter.java @@ -1,4 +1,4 @@ -package dark.library.machine.crafting; +package dark.library.machine; public interface IAutoCrafter { diff --git a/src/minecraft/dark/library/machine/TileEntityRunnableMachine.java b/src/minecraft/dark/library/machine/TileEntityRunnableMachine.java index dcc09fd5a..a7559a49f 100644 --- a/src/minecraft/dark/library/machine/TileEntityRunnableMachine.java +++ b/src/minecraft/dark/library/machine/TileEntityRunnableMachine.java @@ -18,7 +18,7 @@ import universalelectricity.prefab.tile.TileEntityElectricityRunnable; import buildcraft.api.power.IPowerProvider; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerFramework; -import dark.core.power.PowerSystems; +import dark.core.PowerSystems; public abstract class TileEntityRunnableMachine extends TileEntityElectricityRunnable implements IPowerReceptor, IEnergySink, IConnector, IVoltage { diff --git a/src/minecraft/dark/library/machine/terminal/commands/CommandHelp.java b/src/minecraft/dark/library/machine/terminal/CommandHelp.java similarity index 93% rename from src/minecraft/dark/library/machine/terminal/commands/CommandHelp.java rename to src/minecraft/dark/library/machine/terminal/CommandHelp.java index 7c0b91d72..6e84e29ed 100644 --- a/src/minecraft/dark/library/machine/terminal/commands/CommandHelp.java +++ b/src/minecraft/dark/library/machine/terminal/CommandHelp.java @@ -1,12 +1,12 @@ -package dark.library.machine.terminal.commands; +package dark.library.machine.terminal; import java.util.ArrayList; import java.util.List; import net.minecraft.entity.player.EntityPlayer; -import dark.core.api.terminal.ISpecialAccess; -import dark.core.api.terminal.ITerminal; +import dark.core.api.ISpecialAccess; +import dark.core.api.ITerminal; public class CommandHelp extends TerminalCommand { diff --git a/src/minecraft/dark/library/machine/terminal/commands/CommandRegistry.java b/src/minecraft/dark/library/machine/terminal/CommandRegistry.java similarity index 94% rename from src/minecraft/dark/library/machine/terminal/commands/CommandRegistry.java rename to src/minecraft/dark/library/machine/terminal/CommandRegistry.java index b012d76a3..446b8840f 100644 --- a/src/minecraft/dark/library/machine/terminal/commands/CommandRegistry.java +++ b/src/minecraft/dark/library/machine/terminal/CommandRegistry.java @@ -1,11 +1,11 @@ -package dark.library.machine.terminal.commands; +package dark.library.machine.terminal; import java.util.ArrayList; import java.util.List; import net.minecraft.entity.player.EntityPlayer; -import dark.core.api.terminal.ITerminal; +import dark.core.api.ITerminal; /** * * @author Calclavia, DarkGuardsman diff --git a/src/minecraft/dark/library/machine/terminal/commands/CommandUser.java b/src/minecraft/dark/library/machine/terminal/CommandUser.java similarity index 94% rename from src/minecraft/dark/library/machine/terminal/commands/CommandUser.java rename to src/minecraft/dark/library/machine/terminal/CommandUser.java index 5c846045f..d9ea103b1 100644 --- a/src/minecraft/dark/library/machine/terminal/commands/CommandUser.java +++ b/src/minecraft/dark/library/machine/terminal/CommandUser.java @@ -1,11 +1,11 @@ -package dark.library.machine.terminal.commands; +package dark.library.machine.terminal; import java.util.ArrayList; import java.util.List; import net.minecraft.entity.player.EntityPlayer; -import dark.core.api.terminal.ISpecialAccess; -import dark.core.api.terminal.ITerminal; +import dark.core.api.ISpecialAccess; +import dark.core.api.ITerminal; import dark.library.access.AccessLevel; public class CommandUser extends TerminalCommand diff --git a/src/minecraft/dark/library/machine/terminal/commands/TerminalCommand.java b/src/minecraft/dark/library/machine/terminal/TerminalCommand.java similarity index 91% rename from src/minecraft/dark/library/machine/terminal/commands/TerminalCommand.java rename to src/minecraft/dark/library/machine/terminal/TerminalCommand.java index 073cd090d..560694f01 100644 --- a/src/minecraft/dark/library/machine/terminal/commands/TerminalCommand.java +++ b/src/minecraft/dark/library/machine/terminal/TerminalCommand.java @@ -1,11 +1,11 @@ -package dark.library.machine.terminal.commands; +package dark.library.machine.terminal; import java.util.List; import net.minecraft.entity.player.EntityPlayer; -import dark.core.api.terminal.ISpecialAccess; -import dark.core.api.terminal.ITerminal; +import dark.core.api.ISpecialAccess; +import dark.core.api.ITerminal; /** * * @author Calclavia, DarkGuardsman diff --git a/src/minecraft/dark/library/machine/terminal/TileEntityTerminal.java b/src/minecraft/dark/library/machine/terminal/TileEntityTerminal.java index 6479bf596..2a4ba698a 100644 --- a/src/minecraft/dark/library/machine/terminal/TileEntityTerminal.java +++ b/src/minecraft/dark/library/machine/terminal/TileEntityTerminal.java @@ -20,12 +20,11 @@ import com.google.common.io.ByteArrayDataInput; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.Player; -import dark.core.api.terminal.ISpecialAccess; -import dark.core.api.terminal.ITerminal; +import dark.core.api.ISpecialAccess; +import dark.core.api.ITerminal; import dark.library.access.AccessLevel; import dark.library.access.UserAccess; import dark.library.machine.TileEntityRunnableMachine; -import dark.library.machine.terminal.commands.CommandRegistry; /** * diff --git a/src/minecraft/dark/library/orbit/IOrbitingEntity.java b/src/minecraft/dark/library/orbit/IOrbitingEntity.java deleted file mode 100644 index e15246228..000000000 --- a/src/minecraft/dark/library/orbit/IOrbitingEntity.java +++ /dev/null @@ -1,16 +0,0 @@ -package dark.library.orbit; - -import universalelectricity.core.vector.Vector3; - -public interface IOrbitingEntity -{ - /** - * Gets the current orbit the object is using - */ - public NetworkOrbit getOrbit(); - - /** - * Tells this object were it should be in the orbit - */ - public void setOrbitWayPoint(Vector3 vec); -} diff --git a/src/minecraft/dark/library/orbit/NetworkOrbit.java b/src/minecraft/dark/library/orbit/NetworkOrbit.java deleted file mode 100644 index a7fe902cf..000000000 --- a/src/minecraft/dark/library/orbit/NetworkOrbit.java +++ /dev/null @@ -1,164 +0,0 @@ -package dark.library.orbit; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map.Entry; - -import dark.helpers.Pair; -import dark.library.math.LinearAlg; -import dark.library.math.Quaternion; - -import net.minecraft.entity.Entity; -import universalelectricity.core.vector.Vector3; - -/** - * Designed to be used by flying Entities to create an orbit pattern around a central point - * - * @author DarkGuardsman - * - */ -public class NetworkOrbit -{ - /* DEFINED IDEAL NUMBER OF OBJECTS IN ORBIT */ - public static int minObjects = 3; - public static int maxObjects = 20; - - /* CURRENT RADIUS OF THE CIRCLE */ - Double orbitRadius; - - /* CHANGE IN ROTATION OF THE CIRCLE X Y Z */ - Vector3 rotationChange = new Vector3(0, 0, 0); - - /* OBJECTS IN ORBIT */ - HashMap orbitMemeber = new HashMap(); - - /** - * @param entities - entities to add to this orbit when its created < Entity, Radius change> - */ - public NetworkOrbit(HashMap entities) - { - if (entities != null) - { - this.orbitMemeber.putAll(entities); - } - } - - /** - * Called by the host of the orbit too see if this orbit can continue - */ - public boolean canOrbitExist() - { - int members = this.getOrbitMemebers().size(); - if (members > maxObjects || members < minObjects) - { - return false; - } - return true; - } - - /** - * Gets the list of Entities in this orbit - */ - public HashMap getOrbitMemebers() - { - if (this.orbitMemeber == null) - { - this.orbitMemeber = new HashMap(); - } - return this.orbitMemeber; - } - - /** - * Increase/changes the rotation angles of the orbit - * - * @param vec - rotation change stored as a vector3 - * @param increase - add the vec rotation to current rotation - */ - public void changeRotation(Vector3 vec, boolean increase) - { - Vector3 preRotation = rotationChange.clone(); - this.rotationChange = vec; - if (increase) - { - this.rotationChange.add(preRotation); - } - } - - /** - * Get the rotation change of the orbit - */ - public Vector3 getRotation() - { - if (this.rotationChange == null) - { - this.rotationChange = new Vector3(0, 0, 0); - } - return this.rotationChange; - } - - /** - * Ideal minimal radius needed for the number of objects - */ - public double getMinRadius() - { - float width = 0; - Iterator> it = this.getOrbitMemebers().entrySet().iterator(); - while (it.hasNext()) - { - IOrbitingEntity entity = it.next().getKey(); - if (entity instanceof Entity) - { - width += ((Entity) entity).width > ((Entity) entity).height ? ((Entity) entity).width : ((Entity) entity).height; - } - else - { - // TODO get size threw the interface or detect other possible orbit objects - width += 1; - } - } - width = width / this.getOrbitMemebers().size(); - return ((width + (width / 2)) * this.getOrbitMemebers().size()); - } - - /** - * @param pos - position in the orbit - * @return offset distance from orbit center - * - * Note this only gives the offset from the orbit point. This needs to be used to in combo with - * something else to get the orbit point. Then add the result of this to get the pos of the - * object - * - * http://en.wikipedia.org/wiki/Spherical_coordinates - */ - public Vector3 getOrbitOffset(Entity entity, int pos) - { - /* GET RADIUS OF CIRCLE IF TOO SMALL INCREASE AS WELL INCRASE BY OFFSET GIVEN */ - double r = this.getMinRadius(); - if (this.orbitRadius < r) - { - this.orbitRadius = r; - } - else - { - r = this.orbitRadius; - } - if (entity instanceof IOrbitingEntity && this.getOrbitMemebers().containsKey(entity)) - { - r += this.getOrbitMemebers().get(entity); - } - /* DO ROTATION */ - double spacing = (2 * r * Math.PI) / this.getOrbitMemebers().size(); - return NetworkOrbit.getOrbitOffset(r, spacing * pos, this.getRotation()); - } - - public static Vector3 getOrbitOffset(double r, double o, Vector3 t) - { - Quaternion quat = new Quaternion(); - Quaternion ya = new Quaternion(); - - quat.FromEuler((float) t.x, ((float) (t.y)), (float) t.z); - ya.FromAxis(new Vector3(0, 1f, 0), (float) o); - - return quat.multi(ya).multi(new Vector3(0, 0, r)); - } -} diff --git a/src/minecraft/dark/prefab/tile/fluid/TileEntityFluidDevice.java b/src/minecraft/dark/prefab/tile/fluid/TileEntityFluidDevice.java deleted file mode 100644 index 9e600d75d..000000000 --- a/src/minecraft/dark/prefab/tile/fluid/TileEntityFluidDevice.java +++ /dev/null @@ -1,42 +0,0 @@ -package dark.prefab.tile.fluid; - -import java.util.Random; - -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.liquids.ITankContainer; -import net.minecraftforge.liquids.LiquidStack; -import universalelectricity.prefab.tile.TileEntityAdvanced; -import dark.core.api.network.ITileConnector; -import dark.core.api.tools.IReadOut; -import dark.core.hydraulic.network.fluid.HydraulicNetworkHelper; - -public abstract class TileEntityFluidDevice extends TileEntityAdvanced implements IReadOut, ITileConnector -{ - public Random random = new Random(); - - @Override - public void invalidate() - { - super.invalidate(); - HydraulicNetworkHelper.invalidate(this); - } - - /** - * Fills an ITankContainer in the direction - * - * @param stack - LiquidStack that will be inputed in the tile - * @param side - direction to fill in - * @return the ammount filled - */ - public int fillSide(LiquidStack stack, ForgeDirection side, boolean doFill) - { - TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ); - - if (stack != null && stack.amount > 0 && tileEntity instanceof ITankContainer) - { - return ((ITankContainer) tileEntity).fill(side.getOpposite(), stack, doFill); - } - return 0; - } -} diff --git a/src/minecraft/dark/prefab/tile/fluid/TileEntityFluidStorage.java b/src/minecraft/dark/prefab/tile/fluid/TileEntityFluidStorage.java deleted file mode 100644 index 21407d776..000000000 --- a/src/minecraft/dark/prefab/tile/fluid/TileEntityFluidStorage.java +++ /dev/null @@ -1,154 +0,0 @@ -package dark.prefab.tile.fluid; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -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.LiquidDictionary; -import net.minecraftforge.liquids.LiquidStack; -import net.minecraftforge.liquids.LiquidTank; -import dark.core.api.IColorCoded; -import dark.core.hydraulic.helpers.FluidHelper; -import dark.core.hydraulic.helpers.FluidRestrictionHandler; - -public abstract class TileEntityFluidStorage extends TileEntityFluidDevice implements ITankContainer, IColorCoded -{ - /* INTERNAL TANK */ - public LiquidTank tank = new LiquidTank(this.getTankSize()); - - /** - * gets the max storage limit of the tank - */ - public abstract int getTankSize(); - - @Override - public String getMeterReading(EntityPlayer user, ForgeDirection side) - { - if (this.tank.getLiquid() == null) - { - return "Empty"; - } - return String.format("%d/%d %S Stored", tank.getLiquid().amount / LiquidContainerRegistry.BUCKET_VOLUME, tank.getCapacity() / LiquidContainerRegistry.BUCKET_VOLUME, LiquidDictionary.findLiquidName(tank.getLiquid())); - } - - @Override - public boolean canTileConnect(TileEntity entity, ForgeDirection dir) - { - if (entity instanceof ITankContainer) - { - return true; - } - return false; - } - - @Override - public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) - { - return this.fill(0, resource, doFill); - } - - @Override - public int fill(int tankIndex, LiquidStack resource, boolean doFill) - { - if (resource == null || tankIndex != 0) - { - return 0; - } - else if (!FluidRestrictionHandler.isValidLiquid(getColor(),resource)) - { - return 0; - } - else if (this.tank.getLiquid() != null && !resource.isLiquidEqual(this.tank.getLiquid())) - { - return 0; - } - return this.tank.fill(resource, doFill); - } - - @Override - public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - return this.drain(0, maxDrain, doDrain); - } - - @Override - public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain) - { - if (tankIndex != 0 || this.tank.getLiquid() == null) - { - return null; - } - LiquidStack stack = this.tank.getLiquid(); - if (maxDrain < stack.amount) - { - stack = FluidHelper.getStack(stack, maxDrain); - } - return this.tank.drain(maxDrain, doDrain); - } - - @Override - public ILiquidTank[] getTanks(ForgeDirection dir) - { - return new ILiquidTank[] { this.tank }; - } - - @Override - public ILiquidTank getTank(ForgeDirection dir, LiquidStack type) - { - if (type == null) - { - return null; - } - if (type.isLiquidEqual(this.tank.getLiquid())) - { - return this.tank; - } - return null; - } - - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - - LiquidStack liquid = LiquidStack.loadLiquidStackFromNBT(nbt.getCompoundTag("stored")); - if (liquid != null) - { - tank.setLiquid(liquid); - } - } - - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - if (this.tank.containsValidLiquid()) - { - nbt.setTag("stored", this.tank.getLiquid().writeToNBT(new NBTTagCompound())); - } - } - - /** - * Is the internal tank full - */ - public boolean isFull() - { - if (this.tank.getLiquid() == null || this.tank.getLiquid().amount < this.tank.getCapacity()) - { - return false; - } - return true; - } - - /** - * gets the liquidStack stored in the internal tank - */ - public LiquidStack getStoredLiquid() - { - return this.tank.getLiquid(); - } - -}