From af82d23f20dba6bd5867e36f3f2bcc159d7e5a6b Mon Sep 17 00:00:00 2001 From: LAX1DUDE Date: Sat, 16 Apr 2022 01:01:40 -0700 Subject: [PATCH] Fixed texture bleeding, fixed clamping in entity shadows --- .../adapter/EaglerAdapterImpl2.java | 2 +- .../lax1dude/eaglercraft/ConfigConstants.java | 2 +- .../eaglercraft/TextureTerrainMap.java | 8 +++---- .../eaglercraft/glemu/EaglerAdapterGL30.java | 2 +- src/main/java/net/minecraft/src/EntityFX.java | 9 ++++---- .../java/net/minecraft/src/FontRenderer.java | 10 ++++----- src/main/java/net/minecraft/src/Render.java | 4 ++++ .../java/net/minecraft/src/RenderArrow.java | 21 ++++++++++--------- .../java/net/minecraft/src/RenderFish.java | 10 ++++----- .../net/minecraft/src/RenderItemFrame.java | 9 ++++---- .../java/net/minecraft/src/RenderXPOrb.java | 8 +++---- .../java/net/minecraft/src/TexturedQuad.java | 4 ++-- .../adapter/EaglerAdapterImpl2.java | 2 +- 13 files changed, 49 insertions(+), 42 deletions(-) diff --git a/src/lwjgl/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java b/src/lwjgl/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java index 7b3bab7..c477887 100644 --- a/src/lwjgl/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java +++ b/src/lwjgl/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java @@ -185,7 +185,7 @@ public class EaglerAdapterImpl2 { public static final int _wGL_SRC_COLOR = GL11.GL_SRC_COLOR; public static final int _wGL_ONE = GL11.GL_ONE; public static final int _wGL_NEAREST = GL11.GL_NEAREST; - public static final int _wGL_CLAMP = GL11.GL_REPEAT; + public static final int _wGL_CLAMP = GL12.GL_CLAMP_TO_EDGE; public static final int _wGL_TEXTURE_WRAP_S = GL11.GL_TEXTURE_WRAP_S; public static final int _wGL_TEXTURE_WRAP_T = GL11.GL_TEXTURE_WRAP_T; public static final int _wGL_TEXTURE_MAX_LEVEL = GL12.GL_TEXTURE_MAX_LEVEL; diff --git a/src/main/java/net/lax1dude/eaglercraft/ConfigConstants.java b/src/main/java/net/lax1dude/eaglercraft/ConfigConstants.java index ea75b1d..b769640 100644 --- a/src/main/java/net/lax1dude/eaglercraft/ConfigConstants.java +++ b/src/main/java/net/lax1dude/eaglercraft/ConfigConstants.java @@ -4,7 +4,7 @@ public class ConfigConstants { public static boolean profanity = false; - public static final String version = "22w15c"; + public static final String version = "22w15d"; public static final String mainMenuString = "eaglercraft " + version; public static final String forkMe = "https://github.com/LAX1DUDE/eaglercraft"; diff --git a/src/main/java/net/lax1dude/eaglercraft/TextureTerrainMap.java b/src/main/java/net/lax1dude/eaglercraft/TextureTerrainMap.java index 371158a..66f54df 100644 --- a/src/main/java/net/lax1dude/eaglercraft/TextureTerrainMap.java +++ b/src/main/java/net/lax1dude/eaglercraft/TextureTerrainMap.java @@ -54,10 +54,10 @@ public class TextureTerrainMap implements IconRegister { this.maxV = (float)(originY + 48) / (float)map.height; this.originX_center = originX + 16; this.originY_center = originY + 16; - this.minU_center = (float)originX_center / (float)map.width; - this.minV_center = (float)originY_center / (float)map.height; - this.maxU_center = (float)(originX_center + 16) / (float)map.width; - this.maxV_center = (float)(originY_center + 16) / (float)map.height; + this.minU_center = (float)(originX_center + 0.1f) / (float)map.width; + this.minV_center = (float)(originY_center + 0.1f) / (float)map.height; + this.maxU_center = (float)(originX_center + 16 - 0.1f) / (float)map.width; + this.maxV_center = (float)(originY_center + 16 - 0.1f) / (float)map.height; } @Override diff --git a/src/main/java/net/lax1dude/eaglercraft/glemu/EaglerAdapterGL30.java b/src/main/java/net/lax1dude/eaglercraft/glemu/EaglerAdapterGL30.java index fd74d7d..e769b19 100644 --- a/src/main/java/net/lax1dude/eaglercraft/glemu/EaglerAdapterGL30.java +++ b/src/main/java/net/lax1dude/eaglercraft/glemu/EaglerAdapterGL30.java @@ -681,7 +681,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { case GL_NEAREST_MIPMAP_NEAREST: pp3 = _wGL_NEAREST_MIPMAP_NEAREST; break; case GL_NEAREST: pp3 = _wGL_NEAREST; break; case GL_REPEAT: pp3 = _wGL_REPEAT; break; - case GL_CLAMP: pp3 = _wGL_REPEAT; break; + case GL_CLAMP: pp3 = _wGL_CLAMP; break; } if(selectedTex == 0 && boundTexture0 != null && pp2 == _wGL_TEXTURE_MAG_FILTER) { diff --git a/src/main/java/net/minecraft/src/EntityFX.java b/src/main/java/net/minecraft/src/EntityFX.java index 71ff452..1f17f7c 100644 --- a/src/main/java/net/minecraft/src/EntityFX.java +++ b/src/main/java/net/minecraft/src/EntityFX.java @@ -142,10 +142,11 @@ public class EntityFX extends Entity { } public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) { - float var8 = (float) this.particleTextureIndexX / 16.0F; - float var9 = var8 + 0.0624375F; - float var10 = (float) this.particleTextureIndexY / 16.0F; - float var11 = var10 + 0.0624375F; + float fix = 0.001f; + float var8 = (float) this.particleTextureIndexX / 16.0F + fix; + float var9 = var8 + 0.0624375F - fix; + float var10 = (float) this.particleTextureIndexY / 16.0F + fix; + float var11 = var10 + 0.0624375F - fix; float var12 = 0.1F * this.particleScale; if (this.particleIcon != null) { diff --git a/src/main/java/net/minecraft/src/FontRenderer.java b/src/main/java/net/minecraft/src/FontRenderer.java index 8149747..53c33f7 100644 --- a/src/main/java/net/minecraft/src/FontRenderer.java +++ b/src/main/java/net/minecraft/src/FontRenderer.java @@ -191,12 +191,12 @@ public class FontRenderer { float var3 = (float) (par1 % 16 * 8); float var4 = (float) (par1 / 16 * 8); float var5 = par2 ? 1.0F : 0.0F; - float var6 = (float) this.charWidth[par1] - 0.02F; + float var6 = (float) this.charWidth[par1] - 0.2F; Tessellator t = Tessellator.instance; - t.addVertexWithUV(this.posX + 0.02F + var5, this.posY + 0.02F, 0.0F, (var3 + 0.02F) / 128.0F, (var4 + 0.02F) / 128.0F); - t.addVertexWithUV(this.posX + 0.02F - var5, this.posY + 7.98F, 0.0F, (var3 + 0.02F) / 128.0F, (var4 + 7.98F) / 128.0F); - t.addVertexWithUV(this.posX + var6 - var5, this.posY + 7.98F, 0.0F, (var3 + var6) / 128.0F, (var4 + 7.98F) / 128.0F); - t.addVertexWithUV(this.posX + var6 + var5, this.posY + 0.02F, 0.0F, (var3 + var6) / 128.0F, (var4 + 0.02F) / 128.0F); + t.addVertexWithUV(this.posX + 0.05F + var5, this.posY + 0.05F, 0.0F, (var3 + 0.1F) / 128.0F, (var4 + 0.1F) / 128.0F); + t.addVertexWithUV(this.posX + 0.05F - var5, this.posY + 7.95F, 0.0F, (var3 + 0.1F) / 128.0F, (var4 + 7.8F) / 128.0F); + t.addVertexWithUV(this.posX + var6 - var5, this.posY + 7.95F, 0.0F, (var3 + var6) / 128.0F, (var4 + 7.8F) / 128.0F); + t.addVertexWithUV(this.posX + var6 + var5, this.posY + 0.05F, 0.0F, (var3 + var6) / 128.0F, (var4 + 0.1F) / 128.0F); return (float) this.charWidth[par1]; } diff --git a/src/main/java/net/minecraft/src/Render.java b/src/main/java/net/minecraft/src/Render.java index a47f66d..623571f 100644 --- a/src/main/java/net/minecraft/src/Render.java +++ b/src/main/java/net/minecraft/src/Render.java @@ -105,8 +105,11 @@ public abstract class Render { */ private void renderShadow(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND); + EaglerAdapter.glDisable(EaglerAdapter.GL_ALPHA_TEST); EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA); shadow.bindTexture(); + EaglerAdapter.glTexParameteri(EaglerAdapter.GL_TEXTURE_2D, EaglerAdapter.GL_TEXTURE_WRAP_S, EaglerAdapter.GL_CLAMP); + EaglerAdapter.glTexParameteri(EaglerAdapter.GL_TEXTURE_2D, EaglerAdapter.GL_TEXTURE_WRAP_T, EaglerAdapter.GL_CLAMP); World var10 = this.getWorldFromRenderManager(); EaglerAdapter.glDepthMask(false); float var11 = this.shadowSize; @@ -150,6 +153,7 @@ public abstract class Render { var30.draw(); EaglerAdapter.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND); + EaglerAdapter.glEnable(EaglerAdapter.GL_ALPHA_TEST); EaglerAdapter.glDepthMask(true); } diff --git a/src/main/java/net/minecraft/src/RenderArrow.java b/src/main/java/net/minecraft/src/RenderArrow.java index 071e47e..5126a8d 100644 --- a/src/main/java/net/minecraft/src/RenderArrow.java +++ b/src/main/java/net/minecraft/src/RenderArrow.java @@ -16,15 +16,16 @@ public class RenderArrow extends Render { EaglerAdapter.glRotatef(par1EntityArrow.prevRotationPitch + (par1EntityArrow.rotationPitch - par1EntityArrow.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F); Tessellator var10 = Tessellator.instance; byte var11 = 0; - float var12 = 0.0F; - float var13 = 0.5F; - float var14 = (float) (0 + var11 * 10) / 32.0F; - float var15 = (float) (5 + var11 * 10) / 32.0F; - float var16 = 0.0F; - float var17 = 0.15625F; - float var18 = (float) (5 + var11 * 10) / 32.0F; - float var19 = (float) (10 + var11 * 10) / 32.0F; - float var20 = 0.05625F; + float fix = 0.002f; + float var12 = 0.0F + fix; + float var13 = 0.5F - fix; + float var14 = (float) (0 + var11 * 10) / 32.0F + fix; + float var15 = (float) (5 + var11 * 10) / 32.0F - fix; + float var16 = 0.0F + fix; + float var17 = 0.15625F - fix; + float var18 = (float) (5 + var11 * 10) / 32.0F + fix; + float var19 = (float) (10 + var11 * 10) / 32.0F - fix; + float var20 = 0.05625F + fix; EaglerAdapter.glEnable(EaglerAdapter.GL_RESCALE_NORMAL); float var21 = (float) par1EntityArrow.arrowShake - par9; @@ -53,7 +54,7 @@ public class RenderArrow extends Render { for (int var23 = 0; var23 < 4; ++var23) { EaglerAdapter.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); - EaglerAdapter.glNormal3f(0.0F, 0.0F, var20); + EaglerAdapter.glNormal3f(0.0F, 0.0F, -var20); var10.startDrawingQuads(); var10.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double) var12, (double) var14); var10.addVertexWithUV(8.0D, -2.0D, 0.0D, (double) var13, (double) var14); diff --git a/src/main/java/net/minecraft/src/RenderFish.java b/src/main/java/net/minecraft/src/RenderFish.java index c6e6562..6b538c9 100644 --- a/src/main/java/net/minecraft/src/RenderFish.java +++ b/src/main/java/net/minecraft/src/RenderFish.java @@ -22,17 +22,17 @@ public class RenderFish extends Render { byte var11 = 2; tex.bindTexture(); Tessellator var12 = Tessellator.instance; - float var13 = (float) (var10 * 8 + 0) / 128.0F; - float var14 = (float) (var10 * 8 + 8) / 128.0F; - float var15 = (float) (var11 * 8 + 0) / 128.0F; - float var16 = (float) (var11 * 8 + 8) / 128.0F; + float var13 = (float) (var10 * 8 + 0 + 0.15f) / 128.0F; + float var14 = (float) (var10 * 8 + 8 - 0.15f) / 128.0F; + float var15 = (float) (var11 * 8 + 0 + 0.15f) / 128.0F; + float var16 = (float) (var11 * 8 + 8 - 0.15f) / 128.0F; float var17 = 1.0F; float var18 = 0.5F; float var19 = 0.5F; EaglerAdapter.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); EaglerAdapter.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); var12.startDrawingQuads(); - var12.setNormal(0.0F, 1.0F, 0.0F); + var12.setNormal(0.0F, -1.0F, 0.0F); var12.addVertexWithUV((double) (0.0F - var18), (double) (0.0F - var19), 0.0D, (double) var13, (double) var16); var12.addVertexWithUV((double) (var17 - var18), (double) (0.0F - var19), 0.0D, (double) var14, (double) var16); var12.addVertexWithUV((double) (var17 - var18), (double) (1.0F - var19), 0.0D, (double) var14, (double) var15); diff --git a/src/main/java/net/minecraft/src/RenderItemFrame.java b/src/main/java/net/minecraft/src/RenderItemFrame.java index a6a9606..9accb42 100644 --- a/src/main/java/net/minecraft/src/RenderItemFrame.java +++ b/src/main/java/net/minecraft/src/RenderItemFrame.java @@ -113,10 +113,11 @@ public class RenderItemFrame extends Render { EaglerAdapter.glDisable(EaglerAdapter.GL_CULL_FACE); var4.startDrawingQuads(); byte var5 = 7; - var4.addVertexWithUV((double) (0 - var5), (double) (128 + var5), 0.0D, 0.0D, 1.0D); - var4.addVertexWithUV((double) (128 + var5), (double) (128 + var5), 0.0D, 1.0D, 1.0D); - var4.addVertexWithUV((double) (128 + var5), (double) (0 - var5), 0.0D, 1.0D, 0.0D); - var4.addVertexWithUV((double) (0 - var5), (double) (0 - var5), 0.0D, 0.0D, 0.0D); + double d = 0.001d; + var4.addVertexWithUV((double) (0 - var5), (double) (128 + var5), 0.0D, 0.0D + d, 1.0D - d); + var4.addVertexWithUV((double) (128 + var5), (double) (128 + var5), 0.0D, 1.0D - d, 1.0D - d); + var4.addVertexWithUV((double) (128 + var5), (double) (0 - var5), 0.0D, 1.0D - d, 0.0D + d); + var4.addVertexWithUV((double) (0 - var5), (double) (0 - var5), 0.0D, 0.0D + d, 0.0D + d); var4.draw(); EaglerAdapter.glEnable(EaglerAdapter.GL_CULL_FACE); EaglerAdapter.glTranslatef(0.0F, 0.0F, -2.0F); diff --git a/src/main/java/net/minecraft/src/RenderXPOrb.java b/src/main/java/net/minecraft/src/RenderXPOrb.java index 3f34ff3..74c1b4d 100644 --- a/src/main/java/net/minecraft/src/RenderXPOrb.java +++ b/src/main/java/net/minecraft/src/RenderXPOrb.java @@ -23,10 +23,10 @@ public class RenderXPOrb extends Render { int var10 = par1EntityXPOrb.getTextureByXP(); tex_xporb.bindTexture(); Tessellator var11 = Tessellator.instance; - float var12 = (float) (var10 % 4 * 16 + 0) / 64.0F; - float var13 = (float) (var10 % 4 * 16 + 16) / 64.0F; - float var14 = (float) (var10 / 4 * 16 + 0) / 64.0F; - float var15 = (float) (var10 / 4 * 16 + 16) / 64.0F; + float var12 = (float) (var10 % 4 * 16 + 0 + 0.2f) / 64.0F; + float var13 = (float) (var10 % 4 * 16 + 16 - 0.2f) / 64.0F; + float var14 = (float) (var10 / 4 * 16 + 0 + 0.2f) / 64.0F; + float var15 = (float) (var10 / 4 * 16 + 16 - 0.2f) / 64.0F; float var16 = 1.0F; float var17 = 0.5F; float var18 = 0.25F; diff --git a/src/main/java/net/minecraft/src/TexturedQuad.java b/src/main/java/net/minecraft/src/TexturedQuad.java index eb04621..16856b0 100644 --- a/src/main/java/net/minecraft/src/TexturedQuad.java +++ b/src/main/java/net/minecraft/src/TexturedQuad.java @@ -16,8 +16,8 @@ public class TexturedQuad { public TexturedQuad(PositionTextureVertex[] par1ArrayOfPositionTextureVertex, Vec3 normal, int par2, int par3, int par4, int par5, float par6, float par7) { this(par1ArrayOfPositionTextureVertex); - float var8 = 0.0F / par6; - float var9 = 0.0F / par7; + float var8 = 0.2F / par6; + float var9 = 0.2F / par7; par1ArrayOfPositionTextureVertex[0] = par1ArrayOfPositionTextureVertex[0].setTexturePosition((float) par4 / par6 - var8, (float) par3 / par7 + var9); par1ArrayOfPositionTextureVertex[1] = par1ArrayOfPositionTextureVertex[1].setTexturePosition((float) par2 / par6 + var8, (float) par3 / par7 + var9); par1ArrayOfPositionTextureVertex[2] = par1ArrayOfPositionTextureVertex[2].setTexturePosition((float) par2 / par6 + var8, (float) par5 / par7 - var9); diff --git a/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java b/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java index 532b3f8..265cd8a 100644 --- a/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java @@ -411,7 +411,7 @@ public class EaglerAdapterImpl2 { public static final int _wGL_SRC_COLOR = SRC_COLOR; public static final int _wGL_ONE = ONE; public static final int _wGL_NEAREST = NEAREST; - public static final int _wGL_CLAMP = REPEAT; + public static final int _wGL_CLAMP = CLAMP_TO_EDGE; public static final int _wGL_TEXTURE_WRAP_S = TEXTURE_WRAP_S; public static final int _wGL_TEXTURE_WRAP_T = TEXTURE_WRAP_T; public static final int _wGL_REPEAT = REPEAT;