From 73a2a5d78a358455bc9501a2f6731251f666bf33 Mon Sep 17 00:00:00 2001 From: King Lemming Date: Wed, 14 Nov 2012 18:55:08 -0500 Subject: [PATCH 1/4] Liquid Manager Rewrite - slightly more memory usage, loads more efficient at runtime. Added default Lava and Water registrations to Liquid Manager. Removed method which relied on flawed assumption that a given liquid only had a single type of container. Signed-off-by: King Lemming --- .../minecraftforge/liquids/LiquidManager.java | 105 ++++++++++-------- 1 file changed, 57 insertions(+), 48 deletions(-) diff --git a/common/net/minecraftforge/liquids/LiquidManager.java b/common/net/minecraftforge/liquids/LiquidManager.java index 1805a5014..f594e30ed 100644 --- a/common/net/minecraftforge/liquids/LiquidManager.java +++ b/common/net/minecraftforge/liquids/LiquidManager.java @@ -1,64 +1,73 @@ + package net.minecraftforge.liquids; -import java.util.LinkedList; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import net.minecraft.src.Block; +import net.minecraft.src.Item; import net.minecraft.src.ItemStack; public class LiquidManager { - - public static final int BUCKET_VOLUME = 1000; - public static LinkedList liquids = new LinkedList(); - - public static LiquidStack getLiquidForFilledItem(ItemStack filledItem) { - if (filledItem == null) - return null; - for (LiquidData liquid : liquids) - if (liquid.filled.isItemEqual(filledItem)) - return liquid.stillLiquid; + public static final int BUCKET_VOLUME = 1000; - return null; - } - - public static int getLiquidIDForFilledItem(ItemStack filledItem) { - LiquidStack liquidForFilledItem = getLiquidForFilledItem(filledItem); - - if (liquidForFilledItem == null) - return 0; - - return liquidForFilledItem.itemID; - } + private static Map mapItemFromLiquid = new HashMap(); + private static Map mapLiquidFromItem = new HashMap(); + private static Set setLiquidValidation = new HashSet(); + private static ArrayList liquids = new ArrayList(); - public static ItemStack getFilledItemForLiquid(LiquidStack liquid) { - for (LiquidData data : liquids) - if(data.stillLiquid.isLiquidEqual(liquid)) - return data.filled.copy(); + static { + registerLiquid(new LiquidData(new LiquidStack(Block.waterStill, LiquidManager.BUCKET_VOLUME), new LiquidStack(Block.waterMoving, LiquidManager.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))); + } - return null; - } - - public static ItemStack fillLiquidContainer(int liquidId, int quantity, ItemStack emptyContainer) { - return fillLiquidContainer(new LiquidStack(liquidId, quantity, 0), emptyContainer); - } - - public static ItemStack fillLiquidContainer(LiquidStack liquid, ItemStack emptyContainer) { - for(LiquidData data : liquids) - if(liquid.containsLiquid(data.stillLiquid) - && data.container.isItemEqual(emptyContainer)) - return data.filled.copy(); - return null; - } + public static void registerLiquid(LiquidData data) { - public static boolean isLiquid(ItemStack block) { - if (block.itemID == 0) - return false; + 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); + setLiquidValidation.add(Arrays.asList(data.stillLiquid.itemID, data.stillLiquid.itemMeta)); - for (LiquidData liquid : liquids) - if (liquid.stillLiquid.isLiquidEqual(block) || liquid.movingLiquid.isLiquidEqual(block)) - return true; + liquids.add(data); + } - return false; - } + public static LiquidStack getLiquidForFilledItem(ItemStack filledItem) { + if (filledItem == null) { + return null; + } + return mapLiquidFromItem.get(Arrays.asList(filledItem.itemID, filledItem.getItemDamage())); + } + public static ItemStack fillLiquidContainer(int liquidId, int quantity, ItemStack emptyContainer) { + + return fillLiquidContainer(new LiquidStack(liquidId, quantity, 0), emptyContainer); + } + + public static ItemStack fillLiquidContainer(LiquidStack liquid, ItemStack emptyContainer) { + + if (emptyContainer == null || liquid == null) { + return null; + } + return mapItemFromLiquid.get(Arrays.asList(emptyContainer.itemID, emptyContainer.getItemDamage(), liquid.itemID, liquid.itemMeta)); + } + + public static boolean isLiquid(ItemStack block) { + + return setLiquidValidation.contains(Arrays.asList(block.itemID, block.getItemDamage())); + } + + public static ArrayList getRegisteredLiquids() { + + return liquids; + } } From 223aca8a28611dd39d580f462fcd5a495f194db7 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 14 Nov 2012 21:22:44 -0500 Subject: [PATCH 2/4] Rename some liquid stuff for more sensible naming. Tweak API slightly. --- .../minecraftforge/liquids/ILiquidTank.java | 24 ++++++++++ .../liquids/LiquidContainerData.java | 48 +++++++++++++++++++ .../minecraftforge/liquids/LiquidData.java | 45 ----------------- ...idManager.java => LiquidItemRegistry.java} | 31 +++++++----- 4 files changed, 92 insertions(+), 56 deletions(-) create mode 100644 common/net/minecraftforge/liquids/LiquidContainerData.java delete mode 100644 common/net/minecraftforge/liquids/LiquidData.java rename common/net/minecraftforge/liquids/{LiquidManager.java => LiquidItemRegistry.java} (66%) diff --git a/common/net/minecraftforge/liquids/ILiquidTank.java b/common/net/minecraftforge/liquids/ILiquidTank.java index f904b93be..64c1bbd36 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 000000000..d939cab75 --- /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 feff1ec4c..000000000 --- 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 f594e30ed..c5e7273a9 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; } } From 213fb9bd1a079d47d13f3b7ca22ce199129b2ead Mon Sep 17 00:00:00 2001 From: King Lemming Date: Thu, 15 Nov 2012 01:05:23 -0500 Subject: [PATCH 3/4] Fixed oversights in liquid registry, added functionality for instant checks as requested by CJ. Liquid list return is now secure. Signed-off-by: King Lemming --- .../liquids/LiquidItemRegistry.java | 126 +++++++++++++----- 1 file changed, 93 insertions(+), 33 deletions(-) diff --git a/common/net/minecraftforge/liquids/LiquidItemRegistry.java b/common/net/minecraftforge/liquids/LiquidItemRegistry.java index c5e7273a9..8d7da49e7 100644 --- a/common/net/minecraftforge/liquids/LiquidItemRegistry.java +++ b/common/net/minecraftforge/liquids/LiquidItemRegistry.java @@ -16,67 +16,127 @@ import net.minecraft.src.ItemStack; public class LiquidItemRegistry { public static final int BUCKET_VOLUME = 1000; + public static final ItemStack EMPTY_BUCKET = new ItemStack(Item.bucketEmpty); - private static Map mapItemFromLiquid = new HashMap(); - private static Map mapLiquidFromItem = new HashMap(); + private static Map mapFilledItemFromLiquid = new HashMap(); + private static Map mapLiquidFromFilledItem = new HashMap(); + private static Set setContainerValidation = new HashSet(); private static Set setLiquidValidation = new HashSet(); private static ArrayList liquids = new ArrayList(); + /** + * Default registrations + */ static { - registerLiquid( - new LiquidContainerData( - new LiquidStack(Block.waterStill, LiquidItemRegistry.BUCKET_VOLUME), - new ItemStack(Item.bucketWater), new ItemStack(Item.bucketEmpty))); - 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))); -*/ } + registerLiquid(new LiquidContainerData(new LiquidStack(Block.waterStill, LiquidItemRegistry.BUCKET_VOLUME), new LiquidStack(Block.waterMoving, + LiquidItemRegistry.BUCKET_VOLUME), new ItemStack(Item.bucketWater), new ItemStack(Item.bucketEmpty))); + registerLiquid(new LiquidContainerData(new LiquidStack(Block.lavaStill, LiquidItemRegistry.BUCKET_VOLUME), new LiquidStack(Block.lavaMoving, + LiquidItemRegistry.BUCKET_VOLUME), new ItemStack(Item.bucketLava), new ItemStack(Item.bucketEmpty))); + registerLiquid(new LiquidContainerData(new LiquidStack(Block.waterStill, LiquidItemRegistry.BUCKET_VOLUME), new LiquidStack(Block.waterMoving, + LiquidItemRegistry.BUCKET_VOLUME), new ItemStack(Item.potion), new ItemStack(Item.glassBottle))); + // registerLiquid(new LiquidContainerData(new LiquidStack(Item.bucketMilk, LiquidItemRegistry.BUCKET_VOLUME), new ItemStack(Item.bucketMilk), new + // ItemStack(Item.bucketEmpty))); + } + /** + * To register a container with a non-bucket size, the LiquidContainerData entry simply needs to use a size other than LiquidManager.BUCKET_VOLUME + */ 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); + mapFilledItemFromLiquid.put(Arrays.asList(data.container.itemID, data.container.getItemDamage(), data.stillLiquid.itemID, data.stillLiquid.itemMeta), data); + mapLiquidFromFilledItem.put(Arrays.asList(data.filled.itemID, data.filled.getItemDamage()), data); + setContainerValidation.add(Arrays.asList(data.container.itemID, data.container.getItemDamage())); setLiquidValidation.add(Arrays.asList(data.stillLiquid.itemID, data.stillLiquid.itemMeta)); liquids.add(data); } - public static LiquidStack getLiquidForFilledItem(ItemStack filledItem) { + public static LiquidStack getLiquidForFilledItem(ItemStack filledContainer) { - if (filledItem == null) { + if (filledContainer == null) { return null; } - return mapLiquidFromItem.get(Arrays.asList(filledItem.itemID, filledItem.getItemDamage())); - } - - public static ItemStack fillLiquidContainer(int liquidId, int quantity, ItemStack emptyContainer) { - - return fillLiquidContainer(new LiquidStack(liquidId, quantity, 0), emptyContainer); + LiquidContainerData ret = mapLiquidFromFilledItem.get(Arrays.asList(filledContainer.itemID, filledContainer.getItemDamage())); + if (ret != null) { + return ret.stillLiquid.copy(); + } + return null; } public static ItemStack fillLiquidContainer(LiquidStack liquid, ItemStack emptyContainer) { if (emptyContainer == null || liquid == null) { - return null; + return emptyContainer; } - return mapItemFromLiquid.get(Arrays.asList(emptyContainer.itemID, emptyContainer.getItemDamage(), liquid.itemID, liquid.itemMeta)); + LiquidContainerData ret = mapFilledItemFromLiquid.get(Arrays.asList(emptyContainer.itemID, emptyContainer.getItemDamage(), liquid.itemID, liquid.itemMeta)); + if (ret != null) { + if (liquid.amount >= ret.stillLiquid.amount) { + return ret.filled.copy(); + } + } + return emptyContainer; + } + + public static boolean containsLiquid(ItemStack filledContainer, LiquidStack liquid) { + + if (filledContainer == null || liquid == null) { + return false; + } + LiquidContainerData ret = mapLiquidFromFilledItem.get(Arrays.asList(filledContainer.itemID, filledContainer.getItemDamage())); + if (ret != null) { + return ret.stillLiquid.isLiquidEqual(liquid); + } + return false; + } + + public static boolean isBucket(ItemStack container) { + + if (container == null) { + return false; + } + + if (container.isItemEqual(EMPTY_BUCKET)) { + return true; + } + + LiquidContainerData ret = mapLiquidFromFilledItem.get(Arrays.asList(container.itemID, container.getItemDamage())); + if (ret != null) { + return ret.container.isItemEqual(EMPTY_BUCKET); + } + return false; + } + + public static boolean isContainer(ItemStack container) { + + return isEmptyContainer(container) || isFilledContainer(container); + } + + public static boolean isEmptyContainer(ItemStack emptyContainer) { + + if (emptyContainer == null) { + return false; + } + return setContainerValidation.contains(Arrays.asList(emptyContainer.itemID, emptyContainer.getItemDamage())); + } + + public static boolean isFilledContainer(ItemStack filledContainer) { + + if (filledContainer == null) { + return false; + } + return getLiquidForFilledItem(filledContainer) != null; } public static boolean isLiquid(ItemStack block) { + if (block == null) { + return false; + } return setLiquidValidation.contains(Arrays.asList(block.itemID, block.getItemDamage())); } - public static ArrayList getRegisteredLiquids() { - return liquids; + public static LiquidContainerData[] getRegisteredLiquidContainerData() { + + return liquids.toArray(new LiquidContainerData[0]); } } From 0f7811624b44bf50358516274a82d7d6f6b5a5b2 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 15 Nov 2012 06:43:16 -0500 Subject: [PATCH 4/4] Change name to LiquidContainerRegistry. Fix up missing API. This better be it now! --- .../liquids/LiquidContainerData.java | 4 ++-- ...stry.java => LiquidContainerRegistry.java} | 20 ++++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) rename common/net/minecraftforge/liquids/{LiquidItemRegistry.java => LiquidContainerRegistry.java} (82%) diff --git a/common/net/minecraftforge/liquids/LiquidContainerData.java b/common/net/minecraftforge/liquids/LiquidContainerData.java index d939cab75..643595107 100644 --- a/common/net/minecraftforge/liquids/LiquidContainerData.java +++ b/common/net/minecraftforge/liquids/LiquidContainerData.java @@ -22,12 +22,12 @@ public class LiquidContainerData { @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)); + this(new LiquidStack(stillLiquidId, LiquidContainerRegistry.BUCKET_VOLUME), new LiquidStack(movingLiquidId, LiquidContainerRegistry.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)); + this(new LiquidStack(stillLiquidId, LiquidContainerRegistry.BUCKET_VOLUME), new LiquidStack(movingLiquidId, LiquidContainerRegistry.BUCKET_VOLUME), filled, new ItemStack(Item.bucketEmpty)); } public LiquidContainerData(LiquidStack stillLiquid, ItemStack filled, ItemStack container) { diff --git a/common/net/minecraftforge/liquids/LiquidItemRegistry.java b/common/net/minecraftforge/liquids/LiquidContainerRegistry.java similarity index 82% rename from common/net/minecraftforge/liquids/LiquidItemRegistry.java rename to common/net/minecraftforge/liquids/LiquidContainerRegistry.java index 8d7da49e7..7a4e4462a 100644 --- a/common/net/minecraftforge/liquids/LiquidItemRegistry.java +++ b/common/net/minecraftforge/liquids/LiquidContainerRegistry.java @@ -13,7 +13,7 @@ import net.minecraft.src.Block; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; -public class LiquidItemRegistry { +public class LiquidContainerRegistry { public static final int BUCKET_VOLUME = 1000; public static final ItemStack EMPTY_BUCKET = new ItemStack(Item.bucketEmpty); @@ -28,14 +28,10 @@ public class LiquidItemRegistry { * Default registrations */ static { - registerLiquid(new LiquidContainerData(new LiquidStack(Block.waterStill, LiquidItemRegistry.BUCKET_VOLUME), new LiquidStack(Block.waterMoving, - LiquidItemRegistry.BUCKET_VOLUME), new ItemStack(Item.bucketWater), new ItemStack(Item.bucketEmpty))); - registerLiquid(new LiquidContainerData(new LiquidStack(Block.lavaStill, LiquidItemRegistry.BUCKET_VOLUME), new LiquidStack(Block.lavaMoving, - LiquidItemRegistry.BUCKET_VOLUME), new ItemStack(Item.bucketLava), new ItemStack(Item.bucketEmpty))); - registerLiquid(new LiquidContainerData(new LiquidStack(Block.waterStill, LiquidItemRegistry.BUCKET_VOLUME), new LiquidStack(Block.waterMoving, - LiquidItemRegistry.BUCKET_VOLUME), new ItemStack(Item.potion), new ItemStack(Item.glassBottle))); - // registerLiquid(new LiquidContainerData(new LiquidStack(Item.bucketMilk, LiquidItemRegistry.BUCKET_VOLUME), new ItemStack(Item.bucketMilk), new - // ItemStack(Item.bucketEmpty))); + registerLiquid(new LiquidContainerData(new LiquidStack(Block.waterStill, LiquidContainerRegistry.BUCKET_VOLUME), new ItemStack(Item.bucketWater), new ItemStack(Item.bucketEmpty))); + registerLiquid(new LiquidContainerData(new LiquidStack(Block.lavaStill, LiquidContainerRegistry.BUCKET_VOLUME), new ItemStack(Item.bucketLava), new ItemStack(Item.bucketEmpty))); + registerLiquid(new LiquidContainerData(new LiquidStack(Block.waterStill, LiquidContainerRegistry.BUCKET_VOLUME), new ItemStack(Item.potion), new ItemStack(Item.glassBottle))); + // registerLiquid(new LiquidContainerData(new LiquidStack(Item.bucketMilk, LiquidContainerRegistry.BUCKET_VOLUME), new ItemStack(Item.bucketMilk), new ItemStack(Item.bucketEmpty))); } /** @@ -127,12 +123,12 @@ public class LiquidItemRegistry { return getLiquidForFilledItem(filledContainer) != null; } - public static boolean isLiquid(ItemStack block) { + public static boolean isLiquid(ItemStack item) { - if (block == null) { + if (item == null) { return false; } - return setLiquidValidation.contains(Arrays.asList(block.itemID, block.getItemDamage())); + return setLiquidValidation.contains(Arrays.asList(item.itemID, item.getItemDamage())); } public static LiquidContainerData[] getRegisteredLiquidContainerData() {