From 45a4c299dddaead9c756ae15c3f2e10f32742167 Mon Sep 17 00:00:00 2001 From: SirSengir Date: Tue, 17 Jul 2012 17:49:05 +0200 Subject: [PATCH] Completing new API for liquids. --- .../src/buildcraft/api/ILiquidContainer.java | 1 + .../src/buildcraft/api/LiquidSlot.java | 1 + .../api/liquids/ITankContainer.java | 46 +++++++++++++++++++ .../buildcraft/api/liquids/LiquidTank.java | 22 +++++++++ .../buildcraft/builders/BlockArchitect.java | 1 + .../src/buildcraft/builders/BlockBuilder.java | 1 + .../src/buildcraft/factory/BlockQuarry.java | 1 + .../src/buildcraft/factory/BlockRefinery.java | 1 + .../src/buildcraft/factory/TileQuarry.java | 1 + 9 files changed, 75 insertions(+) create mode 100644 common/net/minecraft/src/buildcraft/api/liquids/ITankContainer.java create mode 100644 common/net/minecraft/src/buildcraft/api/liquids/LiquidTank.java diff --git a/common/net/minecraft/src/buildcraft/api/ILiquidContainer.java b/common/net/minecraft/src/buildcraft/api/ILiquidContainer.java index c8c232e9..bf448aa4 100644 --- a/common/net/minecraft/src/buildcraft/api/ILiquidContainer.java +++ b/common/net/minecraft/src/buildcraft/api/ILiquidContainer.java @@ -9,6 +9,7 @@ package net.minecraft.src.buildcraft.api; +@Deprecated public interface ILiquidContainer { public int fill(Orientations from, int quantity, int id, boolean doFill); diff --git a/common/net/minecraft/src/buildcraft/api/LiquidSlot.java b/common/net/minecraft/src/buildcraft/api/LiquidSlot.java index 934d19b6..1852ab3f 100644 --- a/common/net/minecraft/src/buildcraft/api/LiquidSlot.java +++ b/common/net/minecraft/src/buildcraft/api/LiquidSlot.java @@ -9,6 +9,7 @@ package net.minecraft.src.buildcraft.api; +@Deprecated public class LiquidSlot { private int liquidId; diff --git a/common/net/minecraft/src/buildcraft/api/liquids/ITankContainer.java b/common/net/minecraft/src/buildcraft/api/liquids/ITankContainer.java new file mode 100644 index 00000000..a40aad54 --- /dev/null +++ b/common/net/minecraft/src/buildcraft/api/liquids/ITankContainer.java @@ -0,0 +1,46 @@ +package net.minecraft.src.buildcraft.api.liquids; + +import net.minecraft.src.buildcraft.api.Orientations; + +public interface ITankContainer { + + /** + * Fills liquid into internal tanks, distribution is left to the ITankContainer. + * @param from Orientation the liquid is pumped in from. + * @param resource LiquidStack representing the maximum amount of liquid filled into the ITankContainer + * @param doFill If false filling will only be simulated. + * @return Amount of resource that was filled into internal tanks. + */ + int fill(Orientations from, LiquidStack resource, boolean doFill); + /** + * Fills liquid into the specified internal tank. + * @param from Orientation the liquid is pumped in from. + * @param resource LiquidStack representing the maximum amount of liquid filled into the ITankContainer + * @param doFill If false filling will only be simulated. + * @return Amount of resource that was filled into internal tanks. + */ + int fill(int tankIndex, LiquidStack resource, boolean doFill); + + /** + * Drains liquid out of internal tanks, distribution is left to the ITankContainer. + * @param from Orientation the liquid is drained to. + * @param maxEmpty Maximum amount of liquid to drain. + * @param doDrain If false draining will only be simulated. + * @return LiquidStack representing the liquid and amount actually drained from the ITankContainer + */ + LiquidStack drain(Orientations from, int maxEmpty, boolean doDrain); + /** + * Drains liquid out of the specified internal tank. + * @param from Orientation the liquid is drained to. + * @param maxEmpty Maximum amount of liquid to drain. + * @param doDrain If false draining will only be simulated. + * @return LiquidStack representing the liquid and amount actually drained from the ITankContainer + */ + LiquidStack drain(int tankIndex, int maxEmpty, boolean doDrain); + + /** + * @return Array of {@link LiquidTank}s contained in this ITankContainer + */ + LiquidTank[] getTanks(); + +} diff --git a/common/net/minecraft/src/buildcraft/api/liquids/LiquidTank.java b/common/net/minecraft/src/buildcraft/api/liquids/LiquidTank.java new file mode 100644 index 00000000..a179ae0a --- /dev/null +++ b/common/net/minecraft/src/buildcraft/api/liquids/LiquidTank.java @@ -0,0 +1,22 @@ +package net.minecraft.src.buildcraft.api.liquids; + +public class LiquidTank { + private LiquidStack liquid; + private int capacity; + + public LiquidTank(int liquidId, int quantity, int capacity) { + this(new LiquidStack(liquidId, quantity), capacity); + } + public LiquidTank(LiquidStack liquid, int capacity) { + this.liquid = liquid; + this.capacity = capacity; + } + + public LiquidStack getLiquid() { + return this.liquid; + } + + public int getCapacity() { + return this.capacity; + } +} diff --git a/common/net/minecraft/src/buildcraft/builders/BlockArchitect.java b/common/net/minecraft/src/buildcraft/builders/BlockArchitect.java index 899488b8..56aa2f0d 100644 --- a/common/net/minecraft/src/buildcraft/builders/BlockArchitect.java +++ b/common/net/minecraft/src/buildcraft/builders/BlockArchitect.java @@ -81,6 +81,7 @@ public class BlockArchitect extends BlockContainer implements ITextureProvider { world.setBlockMetadata(i, j, k, Orientations.XNeg.ordinal()); break; case ZPos: + default: world.setBlockMetadata(i, j, k, Orientations.XPos.ordinal()); break; } diff --git a/common/net/minecraft/src/buildcraft/builders/BlockBuilder.java b/common/net/minecraft/src/buildcraft/builders/BlockBuilder.java index 7c4970b4..11537f77 100644 --- a/common/net/minecraft/src/buildcraft/builders/BlockBuilder.java +++ b/common/net/minecraft/src/buildcraft/builders/BlockBuilder.java @@ -94,6 +94,7 @@ public class BlockBuilder extends BlockContainer implements ITextureProvider { world.setBlockMetadata(i, j, k, Orientations.XNeg.ordinal()); break; case ZPos: + default: world.setBlockMetadata(i, j, k, Orientations.XPos.ordinal()); break; } diff --git a/common/net/minecraft/src/buildcraft/factory/BlockQuarry.java b/common/net/minecraft/src/buildcraft/factory/BlockQuarry.java index b9631452..022f9c92 100644 --- a/common/net/minecraft/src/buildcraft/factory/BlockQuarry.java +++ b/common/net/minecraft/src/buildcraft/factory/BlockQuarry.java @@ -108,6 +108,7 @@ public class BlockQuarry extends BlockMachineRoot implements ITextureProvider { case XPos: searchFrames(world, i + 1, j, k); case XNeg: + default: searchFrames(world, i - 1, j, k); } } diff --git a/common/net/minecraft/src/buildcraft/factory/BlockRefinery.java b/common/net/minecraft/src/buildcraft/factory/BlockRefinery.java index 5a249c6a..92046c83 100644 --- a/common/net/minecraft/src/buildcraft/factory/BlockRefinery.java +++ b/common/net/minecraft/src/buildcraft/factory/BlockRefinery.java @@ -94,6 +94,7 @@ public class BlockRefinery extends BlockContainer { world.setBlockMetadata(i, j, k, Orientations.XNeg.ordinal()); break; case ZPos: + default: world.setBlockMetadata(i, j, k, Orientations.XPos.ordinal()); break; } diff --git a/common/net/minecraft/src/buildcraft/factory/TileQuarry.java b/common/net/minecraft/src/buildcraft/factory/TileQuarry.java index 9b252018..4e934f05 100644 --- a/common/net/minecraft/src/buildcraft/factory/TileQuarry.java +++ b/common/net/minecraft/src/buildcraft/factory/TileQuarry.java @@ -542,6 +542,7 @@ public class TileQuarry extends TileMachine implements IArmListener, IMachine, I zMin = zCoord + 1; break; case ZNeg: + default: xMin = xCoord - 4 - 1; zMin = zCoord - 9 - 2; break;