This commit is contained in:
PeytonPlayz595 2023-07-17 17:29:57 -04:00
parent 9138a1ee09
commit 40d2195d48
9 changed files with 30 additions and 262 deletions

View File

@ -24,9 +24,6 @@ import com.mojang.minecraft.player.InputHandlerImpl;
import com.mojang.minecraft.player.Player; import com.mojang.minecraft.player.Player;
import com.mojang.minecraft.render.*; import com.mojang.minecraft.render.*;
import com.mojang.minecraft.render.Renderer; import com.mojang.minecraft.render.Renderer;
import com.mojang.minecraft.render.texture.TextureFX;
import com.mojang.minecraft.render.texture.TextureLavaFX;
import com.mojang.minecraft.render.texture.TextureWaterFX;
import net.PeytonPlayz585.math.MathHelper; import net.PeytonPlayz585.math.MathHelper;
import net.lax1dude.eaglercraft.GLAllocation; import net.lax1dude.eaglercraft.GLAllocation;
@ -443,8 +440,6 @@ public final class Minecraft implements Runnable {
var74 = var116.yo + (var116.y - var116.yo) * var80; var74 = var116.yo + (var116.y - var116.yo) * var80;
var33 = var116.zo + (var116.z - var116.zo) * var80; var33 = var116.zo + (var116.z - var116.zo) * var80;
GL11.glTranslatef(-var69, -var74, -var33); GL11.glTranslatef(-var69, -var74, -var33);
//Frustrum var76 = FrustrumImpl.update();
//Frustrum var100 = var76;
Frustrum var76 = new Frustrum(); Frustrum var76 = new Frustrum();
if(field_22009_h != this.player) { if(field_22009_h != this.player) {
field_22009_h = player; field_22009_h = player;
@ -469,7 +464,7 @@ public final class Minecraft implements Runnable {
Collections.sort(var82.minecraft.levelRenderer.chunks, new ChunkDirtyDistanceComparator(var126)); Collections.sort(var82.minecraft.levelRenderer.chunks, new ChunkDirtyDistanceComparator(var126));
var98 = var101.chunks.size() - 1; var98 = var101.chunks.size() - 1;
int var105; int var105;
if((var105 = var101.chunks.size()) > 3) { if((var105 = var101.chunks.size() / 2) > 3) {
var105 = 3; var105 = 3;
} }

View File

@ -33,7 +33,7 @@ public final class Chunk {
this.y = var3; this.y = var3;
this.z = var4; this.z = var4;
this.width = this.height = this.depth = 16; this.width = this.height = this.depth = 16;
MathHelper.sqrt((float)(this.width * this.width + this.height * this.height + this.depth * this.depth)); MathHelper.sqrt((float)(this.width + this.height + this.depth));
this.baseListId = var6; this.baseListId = var6;
this.setAllDirty(); this.setAllDirty();
} }
@ -47,12 +47,10 @@ public final class Chunk {
int var5 = this.y + this.height; int var5 = this.y + this.height;
int var6 = this.z + this.depth; int var6 = this.z + this.depth;
int var7; this.dirty[1] = true;
for(var7 = 0; var7 < 2; ++var7) { this.dirty[2] = true;
this.dirty[var7] = true;
}
for(var7 = 0; var7 < 2; ++var7) { for(int var7 = 0; var7 < 2; ++var7) {
boolean var8 = false; boolean var8 = false;
boolean var9 = false; boolean var9 = false;
GL11.glNewList(this.baseListId + var7, 4864); GL11.glNewList(this.baseListId + var7, 4864);

View File

@ -17,7 +17,7 @@ public final class LevelRenderer {
public Level level; public Level level;
public int listId; public int listId;
public IntBuffer buffer = GLAllocation.createDirectIntBuffer(65536); public IntBuffer buffer = GLAllocation.createDirectIntBuffer(4096);
public List<Chunk> chunks = new ArrayList<Chunk>(); public List<Chunk> chunks = new ArrayList<Chunk>();
private Chunk[] loadQueue; private Chunk[] loadQueue;
public Chunk[] chunkCache; public Chunk[] chunkCache;
@ -26,7 +26,7 @@ public final class LevelRenderer {
private int zChunks; private int zChunks;
private int baseListId; private int baseListId;
public Minecraft minecraft; public Minecraft minecraft;
private int[] chunkDataCache = new int[4096]; private int[] chunkDataCache = new int[1024];
public int ticks = 0; public int ticks = 0;
private float lastLoadX = -9999.0F; private float lastLoadX = -9999.0F;
private float lastLoadY = -9999.0F; private float lastLoadY = -9999.0F;
@ -37,7 +37,7 @@ public final class LevelRenderer {
public LevelRenderer(Minecraft var1) { public LevelRenderer(Minecraft var1) {
this.minecraft = var1; this.minecraft = var1;
this.listId = GL11.glGenLists(2); this.listId = GL11.glGenLists(2);
this.baseListId = GL11.glGenLists(4096 << 6 << 1); this.baseListId = GL11.glGenLists(4096);
} }
public final void refresh() { public final void refresh() {
@ -196,7 +196,6 @@ public final class LevelRenderer {
this.buffer.put(this.chunkDataCache, 0, var6); this.buffer.put(this.chunkDataCache, 0, var6);
this.buffer.flip(); this.buffer.flip();
if(this.buffer.remaining() > 0) { if(this.buffer.remaining() > 0) {
new TextureLocation("/terrain.png").bindTexture();
GL11.glCallLists(this.buffer); GL11.glCallLists(this.buffer);
} }

View File

@ -1,21 +1,13 @@
package com.mojang.minecraft.render; package com.mojang.minecraft.render;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import com.mojang.minecraft.GameSettings; import com.mojang.minecraft.GameSettings;
import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.render.texture.TextureFX;
import net.lax1dude.eaglercraft.EaglerImage; import net.lax1dude.eaglercraft.EaglerImage;
import net.lax1dude.eaglercraft.GLAllocation; import net.lax1dude.eaglercraft.GLAllocation;
@ -23,22 +15,21 @@ import net.lax1dude.eaglercraft.GLAllocation;
public class RenderEngine { public class RenderEngine {
public RenderEngine() { public RenderEngine() {
textureMap = new HashMap<String, Integer>(); // textureMap = new HashMap<String, Integer>();
textureNameToImageMap = new HashMap<Integer, EaglerImage>(); // textureNameToImageMap = new HashMap<Integer, EaglerImage>();
singleIntBuffer = GLAllocation.createDirectIntBuffer(1); singleIntBuffer = GLAllocation.createDirectIntBuffer(1);
imageDataB1 = GLAllocation.createDirectByteBuffer(0x100000); imageDataB1 = GLAllocation.createDirectByteBuffer(0x100000);
imageDataB2 = GLAllocation.createDirectByteBuffer(0x100000); // imageDataB2 = GLAllocation.createDirectByteBuffer(0x100000);
textureList = new ArrayList<TextureFX>();
textureBlending = false; textureBlending = false;
options = Minecraft.settings; options = Minecraft.settings;
} }
public int getTexture(String s) { public int getTexture(String s) {
TextureBase texturepackbase = new TextureBase(); // TextureBase texturepackbase = new TextureBase();
Integer integer = (Integer) textureMap.get(s); // Integer integer = (Integer) textureMap.get(s);
if (integer != null) { // if (integer != null) {
return integer.intValue(); // return integer.intValue();
} // }
try { try {
singleIntBuffer.clear(); singleIntBuffer.clear();
GLAllocation.generateTextureNames(singleIntBuffer); GLAllocation.generateTextureNames(singleIntBuffer);
@ -46,9 +37,9 @@ public class RenderEngine {
if(s.equals("/terrain.png") || s.contains("arrow") || s.contains("default")) { if(s.equals("/terrain.png") || s.contains("arrow") || s.contains("default")) {
textureBlending = true; textureBlending = true;
} }
setupTexture(readTextureImage(texturepackbase.func_6481_a(s)), i); setupTexture(readTextureImage(TextureBase.func_6481_a(s)), i);
textureBlending = false; textureBlending = false;
textureMap.put(s, Integer.valueOf(i)); // textureMap.put(s, Integer.valueOf(i));
return i; return i;
} catch (IOException ioexception) { } catch (IOException ioexception) {
throw new RuntimeException("!!"); throw new RuntimeException("!!");
@ -62,7 +53,7 @@ public class RenderEngine {
textureBlending = true; textureBlending = true;
setupTexture(bufferedimage, i); setupTexture(bufferedimage, i);
textureBlending = false; textureBlending = false;
textureNameToImageMap.put(Integer.valueOf(i), bufferedimage); //textureNameToImageMap.put(Integer.valueOf(i), bufferedimage);
return i; return i;
} }
@ -103,30 +94,13 @@ public class RenderEngine {
imageDataB1.clear(); imageDataB1.clear();
imageDataB1.put(abyte0); imageDataB1.put(abyte0);
imageDataB1.position(0).limit(abyte0.length); imageDataB1.position(0).limit(abyte0.length);
GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, 0, GL11._wGL_RGBA8 /* GL_RGBA */, j, k, 0, GL11._wGL_RGBA8 /* GL_RGBA */, GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, 0, GL11._wGL_RGBA8 /* GL_RGBA */, j, k, 0, GL11.GL_RGBA /* GL_RGBA */,
5121 /* GL_UNSIGNED_BYTE */, imageDataB1); 5121 /* GL_UNSIGNED_BYTE */, imageDataB1);
GL11.glDisable(GL11.GL_BLEND);
} }
public void deleteTexture(int i) { public void deleteTexture(int i) {
GL11.glDeleteTextures(i); GL11.glDeleteTextures(i);
} }
public int getTextureForDownloadableImage(String s, String s1) {
return getTexture("/mob/char.png");
}
public void registerTextureFX(TextureFX texturefx) {
textureList.add(texturefx);
texturefx.animate();
}
private int averageColor(int i, int j) {
int k = (i & 0xff000000) >> 24 & 0xff;
int l = (j & 0xff000000) >> 24 & 0xff;
return ((k + l >> 1) << 24) + ((i & 0xfefefe) + (j & 0xfefefe) >> 1);
}
private EaglerImage readTextureImage(byte[] inputstream) throws IOException { private EaglerImage readTextureImage(byte[] inputstream) throws IOException {
return GL11.loadPNG(inputstream); return GL11.loadPNG(inputstream);
@ -141,12 +115,8 @@ public class RenderEngine {
} }
} }
public static HashMap<String, Integer> textureMap;
private HashMap<Integer, EaglerImage> textureNameToImageMap;
private IntBuffer singleIntBuffer; private IntBuffer singleIntBuffer;
private ByteBuffer imageDataB1; private ByteBuffer imageDataB1;
private ByteBuffer imageDataB2;
private java.util.List<TextureFX> textureList;
private GameSettings options; private GameSettings options;
private boolean textureBlending; private boolean textureBlending;
} }

View File

@ -8,7 +8,7 @@ public class TextureBase {
//This overrides the default Java constructor insuring non-instability //This overrides the default Java constructor insuring non-instability
} }
public byte[] func_6481_a(String s) { public static byte[] func_6481_a(String s) {
return GL11.loadResourceBytes(s); return GL11.loadResourceBytes(s);
} }
} }

View File

@ -1,17 +0,0 @@
package com.mojang.minecraft.render.texture;
public class TextureFX
{
public TextureFX(int textureID)
{
this.textureId = textureID;
}
public byte[] textureData = new byte[1024];
public int textureId;
public boolean anaglyph = false;
public void animate()
{
}
}

View File

@ -1,87 +0,0 @@
package com.mojang.minecraft.render.texture;
import com.mojang.minecraft.level.tile.Block;
import com.mojang.minecraft.render.texture.TextureFX;
import net.PeytonPlayz585.math.MathHelper;
public final class TextureLavaFX extends TextureFX {
private float[] red = new float[256];
private float[] green = new float[256];
private float[] blue = new float[256];
private float[] alpha = new float[256];
public TextureLavaFX() {
super(Block.LAVA.textureId);
}
public final void animate() {
int var1;
int var2;
float var3;
int var5;
int var6;
int var7;
int var8;
int var9;
for(var1 = 0; var1 < 16; ++var1) {
for(var2 = 0; var2 < 16; ++var2) {
var3 = 0.0F;
int var4 = (int)(MathHelper.sin((float)var2 * 3.1415927F * 2.0F / 16.0F) * 1.2F);
var5 = (int)(MathHelper.sin((float)var1 * 3.1415927F * 2.0F / 16.0F) * 1.2F);
for(var6 = var1 - 1; var6 <= var1 + 1; ++var6) {
for(var7 = var2 - 1; var7 <= var2 + 1; ++var7) {
var8 = var6 + var4 & 15;
var9 = var7 + var5 & 15;
var3 += this.red[var8 + (var9 << 4)];
}
}
this.green[var1 + (var2 << 4)] = var3 / 10.0F + (this.blue[(var1 & 15) + ((var2 & 15) << 4)] + this.blue[(var1 + 1 & 15) + ((var2 & 15) << 4)] + this.blue[(var1 + 1 & 15) + ((var2 + 1 & 15) << 4)] + this.blue[(var1 & 15) + ((var2 + 1 & 15) << 4)]) / 4.0F * 0.8F;
this.blue[var1 + (var2 << 4)] += this.alpha[var1 + (var2 << 4)] * 0.01F;
if(this.blue[var1 + (var2 << 4)] < 0.0F) {
this.blue[var1 + (var2 << 4)] = 0.0F;
}
this.alpha[var1 + (var2 << 4)] -= 0.06F;
if(Math.random() < 0.005D) {
this.alpha[var1 + (var2 << 4)] = 1.5F;
}
}
}
float[] var10 = this.green;
this.green = this.red;
this.red = var10;
for(var2 = 0; var2 < 256; ++var2) {
if((var3 = this.red[var2] * 2.0F) > 1.0F) {
var3 = 1.0F;
}
if(var3 < 0.0F) {
var3 = 0.0F;
}
var5 = (int)(var3 * 100.0F + 155.0F);
var6 = (int)(var3 * var3 * 255.0F);
var7 = (int)(var3 * var3 * var3 * var3 * 128.0F);
if(this.anaglyph) {
var8 = (var5 * 30 + var6 * 59 + var7 * 11) / 100;
var9 = (var5 * 30 + var6 * 70) / 100;
var1 = (var5 * 30 + var7 * 70) / 100;
var5 = var8;
var6 = var9;
var7 = var1;
}
this.textureData[var2 << 2] = (byte)var5;
this.textureData[(var2 << 2) + 1] = (byte)var6;
this.textureData[(var2 << 2) + 2] = (byte)var7;
this.textureData[(var2 << 2) + 3] = -1;
}
}
}

View File

@ -1,90 +0,0 @@
package com.mojang.minecraft.render.texture;
import com.mojang.minecraft.level.tile.Block;
import com.mojang.minecraft.render.texture.TextureFX;
public final class TextureWaterFX extends TextureFX {
private float[] red = new float[256];
private float[] blue = new float[256];
private float[] green = new float[256];
private float[] alpha = new float[256];
private int updates = 0;
public TextureWaterFX() {
super(Block.WATER.textureId);
}
public final void animate() {
++this.updates;
int var1;
int var2;
float var3;
int var4;
int var5;
int var6;
for(var1 = 0; var1 < 16; ++var1) {
for(var2 = 0; var2 < 16; ++var2) {
var3 = 0.0F;
for(var4 = var1 - 1; var4 <= var1 + 1; ++var4) {
var5 = var4 & 15;
var6 = var2 & 15;
var3 += this.red[var5 + (var6 << 4)];
}
this.blue[var1 + (var2 << 4)] = var3 / 3.3F + this.green[var1 + (var2 << 4)] * 0.8F;
}
}
for(var1 = 0; var1 < 16; ++var1) {
for(var2 = 0; var2 < 16; ++var2) {
this.green[var1 + (var2 << 4)] += this.alpha[var1 + (var2 << 4)] * 0.05F;
if(this.green[var1 + (var2 << 4)] < 0.0F) {
this.green[var1 + (var2 << 4)] = 0.0F;
}
this.alpha[var1 + (var2 << 4)] -= 0.1F;
if(Math.random() < 0.05D) {
this.alpha[var1 + (var2 << 4)] = 0.5F;
}
}
}
float[] var8 = this.blue;
this.blue = this.red;
this.red = var8;
for(var2 = 0; var2 < 256; ++var2) {
if((var3 = this.red[var2]) > 1.0F) {
var3 = 1.0F;
}
if(var3 < 0.0F) {
var3 = 0.0F;
}
float var9 = var3 * var3;
var5 = (int)(32.0F + var9 * 32.0F);
var6 = (int)(50.0F + var9 * 64.0F);
var1 = 255;
int var10 = (int)(146.0F + var9 * 50.0F);
if(this.anaglyph) {
var1 = (var5 * 30 + var6 * 59 + 2805) / 100;
var4 = (var5 * 30 + var6 * 70) / 100;
int var7 = (var5 * 30 + 17850) / 100;
var5 = var1;
var6 = var4;
var1 = var7;
}
this.textureData[var2 << 2] = (byte)var5;
this.textureData[(var2 << 2) + 1] = (byte)var6;
this.textureData[(var2 << 2) + 2] = (byte)var1;
this.textureData[(var2 << 2) + 3] = (byte)var10;
}
}
}

View File

@ -111,9 +111,9 @@ public class Tessellator {
GL11.glEnableVertexAttrib(GL11.GL_COLOR_ARRAY); GL11.glEnableVertexAttrib(GL11.GL_COLOR_ARRAY);
} }
if (this.hasNormals) { // if (this.hasNormals) {
GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY); // GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY);
} // }
GL11.glDrawArrays(7, 0, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 8)); GL11.glDrawArrays(7, 0, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 8));
@ -125,9 +125,9 @@ public class Tessellator {
GL11.glDisableVertexAttrib(GL11.GL_COLOR_ARRAY); GL11.glDisableVertexAttrib(GL11.GL_COLOR_ARRAY);
} }
if (this.hasNormals) { // if (this.hasNormals) {
GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY); // GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY);
} // }
} }
int var1 = this.rawBufferIndex * 4; int var1 = this.rawBufferIndex * 4;
@ -319,9 +319,9 @@ public class Tessellator {
public void setNormal(float par1, float par2, float par3) { public void setNormal(float par1, float par2, float par3) {
this.hasNormals = true; this.hasNormals = true;
float len = (float) Math.sqrt(par1 * par1 + par2 * par2 + par3 * par3); float len = (float) Math.sqrt(par1 * par1 + par2 * par2 + par3 * par3);
int var4 = (int)((par1 / len) * 126.0F) + 126; int var4 = (int)((par1 / len) * 125.0F) + 125;
int var5 = (int)((par2 / len) * 126.0F) + 126; int var5 = (int)((par2 / len) * 125.0F) + 125;
int var6 = (int)((par3 / len) * 126.0F) + 126; int var6 = (int)((par3 / len) * 125.0F) + 125;
this.normal = var4 & 255 | (var5 & 255) << 8 | (var6 & 255) << 16; this.normal = var4 & 255 | (var5 & 255) << 8 | (var6 & 255) << 16;
} }