From 18398f87ade6f22845a77ff6d91448de3f6db0da Mon Sep 17 00:00:00 2001 From: PeytonPlayz595 <106421860+PeytonPlayz595@users.noreply.github.com> Date: Wed, 12 Jul 2023 17:47:48 -0400 Subject: [PATCH] Replaced ShapeRenderer with Tessellator --- .../java/com/mojang/minecraft/Minecraft.java | 93 +++++---- .../mojang/minecraft/ProgressBarDisplay.java | 43 ++-- .../minecraft/gui/BlockSelectScreen.java | 12 +- .../com/mojang/minecraft/gui/HUDScreen.java | 11 +- .../java/com/mojang/minecraft/gui/Screen.java | 32 +-- .../java/com/mojang/minecraft/item/Arrow.java | 39 ++-- .../com/mojang/minecraft/item/PrimedTnt.java | 8 +- .../mojang/minecraft/level/tile/Block.java | 185 +++++++++--------- .../minecraft/level/tile/FlowerBlock.java | 44 +++-- .../minecraft/level/tile/LiquidBlock.java | 7 +- .../mojang/minecraft/particle/Particle.java | 15 +- .../minecraft/particle/SmokeParticle.java | 5 +- .../minecraft/particle/TerrainParticle.java | 16 +- .../minecraft/particle/WaterDropParticle.java | 5 +- .../com/mojang/minecraft/render/Chunk.java | 11 +- .../minecraft/render/LevelRenderer.java | 73 +++---- .../mojang/minecraft/render/RenderEngine.java | 1 - .../minecraft/render/ShapeRenderer.java | 169 ---------------- .../eaglercraft/adapter/Tessellator.java | 10 +- 19 files changed, 308 insertions(+), 471 deletions(-) delete mode 100644 src/teavm/java/com/mojang/minecraft/render/ShapeRenderer.java diff --git a/src/teavm/java/com/mojang/minecraft/Minecraft.java b/src/teavm/java/com/mojang/minecraft/Minecraft.java index c5bc979..aa289bb 100644 --- a/src/teavm/java/com/mojang/minecraft/Minecraft.java +++ b/src/teavm/java/com/mojang/minecraft/Minecraft.java @@ -30,6 +30,7 @@ import com.mojang.minecraft.render.texture.TextureWaterFX; import net.PeytonPlayz585.math.MathHelper; import net.lax1dude.eaglercraft.GLAllocation; +import net.lax1dude.eaglercraft.adapter.Tessellator; import org.lwjgl.opengl.GL11; @@ -73,6 +74,7 @@ public final class Minecraft implements Runnable { public boolean hasMouse; private int lastClick; public boolean raining; + private static Tessellator tessellator = Tessellator.instance; public Minecraft() { @@ -446,7 +448,6 @@ public final class Minecraft implements Runnable { var89.sortChunks(var126, 0); int var83; int var110; - ShapeRenderer var115; int var114; int var125; int var122; @@ -465,22 +466,21 @@ public final class Minecraft implements Runnable { if((var104 = var89.level.getTile(var122, var125, var38)) != 0 && Block.blocks[var104].isSolid()) { GL11.glColor4f(0.2F, 0.2F, 0.2F, 1.0F); GL11.glDepthFunc(513); - var115 = ShapeRenderer.instance; - ShapeRenderer.instance.begin(); + tessellator.startDrawing(); for(var114 = 0; var114 < 6; ++var114) { - Block.blocks[var104].renderInside(var115, var99, var98, var105, var114); + Block.blocks[var104].renderInside(var99, var98, var105, var114); } - var115.end(); + tessellator.draw(); GL11.glCullFace(1028); - var115.begin(); + tessellator.startDrawing(); for(var114 = 0; var114 < 6; ++var114) { - Block.blocks[var104].renderInside(var115, var99, var98, var105, var114); + Block.blocks[var104].renderInside(var99, var98, var105, var114); } - var115.end(); + tessellator.draw(); GL11.glCullFace(1029); GL11.glDepthFunc(515); } @@ -512,14 +512,13 @@ public final class Minecraft implements Runnable { var110 = new TextureLocation("/terrain.png").bindTexture(); } - ShapeRenderer var121 = ShapeRenderer.instance; - ShapeRenderer.instance.begin(); + tessellator.startDrawing(); for(var120 = 0; var120 < var96.particles[var83].size(); ++var120) { - ((Particle)var96.particles[var83].get(var120)).render(var121, var107, var29, var69, var30, var117, var32); + ((Particle)var96.particles[var83].get(var120)).render(var107, var29, var69, var30, var117, var32); } - var121.end(); + tessellator.draw(); } } @@ -542,31 +541,30 @@ public final class Minecraft implements Runnable { var30 = var69; } - var115 = ShapeRenderer.instance; var74 = 0.0F; var33 = 4.8828125E-4F; var74 = (float)(var89.level.depth + 2); var34 = ((float)var89.ticks + var80) * var33 * 0.03F; var35 = 0.0F; - var115.begin(); - var115.color(var107, var29, var30); + tessellator.startDrawing(); + tessellator.setColorOpaque_F(var107, var29, var30); for(var86 = -2048; var86 < var101.level.width + 2048; var86 += 512) { for(var125 = -2048; var125 < var101.level.height + 2048; var125 += 512) { - var115.vertexUV((float)var86, var74, (float)(var125 + 512), (float)var86 * var33 + var34, (float)(var125 + 512) * var33); - var115.vertexUV((float)(var86 + 512), var74, (float)(var125 + 512), (float)(var86 + 512) * var33 + var34, (float)(var125 + 512) * var33); - var115.vertexUV((float)(var86 + 512), var74, (float)var125, (float)(var86 + 512) * var33 + var34, (float)var125 * var33); - var115.vertexUV((float)var86, var74, (float)var125, (float)var86 * var33 + var34, (float)var125 * var33); - var115.vertexUV((float)var86, var74, (float)var125, (float)var86 * var33 + var34, (float)var125 * var33); - var115.vertexUV((float)(var86 + 512), var74, (float)var125, (float)(var86 + 512) * var33 + var34, (float)var125 * var33); - var115.vertexUV((float)(var86 + 512), var74, (float)(var125 + 512), (float)(var86 + 512) * var33 + var34, (float)(var125 + 512) * var33); - var115.vertexUV((float)var86, var74, (float)(var125 + 512), (float)var86 * var33 + var34, (float)(var125 + 512) * var33); + tessellator.addVertexWithUV((float)var86, var74, (float)(var125 + 512), (float)var86 * var33 + var34, (float)(var125 + 512) * var33); + tessellator.addVertexWithUV((float)(var86 + 512), var74, (float)(var125 + 512), (float)(var86 + 512) * var33 + var34, (float)(var125 + 512) * var33); + tessellator.addVertexWithUV((float)(var86 + 512), var74, (float)var125, (float)(var86 + 512) * var33 + var34, (float)var125 * var33); + tessellator.addVertexWithUV((float)var86, var74, (float)var125, (float)var86 * var33 + var34, (float)var125 * var33); + tessellator.addVertexWithUV((float)var86, var74, (float)var125, (float)var86 * var33 + var34, (float)var125 * var33); + tessellator.addVertexWithUV((float)(var86 + 512), var74, (float)var125, (float)(var86 + 512) * var33 + var34, (float)var125 * var33); + tessellator.addVertexWithUV((float)(var86 + 512), var74, (float)(var125 + 512), (float)(var86 + 512) * var33 + var34, (float)(var125 + 512) * var33); + tessellator.addVertexWithUV((float)var86, var74, (float)(var125 + 512), (float)var86 * var33 + var34, (float)(var125 + 512) * var33); } } - var115.end(); + tessellator.draw(); GL11.glDisable(3553); - var115.begin(); + tessellator.startDrawing(); var34 = (float)(var101.level.skyColor >> 16 & 255) / 255.0F; var35 = (float)(var101.level.skyColor >> 8 & 255) / 255.0F; var87 = (float)(var101.level.skyColor & 255) / 255.0F; @@ -579,19 +577,19 @@ public final class Minecraft implements Runnable { var87 = var74; } - var115.color(var34, var35, var87); + tessellator.setColorOpaque_F(var34, var35, var87); var74 = (float)(var101.level.depth + 10); for(var125 = -2048; var125 < var101.level.width + 2048; var125 += 512) { for(var68 = -2048; var68 < var101.level.height + 2048; var68 += 512) { - var115.vertex((float)var125, var74, (float)var68); - var115.vertex((float)(var125 + 512), var74, (float)var68); - var115.vertex((float)(var125 + 512), var74, (float)(var68 + 512)); - var115.vertex((float)var125, var74, (float)(var68 + 512)); + tessellator.addVertex((float)var125, var74, (float)var68); + tessellator.addVertex((float)(var125 + 512), var74, (float)var68); + tessellator.addVertex((float)(var125 + 512), var74, (float)(var68 + 512)); + tessellator.addVertex((float)var125, var74, (float)(var68 + 512)); } } - var115.end(); + tessellator.draw(); GL11.glEnable(3553); var82.updateFog(); int var108; @@ -602,7 +600,6 @@ public final class Minecraft implements Runnable { boolean var106 = false; MovingObjectPosition var102 = var10001; var101 = var89; - ShapeRenderer var113 = ShapeRenderer.instance; GL11.glEnable(3042); GL11.glEnable(3008); GL11.glBlendFunc(770, 1); @@ -622,18 +619,18 @@ public final class Minecraft implements Runnable { var35 = 1.01F; GL11.glScalef(1.01F, var35, var35); GL11.glTranslatef(-((float)var102.x + var74), -((float)var102.y + var33), -((float)var102.z + var34)); - var113.begin(); - var113.noColor(); + tessellator.startDrawing(); + tessellator.disableColor(); GL11.glDepthMask(false); if(var73 == null) { var73 = Block.STONE; } for(var86 = 0; var86 < 6; ++var86) { - var73.renderSide(var113, var102.x, var102.y, var102.z, var86, 240 + (int)(var101.cracks * 10.0F)); + var73.renderSide(var102.x, var102.y, var102.z, var86, 240 + (int)(var101.cracks * 10.0F)); } - var113.end(); + tessellator.draw(); GL11.glDepthMask(true); GL11.glPopMatrix(); } @@ -692,7 +689,6 @@ public final class Minecraft implements Runnable { var104 = (int)var28.x; var108 = (int)var28.y; var114 = (int)var28.z; - ShapeRenderer var84 = ShapeRenderer.instance; GL11.glDisable(2884); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glEnable(3042); @@ -718,16 +714,16 @@ public final class Minecraft implements Runnable { var35 = (float)var122 + 0.5F - var28.z; float var92 = MathHelper.sqrt(var124 * var124 + var35 * var35) / (float)5; GL11.glColor4f(1.0F, 1.0F, 1.0F, (1.0F - var92 * var92) * 0.7F); - var84.begin(); - var84.vertexUV((float)var110, (float)var86, (float)var122, 0.0F, (float)var86 * 2.0F / 8.0F + var74 * 2.0F); - var84.vertexUV((float)(var110 + 1), (float)var86, (float)(var122 + 1), 2.0F, (float)var86 * 2.0F / 8.0F + var74 * 2.0F); - var84.vertexUV((float)(var110 + 1), (float)var125, (float)(var122 + 1), 2.0F, (float)var125 * 2.0F / 8.0F + var74 * 2.0F); - var84.vertexUV((float)var110, (float)var125, (float)var122, 0.0F, (float)var125 * 2.0F / 8.0F + var74 * 2.0F); - var84.vertexUV((float)var110, (float)var86, (float)(var122 + 1), 0.0F, (float)var86 * 2.0F / 8.0F + var74 * 2.0F); - var84.vertexUV((float)(var110 + 1), (float)var86, (float)var122, 2.0F, (float)var86 * 2.0F / 8.0F + var74 * 2.0F); - var84.vertexUV((float)(var110 + 1), (float)var125, (float)var122, 2.0F, (float)var125 * 2.0F / 8.0F + var74 * 2.0F); - var84.vertexUV((float)var110, (float)var125, (float)(var122 + 1), 0.0F, (float)var125 * 2.0F / 8.0F + var74 * 2.0F); - var84.end(); + tessellator.startDrawing(); + tessellator.addVertexWithUV((float)var110, (float)var86, (float)var122, 0.0F, (float)var86 * 2.0F / 8.0F + var74 * 2.0F); + tessellator.addVertexWithUV((float)(var110 + 1), (float)var86, (float)(var122 + 1), 2.0F, (float)var86 * 2.0F / 8.0F + var74 * 2.0F); + tessellator.addVertexWithUV((float)(var110 + 1), (float)var125, (float)(var122 + 1), 2.0F, (float)var125 * 2.0F / 8.0F + var74 * 2.0F); + tessellator.addVertexWithUV((float)var110, (float)var125, (float)var122, 0.0F, (float)var125 * 2.0F / 8.0F + var74 * 2.0F); + tessellator.addVertexWithUV((float)var110, (float)var86, (float)(var122 + 1), 0.0F, (float)var86 * 2.0F / 8.0F + var74 * 2.0F); + tessellator.addVertexWithUV((float)(var110 + 1), (float)var86, (float)var122, 2.0F, (float)var86 * 2.0F / 8.0F + var74 * 2.0F); + tessellator.addVertexWithUV((float)(var110 + 1), (float)var125, (float)var122, 2.0F, (float)var125 * 2.0F / 8.0F + var74 * 2.0F); + tessellator.addVertexWithUV((float)var110, (float)var125, (float)(var122 + 1), 0.0F, (float)var125 * 2.0F / 8.0F + var74 * 2.0F); + tessellator.draw(); } } } @@ -776,13 +772,12 @@ public final class Minecraft implements Runnable { } GL11.glColor4f(var74 = var112.minecraft.level.getBrightness((int)var116.x, (int)var116.y, (int)var116.z), var74, var74, 1.0F); - ShapeRenderer var123 = ShapeRenderer.instance; if(var112.block != null) { var34 = 0.4F; GL11.glScalef(0.4F, var34, var34); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); new TextureLocation("/terrain.png").bindTexture(); - var112.block.renderPreview(var123); + var112.block.renderPreview(); } else { var116.bindTexture(); GL11.glScalef(1.0F, -1.0F, -1.0F); diff --git a/src/teavm/java/com/mojang/minecraft/ProgressBarDisplay.java b/src/teavm/java/com/mojang/minecraft/ProgressBarDisplay.java index 18b00da..8944401 100644 --- a/src/teavm/java/com/mojang/minecraft/ProgressBarDisplay.java +++ b/src/teavm/java/com/mojang/minecraft/ProgressBarDisplay.java @@ -2,9 +2,10 @@ package com.mojang.minecraft; import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.StopGameException; -import com.mojang.minecraft.render.ShapeRenderer; import com.mojang.minecraft.render.TextureLocation; +import net.lax1dude.eaglercraft.adapter.Tessellator; + import org.lwjgl.opengl.GL11; public final class ProgressBarDisplay { @@ -55,32 +56,32 @@ public final class ProgressBarDisplay { int var4 = this.minecraft.width * 240 / this.minecraft.height; int var5 = this.minecraft.height * 240 / this.minecraft.height; GL11.glClear(16640); - ShapeRenderer var6 = ShapeRenderer.instance; + Tessellator tessellator = Tessellator.instance; int var7 = new TextureLocation("/dirt.png").bindTexture(); float var10 = 32.0F; - var6.begin(); - var6.color(4210752); - var6.vertexUV(0.0F, (float)var5, 0.0F, 0.0F, (float)var5 / var10); - var6.vertexUV((float)var4, (float)var5, 0.0F, (float)var4 / var10, (float)var5 / var10); - var6.vertexUV((float)var4, 0.0F, 0.0F, (float)var4 / var10, 0.0F); - var6.vertexUV(0.0F, 0.0F, 0.0F, 0.0F, 0.0F); - var6.end(); + tessellator.startDrawing(); + tessellator.setColorOpaque_I(4210752); + tessellator.addVertexWithUV(0.0F, (float)var5, 0.0F, 0.0F, (float)var5 / var10); + tessellator.addVertexWithUV((float)var4, (float)var5, 0.0F, (float)var4 / var10, (float)var5 / var10); + tessellator.addVertexWithUV((float)var4, 0.0F, 0.0F, (float)var4 / var10, 0.0F); + tessellator.addVertexWithUV(0.0F, 0.0F, 0.0F, 0.0F, 0.0F); + tessellator.draw(); if(var1 >= 0) { var7 = var4 / 2 - 50; int var8 = var5 / 2 + 16; GL11.glDisable(3553); - var6.begin(); - var6.color(8421504); - var6.vertex((float)var7, (float)var8, 0.0F); - var6.vertex((float)var7, (float)(var8 + 2), 0.0F); - var6.vertex((float)(var7 + 100), (float)(var8 + 2), 0.0F); - var6.vertex((float)(var7 + 100), (float)var8, 0.0F); - var6.color(8454016); - var6.vertex((float)var7, (float)var8, 0.0F); - var6.vertex((float)var7, (float)(var8 + 2), 0.0F); - var6.vertex((float)(var7 + var1), (float)(var8 + 2), 0.0F); - var6.vertex((float)(var7 + var1), (float)var8, 0.0F); - var6.end(); + tessellator.startDrawing(); + tessellator.setColorOpaque_I(8421504); + tessellator.addVertex((float)var7, (float)var8, 0.0F); + tessellator.addVertex((float)var7, (float)(var8 + 2), 0.0F); + tessellator.addVertex((float)(var7 + 100), (float)(var8 + 2), 0.0F); + tessellator.addVertex((float)(var7 + 100), (float)var8, 0.0F); + tessellator.setColorOpaque_I(8454016); + tessellator.addVertex((float)var7, (float)var8, 0.0F); + tessellator.addVertex((float)var7, (float)(var8 + 2), 0.0F); + tessellator.addVertex((float)(var7 + var1), (float)(var8 + 2), 0.0F); + tessellator.addVertex((float)(var7 + var1), (float)var8, 0.0F); + tessellator.draw(); GL11.glEnable(3553); } diff --git a/src/teavm/java/com/mojang/minecraft/gui/BlockSelectScreen.java b/src/teavm/java/com/mojang/minecraft/gui/BlockSelectScreen.java index 2a2fc3e..73c1ed3 100644 --- a/src/teavm/java/com/mojang/minecraft/gui/BlockSelectScreen.java +++ b/src/teavm/java/com/mojang/minecraft/gui/BlockSelectScreen.java @@ -3,8 +3,10 @@ package com.mojang.minecraft.gui; import com.mojang.minecraft.SessionData; import com.mojang.minecraft.gui.GuiScreen; import com.mojang.minecraft.level.tile.Block; -import com.mojang.minecraft.render.ShapeRenderer; import com.mojang.minecraft.render.TextureLocation; + +import net.lax1dude.eaglercraft.adapter.Tessellator; + import org.lwjgl.opengl.GL11; public final class BlockSelectScreen extends GuiScreen { @@ -35,7 +37,7 @@ public final class BlockSelectScreen extends GuiScreen { } drawCenteredString(this.fontRenderer, "Select block", this.width / 2, 40, 16777215); - ShapeRenderer var8 = ShapeRenderer.instance; + Tessellator tessellator = Tessellator.instance; var2 = new TextureLocation("/terrain.png").bindTexture(); GL11.glBindTexture(3553, var2); @@ -55,9 +57,9 @@ public final class BlockSelectScreen extends GuiScreen { GL11.glTranslatef(-1.5F, 0.5F, 0.5F); GL11.glScalef(-1.0F, -1.0F, -1.0F); - var8.begin(); - var4.renderFullbright(var8); - var8.end(); + tessellator.startDrawing(); + var4.renderFullbright(); + tessellator.draw(); GL11.glPopMatrix(); } diff --git a/src/teavm/java/com/mojang/minecraft/gui/HUDScreen.java b/src/teavm/java/com/mojang/minecraft/gui/HUDScreen.java index c54b261..0a9b9bb 100644 --- a/src/teavm/java/com/mojang/minecraft/gui/HUDScreen.java +++ b/src/teavm/java/com/mojang/minecraft/gui/HUDScreen.java @@ -5,9 +5,10 @@ import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.gamemode.SurvivalGameMode; import com.mojang.minecraft.level.tile.Block; import com.mojang.minecraft.player.Inventory; -import com.mojang.minecraft.render.ShapeRenderer; import com.mojang.minecraft.render.TextureLocation; import net.PeytonPlayz585.math.MathHelper; +import net.lax1dude.eaglercraft.adapter.Tessellator; + import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -34,7 +35,7 @@ public final class HUDScreen extends Screen { FontRenderer var5 = this.mc.fontRenderer; this.mc.renderer.enableGuiMode(); new TextureLocation("/gui/gui.png").bindTexture(); - ShapeRenderer var7 = ShapeRenderer.instance; + Tessellator tessellator = Tessellator.instance; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(3042); Inventory var8 = this.mc.player.inventory; @@ -128,9 +129,9 @@ public final class HUDScreen extends Screen { GL11.glTranslatef(-1.5F, 0.5F, 0.5F); GL11.glScalef(-1.0F, -1.0F, -1.0F); new TextureLocation("/terrain.png").bindTexture(); - var7.begin(); - Block.blocks[var15].renderFullbright(var7); - var7.end(); + tessellator.startDrawing(); + Block.blocks[var15].renderFullbright(); + tessellator.draw(); GL11.glPopMatrix(); if(var8.count[var12] > 1) { var23 = "" + var8.count[var12]; diff --git a/src/teavm/java/com/mojang/minecraft/gui/Screen.java b/src/teavm/java/com/mojang/minecraft/gui/Screen.java index 743cdfc..8019a41 100644 --- a/src/teavm/java/com/mojang/minecraft/gui/Screen.java +++ b/src/teavm/java/com/mojang/minecraft/gui/Screen.java @@ -1,7 +1,9 @@ package com.mojang.minecraft.gui; import com.mojang.minecraft.gui.FontRenderer; -import com.mojang.minecraft.render.ShapeRenderer; + +import net.lax1dude.eaglercraft.adapter.Tessellator; + import org.lwjgl.opengl.GL11; public class Screen { @@ -14,17 +16,17 @@ public class Screen { float var6 = (float)(var4 >> 16 & 255) / 255.0F; float var7 = (float)(var4 >> 8 & 255) / 255.0F; float var9 = (float)(var4 & 255) / 255.0F; - ShapeRenderer var8 = ShapeRenderer.instance; + Tessellator tessellator = Tessellator.instance; GL11.glEnable(3042); GL11.glDisable(3553); GL11.glBlendFunc(770, 771); GL11.glColor4f(var6, var7, var9, var5); - var8.begin(); - var8.vertex((float)var0, (float)var3, 0.0F); - var8.vertex((float)var2, (float)var3, 0.0F); - var8.vertex((float)var2, (float)var1, 0.0F); - var8.vertex((float)var0, (float)var1, 0.0F); - var8.end(); + tessellator.startDrawing(); + tessellator.addVertex((float)var0, (float)var3, 0.0F); + tessellator.addVertex((float)var2, (float)var3, 0.0F); + tessellator.addVertex((float)var2, (float)var1, 0.0F); + tessellator.addVertex((float)var0, (float)var1, 0.0F); + tessellator.draw(); GL11.glEnable(3553); GL11.glDisable(3042); } @@ -66,12 +68,12 @@ public class Screen { public final void drawImage(int var1, int var2, int var3, int var4, int var5, int var6) { float var7 = 0.00390625F; float var8 = 0.00390625F; - ShapeRenderer var9 = ShapeRenderer.instance; - ShapeRenderer.instance.begin(); - var9.vertexUV((float)var1, (float)(var2 + var6), this.imgZ, (float)var3 * var7, (float)(var4 + var6) * var8); - var9.vertexUV((float)(var1 + var5), (float)(var2 + var6), this.imgZ, (float)(var3 + var5) * var7, (float)(var4 + var6) * var8); - var9.vertexUV((float)(var1 + var5), (float)var2, this.imgZ, (float)(var3 + var5) * var7, (float)var4 * var8); - var9.vertexUV((float)var1, (float)var2, this.imgZ, (float)var3 * var7, (float)var4 * var8); - var9.end(); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawing(); + tessellator.addVertexWithUV((float)var1, (float)(var2 + var6), this.imgZ, (float)var3 * var7, (float)(var4 + var6) * var8); + tessellator.addVertexWithUV((float)(var1 + var5), (float)(var2 + var6), this.imgZ, (float)(var3 + var5) * var7, (float)(var4 + var6) * var8); + tessellator.addVertexWithUV((float)(var1 + var5), (float)var2, this.imgZ, (float)(var3 + var5) * var7, (float)var4 * var8); + tessellator.addVertexWithUV((float)var1, (float)var2, this.imgZ, (float)var3 * var7, (float)var4 * var8); + tessellator.draw(); } } diff --git a/src/teavm/java/com/mojang/minecraft/item/Arrow.java b/src/teavm/java/com/mojang/minecraft/item/Arrow.java index 802bd1d..68ac807 100644 --- a/src/teavm/java/com/mojang/minecraft/item/Arrow.java +++ b/src/teavm/java/com/mojang/minecraft/item/Arrow.java @@ -4,9 +4,10 @@ import com.mojang.minecraft.Entity; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.phys.AABB; import com.mojang.minecraft.player.Player; -import com.mojang.minecraft.render.ShapeRenderer; import com.mojang.minecraft.render.TextureLocation; import net.PeytonPlayz585.math.MathHelper; +import net.lax1dude.eaglercraft.adapter.Tessellator; + import java.util.List; import org.lwjgl.opengl.GL11; @@ -189,7 +190,7 @@ public class Arrow extends Entity GL11.glRotatef(xRotO + (xRot - xRotO) * unknown0, 0.0F, 0.0F, 1.0F); GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F); - ShapeRenderer shapeRenderer = ShapeRenderer.instance; + Tessellator tessellator = Tessellator.instance; unknown0 = 0.5F; @@ -205,21 +206,21 @@ public class Arrow extends Entity GL11.glNormal3f(unknown6, 0.0F, 0.0F); - shapeRenderer.begin(); - shapeRenderer.vertexUV(-7.0F, -2.0F, -2.0F, 0.0F, unknown4); - shapeRenderer.vertexUV(-7.0F, -2.0F, 2.0F, unknown3, unknown4); - shapeRenderer.vertexUV(-7.0F, 2.0F, 2.0F, unknown3, unknown5); - shapeRenderer.vertexUV(-7.0F, 2.0F, -2.0F, 0.0F, unknown5); - shapeRenderer.end(); + tessellator.startDrawing(); + tessellator.addVertexWithUV(-7.0F, -2.0F, -2.0F, 0.0F, unknown4); + tessellator.addVertexWithUV(-7.0F, -2.0F, 2.0F, unknown3, unknown4); + tessellator.addVertexWithUV(-7.0F, 2.0F, 2.0F, unknown3, unknown5); + tessellator.addVertexWithUV(-7.0F, 2.0F, -2.0F, 0.0F, unknown5); + tessellator.draw(); GL11.glNormal3f(-unknown6, 0.0F, 0.0F); - shapeRenderer.begin(); - shapeRenderer.vertexUV(-7.0F, 2.0F, -2.0F, 0.0F, unknown4); - shapeRenderer.vertexUV(-7.0F, 2.0F, 2.0F, unknown3, unknown4); - shapeRenderer.vertexUV(-7.0F, -2.0F, 2.0F, unknown3, unknown5); - shapeRenderer.vertexUV(-7.0F, -2.0F, -2.0F, 0.0F, unknown5); - shapeRenderer.end(); + tessellator.startDrawing(); + tessellator.addVertexWithUV(-7.0F, 2.0F, -2.0F, 0.0F, unknown4); + tessellator.addVertexWithUV(-7.0F, 2.0F, 2.0F, unknown3, unknown4); + tessellator.addVertexWithUV(-7.0F, -2.0F, 2.0F, unknown3, unknown5); + tessellator.addVertexWithUV(-7.0F, -2.0F, -2.0F, 0.0F, unknown5); + tessellator.draw(); for(int unknown7 = 0; unknown7 < 4; unknown7++) { @@ -227,11 +228,11 @@ public class Arrow extends Entity GL11.glNormal3f(0.0F, -unknown6, 0.0F); - shapeRenderer.vertexUV(-8.0F, -2.0F, 0.0F, 0.0F, unknown1); - shapeRenderer.vertexUV(8.0F, -2.0F, 0.0F, unknown0, unknown1); - shapeRenderer.vertexUV(8.0F, 2.0F, 0.0F, unknown0, unknown2); - shapeRenderer.vertexUV(-8.0F, 2.0F, 0.0F, 0.0F, unknown2); - shapeRenderer.end(); + tessellator.addVertexWithUV(-8.0F, -2.0F, 0.0F, 0.0F, unknown1); + tessellator.addVertexWithUV(8.0F, -2.0F, 0.0F, unknown0, unknown1); + tessellator.addVertexWithUV(8.0F, 2.0F, 0.0F, unknown0, unknown2); + tessellator.addVertexWithUV(-8.0F, 2.0F, 0.0F, 0.0F, unknown2); + tessellator.draw(); } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); diff --git a/src/teavm/java/com/mojang/minecraft/item/PrimedTnt.java b/src/teavm/java/com/mojang/minecraft/item/PrimedTnt.java index 8bf77d0..a8b9e14 100644 --- a/src/teavm/java/com/mojang/minecraft/item/PrimedTnt.java +++ b/src/teavm/java/com/mojang/minecraft/item/PrimedTnt.java @@ -6,9 +6,9 @@ import com.mojang.minecraft.level.tile.Block; import com.mojang.minecraft.particle.SmokeParticle; import com.mojang.minecraft.particle.TerrainParticle; import com.mojang.minecraft.player.Player; -import com.mojang.minecraft.render.ShapeRenderer; import com.mojang.minecraft.render.TextureLocation; import net.PeytonPlayz585.math.MathHelper; + import java.util.Random; import org.lwjgl.opengl.GL11; @@ -108,9 +108,7 @@ public class PrimedTnt extends Entity GL11.glTranslatef(xo + (x - xo) * unknown0 - 0.5F, yo + (y - yo) * unknown0 - 0.5F, zo + (z - zo) * unknown0 - 0.5F); GL11.glPushMatrix(); - ShapeRenderer shapeRenderer = ShapeRenderer.instance; - - Block.TNT.renderPreview(shapeRenderer); + Block.TNT.renderPreview(); GL11.glDisable(3553); GL11.glDisable(2896); @@ -129,7 +127,7 @@ public class PrimedTnt extends Entity GL11.glEnable(3042); GL11.glBlendFunc(770, 1); - Block.TNT.renderPreview(shapeRenderer); + Block.TNT.renderPreview(); GL11.glDisable(3042); GL11.glEnable(3553); diff --git a/src/teavm/java/com/mojang/minecraft/level/tile/Block.java b/src/teavm/java/com/mojang/minecraft/level/tile/Block.java index e3219b0..9d7f2fd 100644 --- a/src/teavm/java/com/mojang/minecraft/level/tile/Block.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/Block.java @@ -8,7 +8,9 @@ import com.mojang.minecraft.model.Vec3D; import com.mojang.minecraft.particle.ParticleManager; import com.mojang.minecraft.particle.TerrainParticle; import com.mojang.minecraft.phys.AABB; -import com.mojang.minecraft.render.ShapeRenderer; + +import net.lax1dude.eaglercraft.adapter.Tessellator; + import java.util.Random; public class Block @@ -136,29 +138,30 @@ public class Block this.tickDelay[id] = tickDelay; } - public void renderFullbright(ShapeRenderer shapeRenderer) + public void renderFullbright() { + Tessellator tessellator = Tessellator.instance; float red = 0.5F; float green = 0.8F; float blue = 0.6F; - shapeRenderer.color(red, red, red); - renderInside(shapeRenderer, -2, 0, 0, 0); + tessellator.setColorOpaque_F(red, red, red); + renderInside(-2, 0, 0, 0); - shapeRenderer.color(1.0F, 1.0F, 1.0F); - renderInside(shapeRenderer, -2, 0, 0, 1); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + renderInside(-2, 0, 0, 1); - shapeRenderer.color(green, green, green); - renderInside(shapeRenderer, -2, 0, 0, 2); + tessellator.setColorOpaque_F(green, green, green); + renderInside(-2, 0, 0, 2); - shapeRenderer.color(green, green, green); - renderInside(shapeRenderer, -2, 0, 0, 3); + tessellator.setColorOpaque_F(green, green, green); + renderInside(-2, 0, 0, 3); - shapeRenderer.color(blue, blue, blue); - renderInside(shapeRenderer, -2, 0, 0, 4); + tessellator.setColorOpaque_F(blue, blue, blue); + renderInside(-2, 0, 0, 4); - shapeRenderer.color(blue, blue, blue); - renderInside(shapeRenderer, -2, 0, 0, 5); + tessellator.setColorOpaque_F(blue, blue, blue); + renderInside(-2, 0, 0, 5); } protected float getBrightness(Level level, int x, int y, int z) @@ -176,16 +179,17 @@ public class Block return textureId; } - public void renderInside(ShapeRenderer shapeRenderer, int x, int y, int z, int side) + public void renderInside(int x, int y, int z, int side) { int textureID1 = getTextureId(side); - renderSide(shapeRenderer, x, y, z, side, textureID1); + renderSide(x, y, z, side, textureID1); } // TODO. - public void renderSide(ShapeRenderer shapeRenderer, int x, int y, int z, int side, int textureID) + public void renderSide(int x, int y, int z, int side, int textureID) { + Tessellator tessellator = Tessellator.instance; int var7 = textureID % 16 << 4; int var8 = textureID / 16 << 4; float var9 = (float)var7 / 256.0F; @@ -209,40 +213,41 @@ public class Block float var12 = (float)z + this.z1; float var13 = (float)z + this.z2; if(side == 0) { - shapeRenderer.vertexUV(var16, var18, var13, var9, var11); - shapeRenderer.vertexUV(var16, var18, var12, var9, var10); - shapeRenderer.vertexUV(var14, var18, var12, var17, var10); - shapeRenderer.vertexUV(var14, var18, var13, var17, var11); + tessellator.addVertexWithUV(var16, var18, var13, var9, var11); + tessellator.addVertexWithUV(var16, var18, var12, var9, var10); + tessellator.addVertexWithUV(var14, var18, var12, var17, var10); + tessellator.addVertexWithUV(var14, var18, var13, var17, var11); } else if(side == 1) { - shapeRenderer.vertexUV(var14, var15, var13, var17, var11); - shapeRenderer.vertexUV(var14, var15, var12, var17, var10); - shapeRenderer.vertexUV(var16, var15, var12, var9, var10); - shapeRenderer.vertexUV(var16, var15, var13, var9, var11); + tessellator.addVertexWithUV(var14, var15, var13, var17, var11); + tessellator.addVertexWithUV(var14, var15, var12, var17, var10); + tessellator.addVertexWithUV(var16, var15, var12, var9, var10); + tessellator.addVertexWithUV(var16, var15, var13, var9, var11); } else if(side == 2) { - shapeRenderer.vertexUV(var16, var15, var12, var17, var10); - shapeRenderer.vertexUV(var14, var15, var12, var9, var10); - shapeRenderer.vertexUV(var14, var18, var12, var9, var11); - shapeRenderer.vertexUV(var16, var18, var12, var17, var11); + tessellator.addVertexWithUV(var16, var15, var12, var17, var10); + tessellator.addVertexWithUV(var14, var15, var12, var9, var10); + tessellator.addVertexWithUV(var14, var18, var12, var9, var11); + tessellator.addVertexWithUV(var16, var18, var12, var17, var11); } else if(side == 3) { - shapeRenderer.vertexUV(var16, var15, var13, var9, var10); - shapeRenderer.vertexUV(var16, var18, var13, var9, var11); - shapeRenderer.vertexUV(var14, var18, var13, var17, var11); - shapeRenderer.vertexUV(var14, var15, var13, var17, var10); + tessellator.addVertexWithUV(var16, var15, var13, var9, var10); + tessellator.addVertexWithUV(var16, var18, var13, var9, var11); + tessellator.addVertexWithUV(var14, var18, var13, var17, var11); + tessellator.addVertexWithUV(var14, var15, var13, var17, var10); } else if(side == 4) { - shapeRenderer.vertexUV(var16, var15, var13, var17, var10); - shapeRenderer.vertexUV(var16, var15, var12, var9, var10); - shapeRenderer.vertexUV(var16, var18, var12, var9, var11); - shapeRenderer.vertexUV(var16, var18, var13, var17, var11); + tessellator.addVertexWithUV(var16, var15, var13, var17, var10); + tessellator.addVertexWithUV(var16, var15, var12, var9, var10); + tessellator.addVertexWithUV(var16, var18, var12, var9, var11); + tessellator.addVertexWithUV(var16, var18, var13, var17, var11); } else if(side == 5) { - shapeRenderer.vertexUV(var14, var18, var13, var9, var11); - shapeRenderer.vertexUV(var14, var18, var12, var17, var11); - shapeRenderer.vertexUV(var14, var15, var12, var17, var10); - shapeRenderer.vertexUV(var14, var15, var13, var9, var10); + tessellator.addVertexWithUV(var14, var18, var13, var9, var11); + tessellator.addVertexWithUV(var14, var18, var12, var17, var11); + tessellator.addVertexWithUV(var14, var15, var12, var17, var10); + tessellator.addVertexWithUV(var14, var15, var13, var9, var10); } } // TODO. - public final void renderSide(ShapeRenderer var1, int var2, int var3, int var4, int var5) { + public final void renderSide(int var2, int var3, int var4, int var5) { + Tessellator tessellator = Tessellator.instance; int var6; float var7; float var8 = (var7 = (float)((var6 = this.getTextureId(var5)) % 16) / 16.0F) + 0.0624375F; @@ -255,45 +260,45 @@ public class Block float var12 = (float)var4 + this.z1; float var13 = (float)var4 + this.z2; if(var5 == 0) { - var1.vertexUV(var14, var11, var13, var8, var9); - var1.vertexUV(var14, var11, var12, var8, var16); - var1.vertexUV(var10, var11, var12, var7, var16); - var1.vertexUV(var10, var11, var13, var7, var9); + tessellator.addVertexWithUV(var14, var11, var13, var8, var9); + tessellator.addVertexWithUV(var14, var11, var12, var8, var16); + tessellator.addVertexWithUV(var10, var11, var12, var7, var16); + tessellator.addVertexWithUV(var10, var11, var13, var7, var9); } if(var5 == 1) { - var1.vertexUV(var10, var15, var13, var7, var9); - var1.vertexUV(var10, var15, var12, var7, var16); - var1.vertexUV(var14, var15, var12, var8, var16); - var1.vertexUV(var14, var15, var13, var8, var9); + tessellator.addVertexWithUV(var10, var15, var13, var7, var9); + tessellator.addVertexWithUV(var10, var15, var12, var7, var16); + tessellator.addVertexWithUV(var14, var15, var12, var8, var16); + tessellator.addVertexWithUV(var14, var15, var13, var8, var9); } if(var5 == 2) { - var1.vertexUV(var10, var11, var12, var8, var9); - var1.vertexUV(var14, var11, var12, var7, var9); - var1.vertexUV(var14, var15, var12, var7, var16); - var1.vertexUV(var10, var15, var12, var8, var16); + tessellator.addVertexWithUV(var10, var11, var12, var8, var9); + tessellator.addVertexWithUV(var14, var11, var12, var7, var9); + tessellator.addVertexWithUV(var14, var15, var12, var7, var16); + tessellator.addVertexWithUV(var10, var15, var12, var8, var16); } if(var5 == 3) { - var1.vertexUV(var14, var15, var13, var8, var16); - var1.vertexUV(var14, var11, var13, var8, var9); - var1.vertexUV(var10, var11, var13, var7, var9); - var1.vertexUV(var10, var15, var13, var7, var16); + tessellator.addVertexWithUV(var14, var15, var13, var8, var16); + tessellator.addVertexWithUV(var14, var11, var13, var8, var9); + tessellator.addVertexWithUV(var10, var11, var13, var7, var9); + tessellator.addVertexWithUV(var10, var15, var13, var7, var16); } if(var5 == 4) { - var1.vertexUV(var10, var11, var13, var8, var9); - var1.vertexUV(var10, var11, var12, var7, var9); - var1.vertexUV(var10, var15, var12, var7, var16); - var1.vertexUV(var10, var15, var13, var8, var16); + tessellator.addVertexWithUV(var10, var11, var13, var8, var9); + tessellator.addVertexWithUV(var10, var11, var12, var7, var9); + tessellator.addVertexWithUV(var10, var15, var12, var7, var16); + tessellator.addVertexWithUV(var10, var15, var13, var8, var16); } if(var5 == 5) { - var1.vertexUV(var14, var15, var13, var7, var16); - var1.vertexUV(var14, var15, var12, var8, var16); - var1.vertexUV(var14, var11, var12, var8, var9); - var1.vertexUV(var14, var11, var13, var7, var9); + tessellator.addVertexWithUV(var14, var15, var13, var7, var16); + tessellator.addVertexWithUV(var14, var15, var12, var8, var16); + tessellator.addVertexWithUV(var14, var11, var12, var8, var9); + tessellator.addVertexWithUV(var14, var11, var13, var7, var9); } } @@ -439,38 +444,39 @@ public class Block } } - public void renderPreview(ShapeRenderer var1) { - var1.begin(); + public void renderPreview() { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawing(); for(int var2 = 0; var2 < 6; ++var2) { if(var2 == 0) { - var1.normal(0.0F, 1.0F, 0.0F); + tessellator.setNormal(0.0F, 1.0F, 0.0F); } if(var2 == 1) { - var1.normal(0.0F, -1.0F, 0.0F); + tessellator.setNormal(0.0F, -1.0F, 0.0F); } if(var2 == 2) { - var1.normal(0.0F, 0.0F, 1.0F); + tessellator.setNormal(0.0F, 0.0F, 1.0F); } if(var2 == 3) { - var1.normal(0.0F, 0.0F, -1.0F); + tessellator.setNormal(0.0F, 0.0F, -1.0F); } if(var2 == 4) { - var1.normal(1.0F, 0.0F, 0.0F); + tessellator.setNormal(1.0F, 0.0F, 0.0F); } if(var2 == 5) { - var1.normal(-1.0F, 0.0F, 0.0F); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); } - this.renderInside(var1, 0, 0, 0, var2); + this.renderInside(0, 0, 0, var2); } - var1.end(); + tessellator.draw(); } public final boolean canExplode() { @@ -581,7 +587,8 @@ public class Block public void explode(Level var1, int var2, int var3, int var4) {} - public boolean render(Level var1, int var2, int var3, int var4, ShapeRenderer var5) { + public boolean render(Level var1, int var2, int var3, int var4) { + Tessellator tessellator = Tessellator.instance; boolean var6 = false; float var7 = 0.5F; float var8 = 0.8F; @@ -589,43 +596,43 @@ public class Block float var10; if(this.canRenderSide(var1, var2, var3 - 1, var4, 0)) { var10 = this.getBrightness(var1, var2, var3 - 1, var4); - var5.color(var7 * var10, var7 * var10, var7 * var10); - this.renderInside(var5, var2, var3, var4, 0); + tessellator.setColorOpaque_F(var7 * var10, var7 * var10, var7 * var10); + this.renderInside(var2, var3, var4, 0); var6 = true; } if(this.canRenderSide(var1, var2, var3 + 1, var4, 1)) { var10 = this.getBrightness(var1, var2, var3 + 1, var4); - var5.color(var10 * 1.0F, var10 * 1.0F, var10 * 1.0F); - this.renderInside(var5, var2, var3, var4, 1); + tessellator.setColorOpaque_F(var10 * 1.0F, var10 * 1.0F, var10 * 1.0F); + this.renderInside(var2, var3, var4, 1); var6 = true; } if(this.canRenderSide(var1, var2, var3, var4 - 1, 2)) { var10 = this.getBrightness(var1, var2, var3, var4 - 1); - var5.color(var8 * var10, var8 * var10, var8 * var10); - this.renderInside(var5, var2, var3, var4, 2); + tessellator.setColorOpaque_F(var8 * var10, var8 * var10, var8 * var10); + this.renderInside(var2, var3, var4, 2); var6 = true; } if(this.canRenderSide(var1, var2, var3, var4 + 1, 3)) { var10 = this.getBrightness(var1, var2, var3, var4 + 1); - var5.color(var8 * var10, var8 * var10, var8 * var10); - this.renderInside(var5, var2, var3, var4, 3); + tessellator.setColorOpaque_F(var8 * var10, var8 * var10, var8 * var10); + this.renderInside(var2, var3, var4, 3); var6 = true; } if(this.canRenderSide(var1, var2 - 1, var3, var4, 4)) { var10 = this.getBrightness(var1, var2 - 1, var3, var4); - var5.color(var9 * var10, var9 * var10, var9 * var10); - this.renderInside(var5, var2, var3, var4, 4); + tessellator.setColorOpaque_F(var9 * var10, var9 * var10, var9 * var10); + this.renderInside(var2, var3, var4, 4); var6 = true; } if(this.canRenderSide(var1, var2 + 1, var3, var4, 5)) { var10 = this.getBrightness(var1, var2 + 1, var3, var4); - var5.color(var9 * var10, var9 * var10, var9 * var10); - this.renderInside(var5, var2, var3, var4, 5); + tessellator.setColorOpaque_F(var9 * var10, var9 * var10, var9 * var10); + this.renderInside(var2, var3, var4, 5); var6 = true; } diff --git a/src/teavm/java/com/mojang/minecraft/level/tile/FlowerBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/FlowerBlock.java index 25cf60a..c64187e 100644 --- a/src/teavm/java/com/mojang/minecraft/level/tile/FlowerBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/FlowerBlock.java @@ -2,12 +2,14 @@ package com.mojang.minecraft.level.tile; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.phys.AABB; -import com.mojang.minecraft.render.ShapeRenderer; import net.PeytonPlayz585.math.MathHelper; +import net.lax1dude.eaglercraft.adapter.Tessellator; import java.util.Random; public class FlowerBlock extends Block { + + Tessellator tessellator = Tessellator.instance; protected FlowerBlock(int var1, int var2) { super(var1); @@ -27,7 +29,7 @@ public class FlowerBlock extends Block { } } - private void render(ShapeRenderer var1, float var2, float var3, float var4) { + private void render(float var2, float var3, float var4) { int var15; int var5 = (var15 = this.getTextureId(15)) % 16 << 4; int var6 = var15 / 16 << 4; @@ -44,14 +46,14 @@ public class FlowerBlock extends Block { float var13 = var3 + 1.0F; float var14 = var4 + 0.5F - var10; var10 += var4 + 0.5F; - var1.vertexUV(var11, var13, var14, var17, var7); - var1.vertexUV(var9, var13, var10, var16, var7); - var1.vertexUV(var9, var3, var10, var16, var18); - var1.vertexUV(var11, var3, var14, var17, var18); - var1.vertexUV(var9, var13, var10, var17, var7); - var1.vertexUV(var11, var13, var14, var16, var7); - var1.vertexUV(var11, var3, var14, var16, var18); - var1.vertexUV(var9, var3, var10, var17, var18); + tessellator.addVertexWithUV(var11, var13, var14, var17, var7); + tessellator.addVertexWithUV(var9, var13, var10, var16, var7); + tessellator.addVertexWithUV(var9, var3, var10, var16, var18); + tessellator.addVertexWithUV(var11, var3, var14, var17, var18); + tessellator.addVertexWithUV(var9, var13, var10, var17, var7); + tessellator.addVertexWithUV(var11, var13, var14, var16, var7); + tessellator.addVertexWithUV(var11, var3, var14, var16, var18); + tessellator.addVertexWithUV(var9, var3, var10, var17, var18); } } @@ -64,27 +66,27 @@ public class FlowerBlock extends Block { return false; } - public final void renderPreview(ShapeRenderer var1) { - var1.normal(0.0F, 1.0F, 0.0F); - var1.begin(); - this.render(var1, 0.0F, 0.4F, -0.3F); - var1.end(); + public final void renderPreview() { + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.startDrawing(); + this.render(0.0F, 0.4F, -0.3F); + tessellator.draw(); } public final boolean isCube() { return false; } - public final boolean render(Level var1, int var2, int var3, int var4, ShapeRenderer var5) { + public final boolean render(Level var1, int var2, int var3, int var4) { float var6 = var1.getBrightness(var2, var3, var4); - var5.color(var6, var6, var6); - this.render(var5, (float)var2, (float)var3, (float)var4); + tessellator.setColorOpaque_F(var6, var6, var6); + this.render((float)var2, (float)var3, (float)var4); return true; } - public final void renderFullbright(ShapeRenderer shapeRenderer) { - shapeRenderer.color(1.0F, 1.0F, 1.0F); - this.render(shapeRenderer, (float)-2, 0.0F, 0.0F); + public final void renderFullbright() { + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + this.render((float)-2, 0.0F, 0.0F); } @Override diff --git a/src/teavm/java/com/mojang/minecraft/level/tile/LiquidBlock.java b/src/teavm/java/com/mojang/minecraft/level/tile/LiquidBlock.java index de06907..36b2f33 100644 --- a/src/teavm/java/com/mojang/minecraft/level/tile/LiquidBlock.java +++ b/src/teavm/java/com/mojang/minecraft/level/tile/LiquidBlock.java @@ -3,7 +3,6 @@ package com.mojang.minecraft.level.tile; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.liquid.LiquidType; import com.mojang.minecraft.phys.AABB; -import com.mojang.minecraft.render.ShapeRenderer; import java.util.Random; @@ -115,9 +114,9 @@ public class LiquidBlock extends Block { return x >= 0 && y >= 0 && z >= 0 && x < level.width && z < level.height?((var6 = level.getTile(x, y, z)) != this.movingId && var6 != this.stillId?(side == 1 && (level.getTile(x - 1, y, z) == 0 || level.getTile(x + 1, y, z) == 0 || level.getTile(x, y, z - 1) == 0 || level.getTile(x, y, z + 1) == 0)?true:super.canRenderSide(level, x, y, z, side)):false):false; } - public final void renderInside(ShapeRenderer shapeRenderer, int x, int y, int z, int side) { - super.renderInside(shapeRenderer, x, y, z, side); - super.renderSide(shapeRenderer, x, y, z, side); + public final void renderInside(int x, int y, int z, int side) { + super.renderInside(x, y, z, side); + super.renderSide(x, y, z, side); } public final boolean isOpaque() { diff --git a/src/teavm/java/com/mojang/minecraft/particle/Particle.java b/src/teavm/java/com/mojang/minecraft/particle/Particle.java index 0cdd49e..127a970 100644 --- a/src/teavm/java/com/mojang/minecraft/particle/Particle.java +++ b/src/teavm/java/com/mojang/minecraft/particle/Particle.java @@ -2,8 +2,8 @@ package com.mojang.minecraft.particle; import com.mojang.minecraft.Entity; import com.mojang.minecraft.level.Level; -import com.mojang.minecraft.render.ShapeRenderer; import net.PeytonPlayz585.math.MathHelper; +import net.lax1dude.eaglercraft.adapter.Tessellator; public class Particle extends Entity { @@ -78,7 +78,8 @@ public class Particle extends Entity { } - public void render(ShapeRenderer var1, float var2, float var3, float var4, float var5, float var6, float var7) { + public void render(float var2, float var3, float var4, float var5, float var6, float var7) { + Tessellator var1 = Tessellator.instance; float var8; float var9 = (var8 = (float)(this.tex % 16) / 16.0F) + 0.0624375F; float var10; @@ -88,11 +89,11 @@ public class Particle extends Entity { float var14 = this.yo + (this.y - this.yo) * var2; float var15 = this.zo + (this.z - this.zo) * var2; var2 = this.getBrightness(var2); - var1.color(this.rCol * var2, this.gCol * var2, this.bCol * var2); - var1.vertexUV(var13 - var3 * var12 - var6 * var12, var14 - var4 * var12, var15 - var5 * var12 - var7 * var12, var8, var11); - var1.vertexUV(var13 - var3 * var12 + var6 * var12, var14 + var4 * var12, var15 - var5 * var12 + var7 * var12, var8, var10); - var1.vertexUV(var13 + var3 * var12 + var6 * var12, var14 + var4 * var12, var15 + var5 * var12 + var7 * var12, var9, var10); - var1.vertexUV(var13 + var3 * var12 - var6 * var12, var14 - var4 * var12, var15 + var5 * var12 - var7 * var12, var9, var11); + var1.setColorOpaque_F(this.rCol * var2, this.gCol * var2, this.bCol * var2); + var1.addVertexWithUV(var13 - var3 * var12 - var6 * var12, var14 - var4 * var12, var15 - var5 * var12 - var7 * var12, var8, var11); + var1.addVertexWithUV(var13 - var3 * var12 + var6 * var12, var14 + var4 * var12, var15 - var5 * var12 + var7 * var12, var8, var10); + var1.addVertexWithUV(var13 + var3 * var12 + var6 * var12, var14 + var4 * var12, var15 + var5 * var12 + var7 * var12, var9, var10); + var1.addVertexWithUV(var13 + var3 * var12 - var6 * var12, var14 - var4 * var12, var15 + var5 * var12 - var7 * var12, var9, var11); } public int getParticleTexture() { diff --git a/src/teavm/java/com/mojang/minecraft/particle/SmokeParticle.java b/src/teavm/java/com/mojang/minecraft/particle/SmokeParticle.java index b2ced7c..e06cf58 100644 --- a/src/teavm/java/com/mojang/minecraft/particle/SmokeParticle.java +++ b/src/teavm/java/com/mojang/minecraft/particle/SmokeParticle.java @@ -2,7 +2,6 @@ package com.mojang.minecraft.particle; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.particle.Particle; -import com.mojang.minecraft.render.ShapeRenderer; public class SmokeParticle extends Particle { @@ -19,8 +18,8 @@ public class SmokeParticle extends Particle { this.noPhysics = true; } - public void render(ShapeRenderer var1, float var2, float var3, float var4, float var5, float var6, float var7) { - super.render(var1, var2, var3, var4, var5, var6, var7); + public void render(float var2, float var3, float var4, float var5, float var6, float var7) { + super.render(var2, var3, var4, var5, var6, var7); } public void tick() { diff --git a/src/teavm/java/com/mojang/minecraft/particle/TerrainParticle.java b/src/teavm/java/com/mojang/minecraft/particle/TerrainParticle.java index 22f8617..7f50149 100644 --- a/src/teavm/java/com/mojang/minecraft/particle/TerrainParticle.java +++ b/src/teavm/java/com/mojang/minecraft/particle/TerrainParticle.java @@ -3,7 +3,8 @@ package com.mojang.minecraft.particle; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.tile.Block; import com.mojang.minecraft.particle.Particle; -import com.mojang.minecraft.render.ShapeRenderer; + +import net.lax1dude.eaglercraft.adapter.Tessellator; public class TerrainParticle extends Particle { @@ -21,7 +22,8 @@ public class TerrainParticle extends Particle { return 1; } - public void render(ShapeRenderer var1, float var2, float var3, float var4, float var5, float var6, float var7) { + public void render(float var2, float var3, float var4, float var5, float var6, float var7) { + Tessellator var1 = Tessellator.instance; float var8; float var9 = (var8 = ((float)(this.tex % 16) + this.uo / 4.0F) / 16.0F) + 0.015609375F; float var10; @@ -31,10 +33,10 @@ public class TerrainParticle extends Particle { float var14 = this.yo + (this.y - this.yo) * var2; float var15 = this.zo + (this.z - this.zo) * var2; var2 = this.getBrightness(var2); - var1.color(var2 * this.rCol, var2 * this.gCol, var2 * this.bCol); - var1.vertexUV(var13 - var3 * var12 - var6 * var12, var14 - var4 * var12, var15 - var5 * var12 - var7 * var12, var8, var11); - var1.vertexUV(var13 - var3 * var12 + var6 * var12, var14 + var4 * var12, var15 - var5 * var12 + var7 * var12, var8, var10); - var1.vertexUV(var13 + var3 * var12 + var6 * var12, var14 + var4 * var12, var15 + var5 * var12 + var7 * var12, var9, var10); - var1.vertexUV(var13 + var3 * var12 - var6 * var12, var14 - var4 * var12, var15 + var5 * var12 - var7 * var12, var9, var11); + var1.setColorOpaque_F(var2 * this.rCol, var2 * this.gCol, var2 * this.bCol); + var1.addVertexWithUV(var13 - var3 * var12 - var6 * var12, var14 - var4 * var12, var15 - var5 * var12 - var7 * var12, var8, var11); + var1.addVertexWithUV(var13 - var3 * var12 + var6 * var12, var14 + var4 * var12, var15 - var5 * var12 + var7 * var12, var8, var10); + var1.addVertexWithUV(var13 + var3 * var12 + var6 * var12, var14 + var4 * var12, var15 + var5 * var12 + var7 * var12, var9, var10); + var1.addVertexWithUV(var13 + var3 * var12 - var6 * var12, var14 - var4 * var12, var15 + var5 * var12 - var7 * var12, var9, var11); } } diff --git a/src/teavm/java/com/mojang/minecraft/particle/WaterDropParticle.java b/src/teavm/java/com/mojang/minecraft/particle/WaterDropParticle.java index 0479a50..73fe658 100644 --- a/src/teavm/java/com/mojang/minecraft/particle/WaterDropParticle.java +++ b/src/teavm/java/com/mojang/minecraft/particle/WaterDropParticle.java @@ -2,7 +2,6 @@ package com.mojang.minecraft.particle; import com.mojang.minecraft.level.Level; import com.mojang.minecraft.particle.Particle; -import com.mojang.minecraft.render.ShapeRenderer; public class WaterDropParticle extends Particle { @@ -22,8 +21,8 @@ public class WaterDropParticle extends Particle { this.lifetime = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); } - public void render(ShapeRenderer var1, float var2, float var3, float var4, float var5, float var6, float var7) { - super.render(var1, var2, var3, var4, var5, var6, var7); + public void render(float var2, float var3, float var4, float var5, float var6, float var7) { + super.render(var2, var3, var4, var5, var6, var7); } public void tick() { diff --git a/src/teavm/java/com/mojang/minecraft/render/Chunk.java b/src/teavm/java/com/mojang/minecraft/render/Chunk.java index 0e7eed5..e205fd6 100644 --- a/src/teavm/java/com/mojang/minecraft/render/Chunk.java +++ b/src/teavm/java/com/mojang/minecraft/render/Chunk.java @@ -4,15 +4,16 @@ import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.tile.Block; import com.mojang.minecraft.player.Player; import com.mojang.minecraft.render.Frustrum; -import com.mojang.minecraft.render.ShapeRenderer; import net.PeytonPlayz585.math.MathHelper; +import net.lax1dude.eaglercraft.adapter.Tessellator; + import org.lwjgl.opengl.GL11; public final class Chunk { private Level level; private int baseListId = -1; - private static ShapeRenderer renderer = ShapeRenderer.instance; + private static Tessellator renderer = Tessellator.instance; public static int chunkUpdates = 0; private int x; private int y; @@ -54,7 +55,7 @@ public final class Chunk { boolean var8 = false; boolean var9 = false; GL11.glNewList(this.baseListId + var7, 4864); - renderer.begin(); + renderer.startDrawing(); for(int var10 = var1; var10 < var4; ++var10) { for(int var11 = var2; var11 < var5; ++var11) { @@ -65,14 +66,14 @@ public final class Chunk { if((var14 = Block.blocks[var13]).getRenderPass() != var7) { var8 = true; } else { - var9 |= var14.render(this.level, var10, var11, var12, renderer); + var9 |= var14.render(this.level, var10, var11, var12); } } } } } - renderer.end(); + renderer.draw(); GL11.glEndList(); if(var9) { this.dirty[var7] = false; diff --git a/src/teavm/java/com/mojang/minecraft/render/LevelRenderer.java b/src/teavm/java/com/mojang/minecraft/render/LevelRenderer.java index 7ae7e48..3b3bd1f 100644 --- a/src/teavm/java/com/mojang/minecraft/render/LevelRenderer.java +++ b/src/teavm/java/com/mojang/minecraft/render/LevelRenderer.java @@ -5,6 +5,7 @@ import com.mojang.minecraft.level.Level; import com.mojang.minecraft.player.Player; import net.lax1dude.eaglercraft.GLAllocation; +import net.lax1dude.eaglercraft.adapter.Tessellator; import java.nio.IntBuffer; import java.util.ArrayList; @@ -75,7 +76,7 @@ public final class LevelRenderer { LevelRenderer var9 = this; float var10 = 0.5F; GL11.glColor4f(0.5F, var10, var10, 1.0F); - ShapeRenderer var11 = ShapeRenderer.instance; + Tessellator var11 = Tessellator.instance; float var12 = this.level.getGroundLevel(); int var5 = 128; if(128 > this.level.width) { @@ -87,7 +88,7 @@ public final class LevelRenderer { } int var6 = 2048 / var5; - var11.begin(); + var11.startDrawing(); int var7; for(var7 = -var5 * var6; var7 < var9.level.width + var5 * var6; var7 += var5) { @@ -97,49 +98,49 @@ public final class LevelRenderer { var10 = 0.0F; } - var11.vertexUV((float)var7, var10, (float)(var8 + var5), 0.0F, (float)var5); - var11.vertexUV((float)(var7 + var5), var10, (float)(var8 + var5), (float)var5, (float)var5); - var11.vertexUV((float)(var7 + var5), var10, (float)var8, (float)var5, 0.0F); - var11.vertexUV((float)var7, var10, (float)var8, 0.0F, 0.0F); + var11.addVertexWithUV((float)var7, var10, (float)(var8 + var5), 0.0F, (float)var5); + var11.addVertexWithUV((float)(var7 + var5), var10, (float)(var8 + var5), (float)var5, (float)var5); + var11.addVertexWithUV((float)(var7 + var5), var10, (float)var8, (float)var5, 0.0F); + var11.addVertexWithUV((float)var7, var10, (float)var8, 0.0F, 0.0F); } } - var11.end(); + var11.draw(); GL11.glColor3f(0.8F, 0.8F, 0.8F); - var11.begin(); + var11.startDrawing(); for(var7 = 0; var7 < var9.level.width; var7 += var5) { - var11.vertexUV((float)var7, 0.0F, 0.0F, 0.0F, 0.0F); - var11.vertexUV((float)(var7 + var5), 0.0F, 0.0F, (float)var5, 0.0F); - var11.vertexUV((float)(var7 + var5), var12, 0.0F, (float)var5, var12); - var11.vertexUV((float)var7, var12, 0.0F, 0.0F, var12); - var11.vertexUV((float)var7, var12, (float)var9.level.height, 0.0F, var12); - var11.vertexUV((float)(var7 + var5), var12, (float)var9.level.height, (float)var5, var12); - var11.vertexUV((float)(var7 + var5), 0.0F, (float)var9.level.height, (float)var5, 0.0F); - var11.vertexUV((float)var7, 0.0F, (float)var9.level.height, 0.0F, 0.0F); + var11.addVertexWithUV((float)var7, 0.0F, 0.0F, 0.0F, 0.0F); + var11.addVertexWithUV((float)(var7 + var5), 0.0F, 0.0F, (float)var5, 0.0F); + var11.addVertexWithUV((float)(var7 + var5), var12, 0.0F, (float)var5, var12); + var11.addVertexWithUV((float)var7, var12, 0.0F, 0.0F, var12); + var11.addVertexWithUV((float)var7, var12, (float)var9.level.height, 0.0F, var12); + var11.addVertexWithUV((float)(var7 + var5), var12, (float)var9.level.height, (float)var5, var12); + var11.addVertexWithUV((float)(var7 + var5), 0.0F, (float)var9.level.height, (float)var5, 0.0F); + var11.addVertexWithUV((float)var7, 0.0F, (float)var9.level.height, 0.0F, 0.0F); } GL11.glColor3f(0.6F, 0.6F, 0.6F); for(var7 = 0; var7 < var9.level.height; var7 += var5) { - var11.vertexUV(0.0F, var12, (float)var7, 0.0F, 0.0F); - var11.vertexUV(0.0F, var12, (float)(var7 + var5), (float)var5, 0.0F); - var11.vertexUV(0.0F, 0.0F, (float)(var7 + var5), (float)var5, var12); - var11.vertexUV(0.0F, 0.0F, (float)var7, 0.0F, var12); - var11.vertexUV((float)var9.level.width, 0.0F, (float)var7, 0.0F, var12); - var11.vertexUV((float)var9.level.width, 0.0F, (float)(var7 + var5), (float)var5, var12); - var11.vertexUV((float)var9.level.width, var12, (float)(var7 + var5), (float)var5, 0.0F); - var11.vertexUV((float)var9.level.width, var12, (float)var7, 0.0F, 0.0F); + var11.addVertexWithUV(0.0F, var12, (float)var7, 0.0F, 0.0F); + var11.addVertexWithUV(0.0F, var12, (float)(var7 + var5), (float)var5, 0.0F); + var11.addVertexWithUV(0.0F, 0.0F, (float)(var7 + var5), (float)var5, var12); + var11.addVertexWithUV(0.0F, 0.0F, (float)var7, 0.0F, var12); + var11.addVertexWithUV((float)var9.level.width, 0.0F, (float)var7, 0.0F, var12); + var11.addVertexWithUV((float)var9.level.width, 0.0F, (float)(var7 + var5), (float)var5, var12); + var11.addVertexWithUV((float)var9.level.width, var12, (float)(var7 + var5), (float)var5, 0.0F); + var11.addVertexWithUV((float)var9.level.width, var12, (float)var7, 0.0F, 0.0F); } - var11.end(); + var11.draw(); GL11.glEndList(); GL11.glNewList(this.listId + 1, 4864); var9 = this; GL11.glColor3f(1.0F, 1.0F, 1.0F); var10 = this.level.getWaterLevel(); GL11.glBlendFunc(770, 771); - var11 = ShapeRenderer.instance; + var11 = Tessellator.instance; var4 = 128; if(128 > this.level.width) { var4 = this.level.width; @@ -150,25 +151,25 @@ public final class LevelRenderer { } var5 = 2048 / var4; - var11.begin(); + var11.startDrawing(); for(var6 = -var4 * var5; var6 < var9.level.width + var4 * var5; var6 += var4) { for(var7 = -var4 * var5; var7 < var9.level.height + var4 * var5; var7 += var4) { float var13 = var10 - 0.1F; if(var6 < 0 || var7 < 0 || var6 >= var9.level.width || var7 >= var9.level.height) { - var11.vertexUV((float)var6, var13, (float)(var7 + var4), 0.0F, (float)var4); - var11.vertexUV((float)(var6 + var4), var13, (float)(var7 + var4), (float)var4, (float)var4); - var11.vertexUV((float)(var6 + var4), var13, (float)var7, (float)var4, 0.0F); - var11.vertexUV((float)var6, var13, (float)var7, 0.0F, 0.0F); - var11.vertexUV((float)var6, var13, (float)var7, 0.0F, 0.0F); - var11.vertexUV((float)(var6 + var4), var13, (float)var7, (float)var4, 0.0F); - var11.vertexUV((float)(var6 + var4), var13, (float)(var7 + var4), (float)var4, (float)var4); - var11.vertexUV((float)var6, var13, (float)(var7 + var4), 0.0F, (float)var4); + var11.addVertexWithUV((float)var6, var13, (float)(var7 + var4), 0.0F, (float)var4); + var11.addVertexWithUV((float)(var6 + var4), var13, (float)(var7 + var4), (float)var4, (float)var4); + var11.addVertexWithUV((float)(var6 + var4), var13, (float)var7, (float)var4, 0.0F); + var11.addVertexWithUV((float)var6, var13, (float)var7, 0.0F, 0.0F); + var11.addVertexWithUV((float)var6, var13, (float)var7, 0.0F, 0.0F); + var11.addVertexWithUV((float)(var6 + var4), var13, (float)var7, (float)var4, 0.0F); + var11.addVertexWithUV((float)(var6 + var4), var13, (float)(var7 + var4), (float)var4, (float)var4); + var11.addVertexWithUV((float)var6, var13, (float)(var7 + var4), 0.0F, (float)var4); } } } - var11.end(); + var11.draw(); GL11.glDisable(3042); GL11.glEndList(); this.queueChunks(0, 0, 0, this.level.width, this.level.depth, this.level.height); diff --git a/src/teavm/java/com/mojang/minecraft/render/RenderEngine.java b/src/teavm/java/com/mojang/minecraft/render/RenderEngine.java index d7188ad..76f93de 100644 --- a/src/teavm/java/com/mojang/minecraft/render/RenderEngine.java +++ b/src/teavm/java/com/mojang/minecraft/render/RenderEngine.java @@ -190,7 +190,6 @@ public class RenderEngine { } } - //public static boolean useMipmaps = false; private HashMap textureMap; private HashMap textureNameToImageMap; private IntBuffer singleIntBuffer; diff --git a/src/teavm/java/com/mojang/minecraft/render/ShapeRenderer.java b/src/teavm/java/com/mojang/minecraft/render/ShapeRenderer.java deleted file mode 100644 index dc94fe9..0000000 --- a/src/teavm/java/com/mojang/minecraft/render/ShapeRenderer.java +++ /dev/null @@ -1,169 +0,0 @@ -package com.mojang.minecraft.render; - -import java.nio.FloatBuffer; -import org.lwjgl.opengl.GL11; - -import net.lax1dude.eaglercraft.GLAllocation; - -public final class ShapeRenderer { - - private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(524288); - private float[] data = new float[524288]; - private int vertices = 0; - private float u; - private float v; - private float r; - private float g; - private float b; - private boolean color = false; - private boolean texture = false; - private boolean normals = false; - private int normal; - private int vertexLength = 3; - private int length = 0; - private boolean noColor = false; - public static ShapeRenderer instance = new ShapeRenderer(); - - - public final void end() { - if(this.vertices > 0) { - this.buffer.clear(); - this.buffer.put(this.data, 0, this.length); - this.buffer.flip(); - - if (this.texture) { - GL11.glEnableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY); - } - - if (this.color) { - GL11.glEnableVertexAttrib(GL11.GL_COLOR_ARRAY); - } - - if (this.normals) { - GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY); - } - - GL11._wglDrawArrays(7, 0, this.vertices); - - if (this.texture) { - GL11.glDisableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY); - } - - if (this.color) { - GL11.glDisableVertexAttrib(GL11.GL_COLOR_ARRAY); - } - - if (this.normals) { - GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY); - } - } - - this.clear(); - } - - private void clear() { - this.vertices = 0; - this.buffer.clear(); - this.length = 0; - } - - public final void begin() { - this.clear(); - this.normals = false; - this.color = false; - this.texture = false; - this.noColor = false; - } - - public final void color(float var1, float var2, float var3) { - if(!this.noColor) { - if(!this.color) { - this.vertexLength += 3; - } - - this.color = true; - this.r = var1; - this.g = var2; - this.b = var3; - } - } - - public final void vertexUV(float var1, float var2, float var3, float var4, float var5) { - if(!this.texture) { - this.vertexLength += 2; - } - - this.texture = true; - this.u = var4; - this.v = var5; - this.vertex(var1, var2, var3); - } - - public final void vertex(float var1, float var2, float var3) { - if(this.texture) { - this.data[this.length++] = this.u; - this.data[this.length++] = this.v; - } - - if(this.color) { - this.data[this.length++] = this.r; - this.data[this.length++] = this.g; - this.data[this.length++] = this.b; - } - - if(this.normals) { - this.data[this.length++] = this.normal; - } - - this.data[this.length++] = var1; - this.data[this.length++] = var2; - this.data[this.length++] = var3; - ++this.vertices; - if(this.vertices % 4 == 0 && this.length >= 524288 - (this.vertexLength << 2)) { - this.end(); - } - - } - - public final void color(int var1) { - int var2 = var1 >> 16 & 255; - int var3 = var1 >> 8 & 255; - var1 &= 255; - int var10001 = var2; - int var10002 = var3; - var3 = var1; - var2 = var10002; - var1 = var10001; - byte var7 = (byte)var1; - byte var4 = (byte)var2; - byte var8 = (byte)var3; - byte var6 = var4; - byte var5 = var7; - if(!this.noColor) { - if(!this.color) { - this.vertexLength += 3; - } - - this.color = true; - this.r = (float)(var5 & 255) / 255.0F; - this.g = (float)(var6 & 255) / 255.0F; - this.b = (float)(var8 & 255) / 255.0F; - } - - } - - public final void noColor() { - this.noColor = true; - } - - public final void normal(float var1, float var2, float var3) { - this.normals = true; - float len = (float) Math.sqrt(var1 * var1 + var2 * var2 + var3 * var3); - int var4 = (int) ((var1 / len) * 127.0F) + 127; - int var5 = (int) ((var2 / len) * 127.0F) + 127; - int var6 = (int) ((var3 / len) * 127.0F) + 127; - this.normal = var4 & 255 | (var5 & 255) << 8 | (var6 & 255) << 16; - GL11.glNormal3f(var1, var2, var3); - } - -} \ No newline at end of file diff --git a/src/teavm/java/net/lax1dude/eaglercraft/adapter/Tessellator.java b/src/teavm/java/net/lax1dude/eaglercraft/adapter/Tessellator.java index 6328954..c0c1840 100644 --- a/src/teavm/java/net/lax1dude/eaglercraft/adapter/Tessellator.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/adapter/Tessellator.java @@ -54,9 +54,6 @@ public class Tessellator { /** Disables all color information for the following draw call. */ private boolean isColorDisabled = false; - /** The draw mode currently being used by the tessellator. */ - private int drawMode; - /** * An offset to be applied along the x-axis for all vertices in this draw call. */ @@ -118,7 +115,7 @@ public class Tessellator { GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY); } - GL11.glDrawArrays(this.drawMode, 0, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 7)); + GL11.glDrawArrays(7, 0, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 7)); if (this.hasTexture) { GL11.glDisableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY); @@ -153,20 +150,19 @@ public class Tessellator { * Sets draw mode in the tessellator to draw quads. */ public void startDrawingQuads() { - this.startDrawing(GL11.GL_QUADS); + this.startDrawing(); } /** * Resets tessellator state and prepares for drawing (with the specified draw * mode). */ - public void startDrawing(int par1) { + public void startDrawing() { if (this.isDrawing) { this.draw(); } this.isDrawing = true; this.reset(); - this.drawMode = par1; this.hasNormals = false; this.hasColor = false; this.hasTexture = false;