diff options
author | Martin Robertz <dream-master@gmx.net> | 2021-07-30 11:54:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-30 11:54:50 +0200 |
commit | 0f7a5c79f0941195d078b1877cd876b1d73b2b33 (patch) | |
tree | 7029c33c0ffb93a1b911ae3395af424ceb7e7743 /src/main/java/gregtech/common/render/GT_IconFlipped.java | |
parent | 2bff27eca61fd5d19f64969f67442c3a55175d3e (diff) | |
parent | ea5c515f4769fa83f4eb6268f0b8048f76fbb0ac (diff) | |
download | GT5-Unofficial-0f7a5c79f0941195d078b1877cd876b1d73b2b33.tar.gz GT5-Unofficial-0f7a5c79f0941195d078b1877cd876b1d73b2b33.tar.bz2 GT5-Unofficial-0f7a5c79f0941195d078b1877cd876b1d73b2b33.zip |
Merge pull request #551 from GTNewHorizons/structurelib-integration
StructureLib integration
Diffstat (limited to 'src/main/java/gregtech/common/render/GT_IconFlipped.java')
-rw-r--r-- | src/main/java/gregtech/common/render/GT_IconFlipped.java | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/main/java/gregtech/common/render/GT_IconFlipped.java b/src/main/java/gregtech/common/render/GT_IconFlipped.java new file mode 100644 index 0000000000..c3eee2900f --- /dev/null +++ b/src/main/java/gregtech/common/render/GT_IconFlipped.java @@ -0,0 +1,80 @@ +package gregtech.common.render; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.IIcon; + +@SideOnly(Side.CLIENT) +public class GT_IconFlipped implements IIcon { + private final IIcon baseIcon; + private final boolean flipU; + private final boolean flipV; + + public GT_IconFlipped(IIcon baseIcon, boolean flipU, boolean flipV) { + this.baseIcon = baseIcon; + this.flipU = flipU; + this.flipV = flipV; + } + + /** + * Returns the width of the icon, in pixels. + */ + public int getIconWidth() { + return this.baseIcon.getIconWidth(); + } + + /** + * Returns the height of the icon, in pixels. + */ + public int getIconHeight() { + return this.baseIcon.getIconHeight(); + } + + /** + * Returns the minimum U coordinate to use when rendering with this icon. + */ + public float getMinU() { + return this.flipU ? this.baseIcon.getMaxU() : this.baseIcon.getMinU(); + } + + /** + * Returns the maximum U coordinate to use when rendering with this icon. + */ + public float getMaxU() { + return this.flipU ? this.baseIcon.getMinU() : this.baseIcon.getMaxU(); + } + + /** + * Gets a U coordinate on the icon. 0 returns uMin and 16 returns uMax. Other arguments return in-between values. + */ + public float getInterpolatedU(double p_94214_1_) { + float f = this.getMaxU() - this.getMinU(); + return this.getMinU() + f * ((float) p_94214_1_ / 16.0F); + } + + /** + * Returns the minimum V coordinate to use when rendering with this icon. + */ + public float getMinV() { + return this.flipV ? this.baseIcon.getMaxV() : this.baseIcon.getMinV(); + } + + /** + * Returns the maximum V coordinate to use when rendering with this icon. + */ + public float getMaxV() { + return this.flipV ? this.baseIcon.getMinV() : this.baseIcon.getMaxV(); + } + + /** + * Gets a V coordinate on the icon. 0 returns vMin and 16 returns vMax. Other arguments return in-between values. + */ + public float getInterpolatedV(double p_94207_1_) { + float f = this.getMaxV() - this.getMinV(); + return this.getMinV() + f * ((float) p_94207_1_ / 16.0F); + } + + public String getIconName() { + return this.baseIcon.getIconName(); + } +}
\ No newline at end of file |