-
Notifications
You must be signed in to change notification settings - Fork 86
fix(render): unflip texture on bottom face of blocks #676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3a1655e
fix(render): unflip texture on bottom face of blocks
leagris c812fed
Merge branch 'master' into fixBottomUV
leagris bcb6306
Apply requested changes from @Alexdoru
leagris c8d54fa
Publishes the UV fix to the Launch Blackboard
leagris db0bd51
fix partial block UV
leagris 26e9f4d
fix rotated partial block UV
leagris 7ce59ad
Merge branch 'master' into fixBottomUV
Dream-Master d4f68bf
Merge branch 'master' into fixBottomUV
wlhlm aa3b577
Merge branch 'master' into fixBottomUV
leagris ad42815
feat(FixesConfig): enable fixBottomFaceUV by default
leagris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
...n/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinRenderBlocks_FaceYNegUV.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| package com.mitchej123.hodgepodge.mixins.early.minecraft; | ||
|
|
||
| import net.minecraft.block.Block; | ||
| import net.minecraft.client.renderer.RenderBlocks; | ||
| import net.minecraft.client.renderer.Tessellator; | ||
| import net.minecraft.util.IIcon; | ||
|
|
||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.Overwrite; | ||
| import org.spongepowered.asm.mixin.Shadow; | ||
|
|
||
| import cpw.mods.fml.relauncher.Side; | ||
| import cpw.mods.fml.relauncher.SideOnly; | ||
|
|
||
| /** | ||
| * Patched {@link RenderBlocks} to fix {@link #renderFaceYNeg} texture UV | ||
| * <dl> | ||
| * <dt>Suppressed warnings:</dt> | ||
| * <dd>{@code ClassWithTooManyFields}: Legacy class design</dd> | ||
| * <dd>{@code UnusedMixin}: Dynamically applied at run-time</dd> | ||
| * </dl> | ||
| */ | ||
| @SuppressWarnings({ "ClassWithTooManyFields", "UnusedMixin" }) | ||
| @SideOnly(Side.CLIENT) | ||
leagris marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| @Mixin(RenderBlocks.class) | ||
leagris marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public abstract class MixinRenderBlocks_FaceYNegUV { | ||
|
|
||
| @Shadow | ||
| public IIcon overrideBlockTexture; | ||
| @Shadow | ||
| public double renderMinX, renderMaxX, renderMinZ, renderMaxZ, renderMinY; | ||
| @Shadow | ||
| public int uvRotateBottom; | ||
| @Shadow | ||
| public boolean renderFromInside; | ||
| @Shadow | ||
| public boolean enableAO; | ||
| @Shadow | ||
| public int brightnessTopLeft, brightnessTopRight, brightnessBottomLeft, brightnessBottomRight; | ||
| @Shadow | ||
| public float colorRedTopLeft, colorGreenTopLeft, colorBlueTopLeft; | ||
| @Shadow | ||
| public float colorRedTopRight, colorGreenTopRight, colorBlueTopRight; | ||
| @Shadow | ||
| public float colorRedBottomLeft, colorGreenBottomLeft, colorBlueBottomLeft; | ||
| @Shadow | ||
| public float colorRedBottomRight, colorGreenBottomRight, colorBlueBottomRight; | ||
|
|
||
| @Shadow | ||
| public abstract boolean hasOverrideBlockTexture(); | ||
|
|
||
| /** | ||
| * @author leagris | ||
| * @reason Fixes horizontal flip bug in bottom face textures prior to Minecraft 1.8. | ||
| * @link <a href="https://bugs.mojang.com/browse/MC-47811">MC-47811</a> | ||
| */ | ||
| @SuppressWarnings("OverlyComplexMethod") // Complex by nature | ||
| @Overwrite | ||
| public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) { | ||
| Tessellator tessellator = Tessellator.instance; | ||
|
|
||
| if (this.hasOverrideBlockTexture()) { | ||
| icon = this.overrideBlockTexture; | ||
| } | ||
|
|
||
| double uMinX = icon.getInterpolatedU(this.renderMaxX * 16.0D); | ||
| double uMaxX = icon.getInterpolatedU(this.renderMinX * 16.0D); | ||
| double vMinZ = icon.getInterpolatedV(this.renderMinZ * 16.0D); | ||
| double vMaxZ = icon.getInterpolatedV(this.renderMaxZ * 16.0D); | ||
|
|
||
| if (this.renderMinX < 0.0D || this.renderMaxX > 1.0D) { | ||
| uMinX = icon.getMaxU(); | ||
| uMaxX = icon.getMinU(); | ||
| } | ||
|
|
||
| if (this.renderMinZ < 0.0D || this.renderMaxZ > 1.0D) { | ||
| vMinZ = icon.getMinV(); | ||
| vMaxZ = icon.getMaxV(); | ||
| } | ||
|
|
||
| double uMaxXCopy = uMaxX; | ||
| double uMinXCopy = uMinX; | ||
| double vMinZCopy = vMinZ; | ||
| double vMaxZCopy = vMaxZ; | ||
|
|
||
| if (this.uvRotateBottom == 2) { | ||
| uMinX = icon.getInterpolatedU(this.renderMaxZ * 16.0D); | ||
| vMinZ = icon.getInterpolatedV(16.0D - this.renderMaxX * 16.0D); | ||
| uMaxX = icon.getInterpolatedU(this.renderMinZ * 16.0D); | ||
| vMaxZ = icon.getInterpolatedV(16.0D - this.renderMinX * 16.0D); | ||
| vMinZCopy = vMinZ; | ||
| vMaxZCopy = vMaxZ; | ||
| uMaxXCopy = uMinX; | ||
| uMinXCopy = uMaxX; | ||
| vMinZ = vMaxZ; | ||
| vMaxZ = vMinZCopy; | ||
| } else if (this.uvRotateBottom == 1) { | ||
| uMinX = icon.getInterpolatedU(16.0D - this.renderMinZ * 16.0D); | ||
| vMinZ = icon.getInterpolatedV(this.renderMinX * 16.0D); | ||
| uMaxX = icon.getInterpolatedU(16.0D - this.renderMaxZ * 16.0D); | ||
| vMaxZ = icon.getInterpolatedV(this.renderMaxX * 16.0D); | ||
| uMaxXCopy = uMaxX; | ||
| uMinXCopy = uMinX; | ||
| uMinX = uMaxX; | ||
| uMaxX = uMinXCopy; | ||
| vMinZCopy = vMaxZ; | ||
| vMaxZCopy = vMinZ; | ||
| } else if (this.uvRotateBottom == 3) { | ||
| uMinX = icon.getInterpolatedU(16.0D - this.renderMaxX * 16.0D); | ||
| uMaxX = icon.getInterpolatedU(16.0D - this.renderMinX * 16.0D); | ||
| vMinZ = icon.getInterpolatedV(16.0D - this.renderMinZ * 16.0D); | ||
| vMaxZ = icon.getInterpolatedV(16.0D - this.renderMaxZ * 16.0D); | ||
| uMaxXCopy = uMaxX; | ||
| uMinXCopy = uMinX; | ||
| vMinZCopy = vMinZ; | ||
| vMaxZCopy = vMaxZ; | ||
| } | ||
|
|
||
| double xMin = x + this.renderMinX; | ||
| double xMax = x + this.renderMaxX; | ||
| double yMin = y + this.renderMinY; | ||
| double zMin = z + this.renderMinZ; | ||
| double zMax = z + this.renderMaxZ; | ||
|
|
||
| if (this.renderFromInside) { | ||
| xMin = x + this.renderMaxX; | ||
| xMax = x + this.renderMinX; | ||
| } | ||
|
|
||
| if (this.enableAO) { | ||
| tessellator.setColorOpaque_F(this.colorRedTopLeft, this.colorGreenTopLeft, this.colorBlueTopLeft); | ||
| tessellator.setBrightness(this.brightnessTopLeft); | ||
| tessellator.addVertexWithUV(xMin, yMin, zMax, uMinXCopy, vMaxZCopy); | ||
| tessellator.setColorOpaque_F(this.colorRedBottomLeft, this.colorGreenBottomLeft, this.colorBlueBottomLeft); | ||
| tessellator.setBrightness(this.brightnessBottomLeft); | ||
| tessellator.addVertexWithUV(xMin, yMin, zMin, uMinX, vMinZ); | ||
| tessellator | ||
| .setColorOpaque_F(this.colorRedBottomRight, this.colorGreenBottomRight, this.colorBlueBottomRight); | ||
| tessellator.setBrightness(this.brightnessBottomRight); | ||
| tessellator.addVertexWithUV(xMax, yMin, zMin, uMaxXCopy, vMinZCopy); | ||
| tessellator.setColorOpaque_F(this.colorRedTopRight, this.colorGreenTopRight, this.colorBlueTopRight); | ||
| tessellator.setBrightness(this.brightnessTopRight); | ||
| tessellator.addVertexWithUV(xMax, yMin, zMax, uMaxX, vMaxZ); | ||
| } else { | ||
| tessellator.addVertexWithUV(xMin, yMin, zMax, uMinXCopy, vMaxZCopy); | ||
| tessellator.addVertexWithUV(xMin, yMin, zMin, uMinX, vMinZ); | ||
| tessellator.addVertexWithUV(xMax, yMin, zMin, uMaxXCopy, vMinZCopy); | ||
| tessellator.addVertexWithUV(xMax, yMin, zMax, uMaxX, vMaxZ); | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.