diff --git a/common/net/minecraftforge/liquids/ILiquidTank.java b/common/net/minecraftforge/liquids/ILiquidTank.java index f904b93be4..64c1bbd366 100644 --- a/common/net/minecraftforge/liquids/ILiquidTank.java +++ b/common/net/minecraftforge/liquids/ILiquidTank.java @@ -1,13 +1,37 @@ package net.minecraftforge.liquids; +/** + * A tank is the unit of interaction with liquid inventories. + * + * @author cpw + */ public interface ILiquidTank { /** * @return LiquidStack representing the liquid contained in the tank, null if empty. */ LiquidStack getLiquid(); + + /** + * These shouldn't be used to interact with a foreign tank. Use {@link #fill(LiquidStack, boolean)} + * and {@link #drain(int, boolean)}. + * + * @param liquid + */ + @Deprecated void setLiquid(LiquidStack liquid); + /** + * This method should not be used to interact with a foreign tank. Use {@link #fill(LiquidStack, boolean)} + * and {@link #drain(int, boolean)}. + * + * @param capacity + */ + @Deprecated void setCapacity(int capacity); + + /** + * @return capacity of this tank + */ int getCapacity(); /** diff --git a/common/net/minecraftforge/liquids/LiquidContainerData.java b/common/net/minecraftforge/liquids/LiquidContainerData.java new file mode 100644 index 0000000000..d939cab759 --- /dev/null +++ b/common/net/minecraftforge/liquids/LiquidContainerData.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) SpaceToad, 2011 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ + +package net.minecraftforge.liquids; + +import net.minecraft.src.Item; +import net.minecraft.src.ItemStack; + +public class LiquidContainerData { + + public final LiquidStack stillLiquid; + @Deprecated public LiquidStack movingLiquid; + public final ItemStack filled; + public final ItemStack container; + + + @Deprecated + public LiquidContainerData(int stillLiquidId, int movingLiquidId, Item filled) { + this(new LiquidStack(stillLiquidId, LiquidItemRegistry.BUCKET_VOLUME), new LiquidStack(movingLiquidId, LiquidItemRegistry.BUCKET_VOLUME), new ItemStack(filled, 1), new ItemStack(Item.bucketEmpty)); + } + + @Deprecated + public LiquidContainerData(int stillLiquidId, int movingLiquidId, ItemStack filled) { + this(new LiquidStack(stillLiquidId, LiquidItemRegistry.BUCKET_VOLUME), new LiquidStack(movingLiquidId, LiquidItemRegistry.BUCKET_VOLUME), filled, new ItemStack(Item.bucketEmpty)); + } + + public LiquidContainerData(LiquidStack stillLiquid, ItemStack filled, ItemStack container) { + this.stillLiquid = stillLiquid; + this.filled = filled; + this.container = container; + + if(stillLiquid == null || filled == null || container == null) + throw new RuntimeException("stillLiquid, filled, or container is null, this is an error"); + } + + @Deprecated + public LiquidContainerData(LiquidStack stillLiquid, LiquidStack movingLiquid, ItemStack filled, ItemStack container) { + this(stillLiquid, filled, container); + this.movingLiquid = movingLiquid; + } + +} diff --git a/common/net/minecraftforge/liquids/LiquidData.java b/common/net/minecraftforge/liquids/LiquidData.java deleted file mode 100644 index feff1ec4c0..0000000000 --- a/common/net/minecraftforge/liquids/LiquidData.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) SpaceToad, 2011 - * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public - * License 1.0, or MMPL. Please check the contents of the license located in - * http://www.mod-buildcraft.com/MMPL-1.0.txt - */ - -package net.minecraftforge.liquids; - -import net.minecraft.src.Item; -import net.minecraft.src.ItemStack; - -public class LiquidData { - - public final LiquidStack stillLiquid; - public final LiquidStack movingLiquid; - - public final ItemStack filled; - public final ItemStack container; - - public LiquidData(int stillLiquidId, int movingLiquidId, Item filled) { - this(new LiquidStack(stillLiquidId, LiquidManager.BUCKET_VOLUME), new LiquidStack(movingLiquidId, LiquidManager.BUCKET_VOLUME), new ItemStack(filled, 1), new ItemStack(Item.bucketEmpty)); - } - - public LiquidData(int stillLiquidId, int movingLiquidId, ItemStack filled) { - this(new LiquidStack(stillLiquidId, LiquidManager.BUCKET_VOLUME), new LiquidStack(movingLiquidId, LiquidManager.BUCKET_VOLUME), filled, new ItemStack(Item.bucketEmpty)); - } - - public LiquidData(LiquidStack stillLiquid, ItemStack filled, ItemStack container) { - this(stillLiquid, stillLiquid, filled, container); - } - - public LiquidData(LiquidStack stillLiquid, LiquidStack movingLiquid, ItemStack filled, ItemStack container) { - this.stillLiquid = stillLiquid; - this.movingLiquid = movingLiquid; - this.filled = filled; - this.container = container; - - if(stillLiquid == null || filled == null || container == null) - throw new RuntimeException("stillLiquid, filled, or container is null, this is an error"); - } - -} diff --git a/common/net/minecraftforge/liquids/LiquidManager.java b/common/net/minecraftforge/liquids/LiquidItemRegistry.java similarity index 66% rename from common/net/minecraftforge/liquids/LiquidManager.java rename to common/net/minecraftforge/liquids/LiquidItemRegistry.java index f594e30ed7..c5e7273a98 100644 --- a/common/net/minecraftforge/liquids/LiquidManager.java +++ b/common/net/minecraftforge/liquids/LiquidItemRegistry.java @@ -13,25 +13,35 @@ import net.minecraft.src.Block; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; -public class LiquidManager { +public class LiquidItemRegistry { public static final int BUCKET_VOLUME = 1000; private static Map mapItemFromLiquid = new HashMap(); private static Map mapLiquidFromItem = new HashMap(); private static Set setLiquidValidation = new HashSet(); - private static ArrayList liquids = new ArrayList(); + private static ArrayList liquids = new ArrayList(); static { - registerLiquid(new LiquidData(new LiquidStack(Block.waterStill, LiquidManager.BUCKET_VOLUME), new LiquidStack(Block.waterMoving, LiquidManager.BUCKET_VOLUME), + registerLiquid( + new LiquidContainerData( + new LiquidStack(Block.waterStill, LiquidItemRegistry.BUCKET_VOLUME), new ItemStack(Item.bucketWater), new ItemStack(Item.bucketEmpty))); - registerLiquid(new LiquidData(new LiquidStack(Block.lavaStill, LiquidManager.BUCKET_VOLUME), new LiquidStack(Block.lavaMoving, LiquidManager.BUCKET_VOLUME), new ItemStack( - Item.bucketLava), new ItemStack(Item.bucketEmpty))); - registerLiquid(new LiquidData(new LiquidStack(Block.waterStill, LiquidManager.BUCKET_VOLUME), new LiquidStack(Block.waterMoving, LiquidManager.BUCKET_VOLUME), - new ItemStack(Item.potion), new ItemStack(Item.glassBottle))); - } + registerLiquid( + new LiquidContainerData( + new LiquidStack(Block.lavaStill, LiquidItemRegistry.BUCKET_VOLUME), + new ItemStack(Item.bucketLava), new ItemStack(Item.bucketEmpty))); + registerLiquid( + new LiquidContainerData( + new LiquidStack(Block.waterStill, LiquidItemRegistry.BUCKET_VOLUME), + new ItemStack(Item.potion), new ItemStack(Item.glassBottle))); +/* registerLiquid( + new LiquidContainerData( + new LiquidStack(Item.milk, LiquidItemRegistry.BUCKET_VOLUME), + new ItemStack(Item.potion), new ItemStack(Item.glassBottle))); +*/ } - public static void registerLiquid(LiquidData data) { + public static void registerLiquid(LiquidContainerData data) { mapItemFromLiquid.put(Arrays.asList(data.container.itemID, data.container.getItemDamage(), data.stillLiquid.itemID, data.stillLiquid.itemMeta), data.filled); mapLiquidFromItem.put(Arrays.asList(data.filled.itemID, data.filled.getItemDamage()), data.stillLiquid); @@ -66,8 +76,7 @@ public class LiquidManager { return setLiquidValidation.contains(Arrays.asList(block.itemID, block.getItemDamage())); } - public static ArrayList getRegisteredLiquids() { - + public static ArrayList getRegisteredLiquids() { return liquids; } }