diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2021-06-16 16:15:18 +0800 |
---|---|---|
committer | Glease <4586901+Glease@users.noreply.github.com> | 2021-07-30 14:39:30 +0800 |
commit | 62f04c2893a66c4f80383da1a973fad4708171d4 (patch) | |
tree | e8fc2873c0fbba04c2732882826f273f53fa8f73 /src/main/java/gregtech/common/render | |
parent | b0903281c7f2688724335a0a0684f9faeb96d9fc (diff) | |
download | GT5-Unofficial-62f04c2893a66c4f80383da1a973fad4708171d4.tar.gz GT5-Unofficial-62f04c2893a66c4f80383da1a973fad4708171d4.tar.bz2 GT5-Unofficial-62f04c2893a66c4f80383da1a973fad4708171d4.zip |
draw flipped textures & flipping markers
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/common/render')
-rw-r--r-- | src/main/java/gregtech/common/render/GT_IconFlipped.java | 80 | ||||
-rw-r--r-- | src/main/java/gregtech/common/render/GT_RenderedTexture.java | 20 |
2 files changed, 93 insertions, 7 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 diff --git a/src/main/java/gregtech/common/render/GT_RenderedTexture.java b/src/main/java/gregtech/common/render/GT_RenderedTexture.java index 135ebf28c6..e35e2dbb6b 100644 --- a/src/main/java/gregtech/common/render/GT_RenderedTexture.java +++ b/src/main/java/gregtech/common/render/GT_RenderedTexture.java @@ -2,6 +2,7 @@ package gregtech.common.render; import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; +import com.gtnewhorizon.structurelib.alignment.enumerable.Flip; import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation; import gregtech.GT_Mod; import gregtech.api.interfaces.IColorModulationContainer; @@ -12,7 +13,6 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.LightingHelper; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IconFlipped; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.init.Blocks; @@ -225,7 +225,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceYNeg(Blocks.air, x, y, z, new IconFlipped(icon, !stdOrient, false)); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceYNeg(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped() ^ !stdOrient, aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateBottom = 0; } @@ -249,7 +250,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceYPos(Blocks.air, x, y, z, icon); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceYPos(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateTop = 0; } @@ -274,7 +276,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceZNeg(Blocks.air, x, y, z, icon); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceZNeg(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateEast = 0; aRenderer.field_152631_f = false; } @@ -299,7 +302,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceZPos(Blocks.air, x, y, z, icon); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceZPos(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateWest = 0; } @@ -323,7 +327,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceXNeg(Blocks.air, x, y, z, icon); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceXNeg(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateNorth = 0; } @@ -348,7 +353,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceXPos(Blocks.air, x, y, z, icon); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceXPos(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateSouth = 0; aRenderer.field_152631_f = false; } |