From fc976c77141e6b0fc7c3c9b512e1ac72fc162ed2 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 29 Mar 2013 12:27:09 -0400 Subject: [PATCH] Fix up liquidstack so it knows about the texture sheet for it's icon --- .../minecraftforge/liquids/LiquidStack.java | 59 ++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/common/net/minecraftforge/liquids/LiquidStack.java b/common/net/minecraftforge/liquids/LiquidStack.java index 20de276c1..124d2dcac 100644 --- a/common/net/minecraftforge/liquids/LiquidStack.java +++ b/common/net/minecraftforge/liquids/LiquidStack.java @@ -124,9 +124,46 @@ public class LiquidStack return liquidstack.itemID == 0 ? null : liquidstack; } + @SideOnly(CLIENT) + private String textureSheet = "/terrain.png"; + + /** + * Return the textureSheet used for this liquid stack's texture Icon + * Defaults to '/terrain.png' + * + * See {@link #getRenderingIcon()} for the actual icon + * + * @return The texture sheet + */ + public String getTextureSheet() + { + return textureSheet; + } + + /** + * Set the texture sheet for this icon (usually /terrain.png or /gui/items.png) + * + * See also the {@link #setRenderingIcon(Icon)} for the icon itself + * + * @param textureSheet + * @return the liquid stack + */ + public LiquidStack setTextureSheet(String textureSheet) + { + this.textureSheet = textureSheet; + return this; + } @SideOnly(CLIENT) private Icon renderingIcon; + /** + * Get the rendering icon for this liquid stack, for presentation in the world or in GUIs. + * Defaults to handling water and lava, and returns the set rendering icon otherwise. + * + * See {@link #getTextureSheet()} to get the texture sheet this icon is associated with + * + * @return The icon for rendering this liquid + */ @SideOnly(CLIENT) public Icon getRenderingIcon() { @@ -141,10 +178,20 @@ public class LiquidStack return renderingIcon; } + /** + * Set the icon for rendering this liquid + * It should be refreshed whenever textures are refreshed. + * + * See also {@link #setTextureSheet(String)} for setting the sheet this icon is associated with + * + * @param icon The icon to render + * @return The liquid stack + */ @SideOnly(CLIENT) - public void setRenderingIcon(Icon icon) + public LiquidStack setRenderingIcon(Icon icon) { this.renderingIcon = icon; + return this; } @Override @@ -158,4 +205,14 @@ public class LiquidStack { return ob instanceof LiquidStack && Objects.equal(((LiquidStack)ob).itemID, itemID) && Objects.equal(((LiquidStack)ob).itemMeta, itemMeta); } + + + /** + * Get the canonical version of this liquid stack (will contain things like icons and texturesheets) + * @return The canonical liquidstack + */ + public LiquidStack canonical() + { + return LiquidDictionary.getCanonicalLiquid(LiquidDictionary.findLiquidName(this)); + } }