Rewrote Minecraft's Texture Loading

This commit is contained in:
PeytonPlayz595 2023-07-10 20:28:27 -04:00
parent ecf58c6fe3
commit bd91221da9
24 changed files with 310 additions and 303 deletions

View File

@ -8,7 +8,6 @@ import com.mojang.minecraft.level.tile.Tile$SoundType;
import com.mojang.minecraft.model.Vec3D; import com.mojang.minecraft.model.Vec3D;
import com.mojang.minecraft.net.PositionUpdate; import com.mojang.minecraft.net.PositionUpdate;
import com.mojang.minecraft.phys.AABB; import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.render.TextureManager;
import com.mojang.util.MathHelper; import com.mojang.util.MathHelper;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
@ -364,7 +363,7 @@ public abstract class Entity implements Serializable {
return this.level.getBrightness(var4, var2, var3); return this.level.getBrightness(var4, var2, var3);
} }
public void render(TextureManager var1, float var2) {} public void render(float var2) {}
public void setLevel(Level var1) { public void setLevel(Level var1) {
this.level = var1; this.level = var1;
@ -473,5 +472,5 @@ public abstract class Entity implements Serializable {
return false; return false;
} }
public void renderHover(TextureManager var1, float var2) {} public void renderHover(float var2) {}
} }

View File

@ -26,7 +26,6 @@ import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.player.InputHandlerImpl; 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.texture.TextureFX; import com.mojang.minecraft.render.texture.TextureFX;
import com.mojang.minecraft.render.texture.TextureLavaFX; import com.mojang.minecraft.render.texture.TextureLavaFX;
import com.mojang.minecraft.render.texture.TextureWaterFX; import com.mojang.minecraft.render.texture.TextureWaterFX;
@ -62,7 +61,6 @@ public final class Minecraft implements Runnable {
public String host; public String host;
public boolean levelLoaded = false; public boolean levelLoaded = false;
public volatile boolean waiting = false; public volatile boolean waiting = false;
public TextureManager textureManager;
public FontRenderer fontRenderer; public FontRenderer fontRenderer;
public GuiScreen currentScreen = null; public GuiScreen currentScreen = null;
public ProgressBarDisplay progressBar = new ProgressBarDisplay(this); public ProgressBarDisplay progressBar = new ProgressBarDisplay(this);
@ -203,13 +201,10 @@ public final class Minecraft implements Runnable {
GL11.glMatrixMode(5888); GL11.glMatrixMode(5888);
checkGLError("Startup"); checkGLError("Startup");
this.settings = new GameSettings(this); this.settings = new GameSettings(this);
this.textureManager = new TextureManager(this.settings); this.fontRenderer = new FontRenderer(this.settings, "/default.png");
this.textureManager.registerAnimation(new TextureLavaFX());
this.textureManager.registerAnimation(new TextureWaterFX());
this.fontRenderer = new FontRenderer(this.settings, "/default.png", this.textureManager);
IntBuffer var9; IntBuffer var9;
(var9 = BufferUtils.createIntBuffer(256)).clear().limit(256); (var9 = BufferUtils.createIntBuffer(256)).clear().limit(256);
this.levelRenderer = new LevelRenderer(this, this.textureManager); this.levelRenderer = new LevelRenderer(this);
Item.initModels(); Item.initModels();
Mob.modelCache = new ModelManager(); Mob.modelCache = new ModelManager();
GL11.glViewport(0, 0, this.width, this.height); GL11.glViewport(0, 0, this.width, this.height);
@ -238,7 +233,7 @@ public final class Minecraft implements Runnable {
//} //}
} }
this.particleManager = new ParticleManager(this.level, this.textureManager); this.particleManager = new ParticleManager(this.level);
// try { // try {
// var1.soundPlayer = new SoundPlayer(var1.settings); // var1.soundPlayer = new SoundPlayer(var1.settings);
@ -603,7 +598,7 @@ public final class Minecraft implements Runnable {
var82.setLighting(true); var82.setLighting(true);
Vec3D var103 = var82.getPlayerVector(var80); Vec3D var103 = var82.getPlayerVector(var80);
var89.level.blockMap.render(var103, var76, var89.textureManager, var80); var89.level.blockMap.render(var103, var76, var80);
var82.setLighting(false); var82.setLighting(false);
var82.updateFog(); var82.updateFog();
float var107 = var80; float var107 = var80;
@ -615,16 +610,18 @@ public final class Minecraft implements Runnable {
for(var83 = 0; var83 < 2; ++var83) { for(var83 = 0; var83 < 2; ++var83) {
if(var96.particles[var83].size() != 0) { if(var96.particles[var83].size() != 0) {
var110 = 0; RenderEngine r = new RenderEngine();
var110 = 0;
if(var83 == 0) { if(var83 == 0) {
var110 = var96.textureManager.load("/particles.png"); var110 = r.getTexture("/particles.png");
new TextureLocation("/particles.png").bindTexture();
} }
if(var83 == 1) { if(var83 == 1) {
var110 = var96.textureManager.load("/terrain.png"); var110 = r.getTexture("/terrain.png");
new TextureLocation("/terrain.png").bindTexture();
} }
GL11.glBindTexture(3553, var110);
ShapeRenderer var121 = ShapeRenderer.instance; ShapeRenderer var121 = ShapeRenderer.instance;
ShapeRenderer.instance.begin(); ShapeRenderer.instance.begin();
@ -636,12 +633,12 @@ public final class Minecraft implements Runnable {
} }
} }
GL11.glBindTexture(3553, var89.textureManager.load("/rock.png")); new TextureLocation("/rock.png").bindTexture();
GL11.glEnable(3553); GL11.glEnable(3553);
GL11.glCallList(var89.listId); GL11.glCallList(var89.listId);
var82.updateFog(); var82.updateFog();
var101 = var89; var101 = var89;
GL11.glBindTexture(3553, var89.textureManager.load("/clouds.png")); new TextureLocation("/clouds.png").bindTexture();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
var107 = (float)(var89.level.cloudColor >> 16 & 255) / 255.0F; var107 = (float)(var89.level.cloudColor >> 16 & 255) / 255.0F;
var29 = (float)(var89.level.cloudColor >> 8 & 255) / 255.0F; var29 = (float)(var89.level.cloudColor >> 8 & 255) / 255.0F;
@ -722,8 +719,9 @@ public final class Minecraft implements Runnable {
GL11.glColor4f(1.0F, 1.0F, 1.0F, (MathHelper.sin((float)System.currentTimeMillis() / 100.0F) * 0.2F + 0.4F) * 0.5F); GL11.glColor4f(1.0F, 1.0F, 1.0F, (MathHelper.sin((float)System.currentTimeMillis() / 100.0F) * 0.2F + 0.4F) * 0.5F);
if(var89.cracks > 0.0F) { if(var89.cracks > 0.0F) {
GL11.glBlendFunc(774, 768); GL11.glBlendFunc(774, 768);
var108 = var89.textureManager.load("/terrain.png"); RenderEngine r = new RenderEngine();
GL11.glBindTexture(3553, var108); var108 = r.getTexture("/terrain.png");
new TextureLocation("/terrain.png").bindTexture();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);
GL11.glPushMatrix(); GL11.glPushMatrix();
Block var10000 = (var114 = var89.level.getTile(var102.x, var102.y, var102.z)) > 0?Block.blocks[var114]:null; Block var10000 = (var114 = var89.level.getTile(var102.x, var102.y, var102.z)) > 0?Block.blocks[var114]:null;
@ -802,7 +800,7 @@ public final class Minecraft implements Runnable {
var82.updateFog(); var82.updateFog();
GL11.glEnable(3553); GL11.glEnable(3553);
GL11.glEnable(3042); GL11.glEnable(3042);
GL11.glBindTexture(3553, var89.textureManager.load("/water.png")); new TextureLocation("/water.png").bindTexture();
GL11.glCallList(var89.listId + 1); GL11.glCallList(var89.listId + 1);
GL11.glDisable(3042); GL11.glDisable(3042);
GL11.glEnable(3042); GL11.glEnable(3042);
@ -818,7 +816,7 @@ public final class Minecraft implements Runnable {
} }
if(var120 > 0) { if(var120 > 0) {
GL11.glBindTexture(3553, var89.textureManager.load("/terrain.png")); new TextureLocation("/terrain.png").bindTexture();
if(settings.ofFastMath) { if(settings.ofFastMath) {
GL11.glCallLists(var89.buffer_fast); GL11.glCallLists(var89.buffer_fast);
} else { } else {
@ -842,7 +840,7 @@ public final class Minecraft implements Runnable {
GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GL11.glEnable(3042); GL11.glEnable(3042);
GL11.glBlendFunc(770, 771); GL11.glBlendFunc(770, 771);
//GL11.glBindTexture(3553, var82.minecraft.textureManager.load("/rain.png")); new TextureLocation("/rain.png").bindTexture();
for(var110 = var104 - 5; var110 <= var104 + 5; ++var110) { for(var110 = var104 - 5; var110 <= var104 + 5; ++var110) {
for(var122 = var114 - 5; var122 <= var114 + 5; ++var122) { for(var122 = var114 - 5; var122 <= var114 + 5; ++var122) {
@ -882,7 +880,7 @@ public final class Minecraft implements Runnable {
} }
if(var82.entity != null) { if(var82.entity != null) {
var82.entity.renderHover(var82.minecraft.textureManager, var80); var82.entity.renderHover(var80);
} }
GL11.glClear(256); GL11.glClear(256);
@ -926,10 +924,10 @@ public final class Minecraft implements Runnable {
var34 = 0.4F; var34 = 0.4F;
GL11.glScalef(0.4F, var34, var34); GL11.glScalef(0.4F, var34, var34);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
GL11.glBindTexture(3553, var112.minecraft.textureManager.load("/terrain.png")); new TextureLocation("/terrain.png").bindTexture();
var112.block.renderPreview(var123); var112.block.renderPreview(var123);
} else { } else {
var116.bindTexture(var112.minecraft.textureManager); var116.bindTexture();
GL11.glScalef(1.0F, -1.0F, -1.0F); GL11.glScalef(1.0F, -1.0F, -1.0F);
GL11.glTranslatef(0.0F, 0.2F, 0.0F); GL11.glTranslatef(0.0F, 0.2F, 0.0F);
GL11.glRotatef(-120.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(-120.0F, 0.0F, 0.0F, 1.0F);
@ -1133,18 +1131,17 @@ public final class Minecraft implements Runnable {
++((ChatLine)var17.chat.get(var16)).time; ++((ChatLine)var17.chat.get(var16)).time;
} }
GL11.glBindTexture(3553, this.textureManager.load("/terrain.png")); new TextureLocation("/terrain.png").bindTexture();
TextureManager var19 = this.textureManager;
for(var16 = 0; var16 < var19.animations.size(); ++var16) { // for(var16 = 0; var16 < var19.animations.size(); ++var16) {
TextureFX var3; // TextureFX var3;
(var3 = (TextureFX)var19.animations.get(var16)).anaglyph = var19.settings.anaglyph; // (var3 = (TextureFX)var19.animations.get(var16)).anaglyph = var19.settings.anaglyph;
var3.animate(); // var3.animate();
var19.textureBuffer.clear(); // var19.textureBuffer.clear();
var19.textureBuffer.put(var3.textureData); // var19.textureBuffer.put(var3.textureData);
var19.textureBuffer.position(0).limit(var3.textureData.length); // var19.textureBuffer.position(0).limit(var3.textureData.length);
GL11.glTexSubImage2D(3553, 0, var3.textureId % 16 << 4, var3.textureId / 16 << 4, 16, 16, 6408, 5121, var19.textureBuffer); // GL11.glTexSubImage2D(3553, 0, var3.textureId % 16 << 4, var3.textureId / 16 << 4, 16, 16, 6408, 5121, var19.textureBuffer);
} // }
int var4; int var4;
int var8; int var8;
@ -1332,7 +1329,6 @@ public final class Minecraft implements Runnable {
} else if(var6 == PacketType.DESPAWN_PLAYER) { } else if(var6 == PacketType.DESPAWN_PLAYER) {
var5 = ((Byte)var7[0]).byteValue(); var5 = ((Byte)var7[0]).byteValue();
if(var5 >= 0 && (var33 = (NetworkPlayer)var42.players.remove(Byte.valueOf(var5))) != null) { if(var5 >= 0 && (var33 = (NetworkPlayer)var42.players.remove(Byte.valueOf(var5))) != null) {
var33.clear();
var42.minecraft.level.removeEntity(var33); var42.minecraft.level.removeEntity(var33);
} }
} else if(var6 == PacketType.CHAT_MESSAGE) { } else if(var6 == PacketType.CHAT_MESSAGE) {

View File

@ -2,7 +2,10 @@ package com.mojang.minecraft;
import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.StopGameException; import com.mojang.minecraft.StopGameException;
import com.mojang.minecraft.render.RenderEngine;
import com.mojang.minecraft.render.ShapeRenderer; import com.mojang.minecraft.render.ShapeRenderer;
import com.mojang.minecraft.render.TextureLocation;
import org.lwjgl.opengl.Display; import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -55,8 +58,9 @@ public final class ProgressBarDisplay {
int var5 = this.minecraft.height * 240 / this.minecraft.height; int var5 = this.minecraft.height * 240 / this.minecraft.height;
GL11.glClear(16640); GL11.glClear(16640);
ShapeRenderer var6 = ShapeRenderer.instance; ShapeRenderer var6 = ShapeRenderer.instance;
int var7 = this.minecraft.textureManager.load("/dirt.png"); RenderEngine r = new RenderEngine();
GL11.glBindTexture(3553, var7); int var7 = r.getTexture("/dirt.png");
new TextureLocation("/dirt.png").bindTexture();
float var10 = 32.0F; float var10 = 32.0F;
var6.begin(); var6.begin();
var6.color(4210752); var6.color(4210752);

View File

@ -29,12 +29,12 @@ public class SkinDownloadThread extends Thread
connection.connect(); connection.connect();
if(connection.getResponseCode() != 404) // if(connection.getResponseCode() != 404)
{ // {
Player.newTexture = ImageIO.read(connection.getInputStream()); // Player.newTexture = ImageIO.read(connection.getInputStream());
//
return; // return;
} // }
} catch (Exception var4) { } catch (Exception var4) {
var4.printStackTrace(); var4.printStackTrace();
} finally { } finally {

View File

@ -4,7 +4,8 @@ import com.mojang.minecraft.SessionData;
import com.mojang.minecraft.gui.GuiScreen; import com.mojang.minecraft.gui.GuiScreen;
import com.mojang.minecraft.level.tile.Block; import com.mojang.minecraft.level.tile.Block;
import com.mojang.minecraft.render.ShapeRenderer; import com.mojang.minecraft.render.ShapeRenderer;
import com.mojang.minecraft.render.TextureManager; import com.mojang.minecraft.render.TextureLocation;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public final class BlockSelectScreen extends GuiScreen { public final class BlockSelectScreen extends GuiScreen {
@ -35,10 +36,8 @@ public final class BlockSelectScreen extends GuiScreen {
} }
drawCenteredString(this.fontRenderer, "Select block", this.width / 2, 40, 16777215); drawCenteredString(this.fontRenderer, "Select block", this.width / 2, 40, 16777215);
TextureManager var7 = this.minecraft.textureManager;
ShapeRenderer var8 = ShapeRenderer.instance; ShapeRenderer var8 = ShapeRenderer.instance;
var2 = var7.load("/terrain.png"); new TextureLocation("/terrain.png").bindTexture();
GL11.glBindTexture(3553, var2);
for(var2 = 0; var2 < SessionData.allowedBlocks.size(); ++var2) { for(var2 = 0; var2 < SessionData.allowedBlocks.size(); ++var2) {
Block var4 = (Block)SessionData.allowedBlocks.get(var2); Block var4 = (Block)SessionData.allowedBlocks.get(var2);

View File

@ -2,12 +2,14 @@ package com.mojang.minecraft.gui;
import com.mojang.minecraft.GameSettings; import com.mojang.minecraft.GameSettings;
import com.mojang.minecraft.render.ShapeRenderer; import com.mojang.minecraft.render.ShapeRenderer;
import com.mojang.minecraft.render.TextureManager;
import java.awt.image.BufferedImage; import net.PeytonPlayz585.lwjgl.LWJGLUtils;
import java.io.IOException; import net.PeytonPlayz585.minecraft.MinecraftImage;
import javax.imageio.ImageIO;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import com.mojang.minecraft.render.RenderEngine;
public final class FontRenderer { public final class FontRenderer {
private int[] widthmap = new int[256]; private int[] widthmap = new int[256];
@ -15,21 +17,12 @@ public final class FontRenderer {
private GameSettings settings; private GameSettings settings;
public FontRenderer(GameSettings var1, String var2, TextureManager var3) { public FontRenderer(GameSettings var1, String var2) {
this.settings = var1; this.settings = var1;
MinecraftImage var14 = LWJGLUtils.loadPNG(GL11.loadResourceBytes(var2));
BufferedImage var14; int var4 = var14.w;
try { int var5 = var14.h;
var14 = ImageIO.read(TextureManager.class.getResourceAsStream(var2));
} catch (IOException var13) {
throw new RuntimeException(var13);
}
int var4 = var14.getWidth();
int var5 = var14.getHeight();
int[] var6 = new int[var4 * var5]; int[] var6 = new int[var4 * var5];
var14.getRGB(0, 0, var4, var5, var6, 0, var4);
for(int var15 = 0; var15 < 128; ++var15) { for(int var15 = 0; var15 < 128; ++var15) {
var5 = var15 % 16; var5 = var15 % 16;
int var7 = var15 / 16; int var7 = var15 / 16;
@ -53,8 +46,10 @@ public final class FontRenderer {
this.widthmap[var15] = var8; this.widthmap[var15] = var8;
} }
RenderEngine r = new RenderEngine();
this.fontTexture = var3.load(var2); this.fontTexture = r.getTexture(var2);
} }
public final void render(String var1, int var2, int var3, int var4) { public final void render(String var1, int var2, int var3, int var4) {

View File

@ -4,6 +4,8 @@ import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.gui.Button; import com.mojang.minecraft.gui.Button;
import com.mojang.minecraft.gui.FontRenderer; import com.mojang.minecraft.gui.FontRenderer;
import com.mojang.minecraft.gui.Screen; import com.mojang.minecraft.gui.Screen;
import com.mojang.minecraft.render.TextureLocation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
@ -27,7 +29,7 @@ public class GuiScreen extends Screen {
Button var4 = var10000; Button var4 = var10000;
if(var10000.visible) { if(var10000.visible) {
FontRenderer var8 = var7.fontRenderer; FontRenderer var8 = var7.fontRenderer;
GL11.glBindTexture(3553, var7.textureManager.load("/gui/gui.png")); new TextureLocation("/gui/gui.png").bindTexture();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
byte var9 = 1; byte var9 = 1;
boolean var6 = var1 >= var4.x && var2 >= var4.y && var1 < var4.x + var4.width && var2 < var4.y + var4.height; boolean var6 = var1 >= var4.x && var2 >= var4.y && var1 < var4.x + var4.width && var2 < var4.y + var4.height;

View File

@ -9,7 +9,7 @@ import com.mojang.minecraft.gui.Screen;
import com.mojang.minecraft.level.tile.Block; import com.mojang.minecraft.level.tile.Block;
import com.mojang.minecraft.player.Inventory; import com.mojang.minecraft.player.Inventory;
import com.mojang.minecraft.render.ShapeRenderer; import com.mojang.minecraft.render.ShapeRenderer;
import com.mojang.minecraft.render.TextureManager; import com.mojang.minecraft.render.TextureLocation;
import com.mojang.util.MathHelper; import com.mojang.util.MathHelper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -37,8 +37,7 @@ public final class HUDScreen extends Screen {
public final void render(float var1, boolean var2, int var3, int var4) { public final void render(float var1, boolean var2, int var3, int var4) {
FontRenderer var5 = this.mc.fontRenderer; FontRenderer var5 = this.mc.fontRenderer;
this.mc.renderer.enableGuiMode(); this.mc.renderer.enableGuiMode();
TextureManager var6 = this.mc.textureManager; new TextureLocation("/gui/gui.png").bindTexture();
GL11.glBindTexture(3553, this.mc.textureManager.load("/gui/gui.png"));
ShapeRenderer var7 = ShapeRenderer.instance; ShapeRenderer var7 = ShapeRenderer.instance;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(3042); GL11.glEnable(3042);
@ -46,7 +45,7 @@ public final class HUDScreen extends Screen {
this.imgZ = -90.0F; this.imgZ = -90.0F;
this.drawImage(this.width / 2 - 91, this.height - 22, 0, 0, 182, 22); this.drawImage(this.width / 2 - 91, this.height - 22, 0, 0, 182, 22);
this.drawImage(this.width / 2 - 91 - 1 + var8.selected * 20, this.height - 22 - 1, 0, 22, 24, 22); this.drawImage(this.width / 2 - 91 - 1 + var8.selected * 20, this.height - 22 - 1, 0, 22, 24, 22);
GL11.glBindTexture(3553, this.mc.textureManager.load("/gui/icons.png")); new TextureLocation("/gui/icons.png").bindTexture();
this.drawImage(this.width / 2 - 7, this.height / 2 - 7, 0, 0, 16, 16); this.drawImage(this.width / 2 - 7, this.height / 2 - 7, 0, 0, 16, 16);
boolean var9 = this.mc.player.invulnerableTime / 3 % 2 == 1; boolean var9 = this.mc.player.invulnerableTime / 3 % 2 == 1;
if(this.mc.player.invulnerableTime < 10) { if(this.mc.player.invulnerableTime < 10) {
@ -132,8 +131,7 @@ public final class HUDScreen extends Screen {
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-1.5F, 0.5F, 0.5F); GL11.glTranslatef(-1.5F, 0.5F, 0.5F);
GL11.glScalef(-1.0F, -1.0F, -1.0F); GL11.glScalef(-1.0F, -1.0F, -1.0F);
int var20 = var6.load("/terrain.png"); new TextureLocation("/terrain.png").bindTexture();
GL11.glBindTexture(3553, var20);
var7.begin(); var7.begin();
Block.blocks[var15].renderFullbright(var7); Block.blocks[var15].renderFullbright(var7);
var7.end(); var7.end();

View File

@ -5,7 +5,7 @@ import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.phys.AABB; import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.player.Player; import com.mojang.minecraft.player.Player;
import com.mojang.minecraft.render.ShapeRenderer; import com.mojang.minecraft.render.ShapeRenderer;
import com.mojang.minecraft.render.TextureManager; import com.mojang.minecraft.render.TextureLocation;
import com.mojang.util.MathHelper; import com.mojang.util.MathHelper;
import java.util.List; import java.util.List;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -176,11 +176,9 @@ public class Arrow extends Entity
} }
@Override @Override
public void render(TextureManager textureManager, float unknown0) public void render(float unknown0)
{ {
textureId = textureManager.load("/item/arrows.png"); new TextureLocation("/item/arrows.png").bindTexture();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
float brightness = level.getBrightness((int)x, (int)y, (int)z); float brightness = level.getBrightness((int)x, (int)y, (int)z);

View File

@ -4,7 +4,7 @@ import com.mojang.minecraft.Entity;
import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.tile.Block; import com.mojang.minecraft.level.tile.Block;
import com.mojang.minecraft.player.Player; import com.mojang.minecraft.player.Player;
import com.mojang.minecraft.render.TextureManager; import com.mojang.minecraft.render.TextureLocation;
import com.mojang.util.MathHelper; import com.mojang.util.MathHelper;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -64,11 +64,9 @@ public class Item extends Entity
} }
@Override @Override
public void render(TextureManager textureManager, float unknown0) public void render(float unknown0)
{ {
textureId = textureManager.load("/terrain.png"); new TextureLocation("/terrain.png").bindTexture();
GL11.glBindTexture(3553, this.textureId);
float brightness = level.getBrightness((int)x, (int)y, (int)z); float brightness = level.getBrightness((int)x, (int)y, (int)z);
float unknown1 = rot + ((float)tickCount + unknown0) * 3.0F; float unknown1 = rot + ((float)tickCount + unknown0) * 3.0F;

View File

@ -7,7 +7,7 @@ import com.mojang.minecraft.particle.SmokeParticle;
import com.mojang.minecraft.particle.TerrainParticle; import com.mojang.minecraft.particle.TerrainParticle;
import com.mojang.minecraft.player.Player; import com.mojang.minecraft.player.Player;
import com.mojang.minecraft.render.ShapeRenderer; import com.mojang.minecraft.render.ShapeRenderer;
import com.mojang.minecraft.render.TextureManager; import com.mojang.minecraft.render.TextureLocation;
import com.mojang.util.MathHelper; import com.mojang.util.MathHelper;
import java.util.Random; import java.util.Random;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -97,11 +97,9 @@ public class PrimedTnt extends Entity
} }
@Override @Override
public void render(TextureManager textureManager, float unknown0) public void render(float unknown0)
{ {
int textureID = textureManager.load("/terrain.png"); new TextureLocation("/terrain.png").bindTexture();
GL11.glBindTexture(3553, textureID);
float brightness = level.getBrightness((int)x, (int)y, (int)z); float brightness = level.getBrightness((int)x, (int)y, (int)z);

View File

@ -2,7 +2,6 @@ package com.mojang.minecraft.item;
import com.mojang.minecraft.Entity; import com.mojang.minecraft.Entity;
import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.render.TextureManager;
public class TakeEntityAnim extends Entity public class TakeEntityAnim extends Entity
{ {
@ -45,9 +44,9 @@ public class TakeEntityAnim extends Entity
} }
@Override @Override
public void render(TextureManager textureManager, float unknown0) public void render(float unknown0)
{ {
item.render(textureManager, unknown0); item.render(unknown0);
} }
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@ -6,7 +6,6 @@ import com.mojang.minecraft.level.SyntheticClass;
import com.mojang.minecraft.model.Vec3D; import com.mojang.minecraft.model.Vec3D;
import com.mojang.minecraft.phys.AABB; import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.render.Frustrum; import com.mojang.minecraft.render.Frustrum;
import com.mojang.minecraft.render.TextureManager;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -166,7 +165,7 @@ public class BlockMap implements Serializable {
} }
public void render(Vec3D var1, Frustrum var2, TextureManager var3, float var4) { public void render(Vec3D var1, Frustrum var2, float var4) {
for(int var5 = 0; var5 < this.width; ++var5) { for(int var5 = 0; var5 < this.width; ++var5) {
float var6 = (float)((var5 << 4) - 2); float var6 = (float)((var5 << 4) - 2);
float var7 = (float)((var5 + 1 << 4) + 2); float var7 = (float)((var5 + 1 << 4) + 2);
@ -252,7 +251,7 @@ public class BlockMap implements Serializable {
} }
} }
var22.render(var3, var4); var22.render(var4);
} }
} }
} }

View File

@ -4,7 +4,7 @@ import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.mob.Mob; import com.mojang.minecraft.mob.Mob;
import com.mojang.minecraft.model.HumanoidModel; import com.mojang.minecraft.model.HumanoidModel;
import com.mojang.minecraft.model.Model; import com.mojang.minecraft.model.Model;
import com.mojang.minecraft.render.TextureManager; import com.mojang.minecraft.render.TextureLocation;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public class HumanoidMob extends Mob { public class HumanoidMob extends Mob {
@ -20,8 +20,8 @@ public class HumanoidMob extends Mob {
this.setPos(var2, var3, var4); this.setPos(var2, var3, var4);
} }
public void renderModel(TextureManager var1, float var2, float var3, float var4, float var5, float var6, float var7) { public void renderModel(float var2, float var3, float var4, float var5, float var6, float var7) {
super.renderModel(var1, var2, var3, var4, var5, var6, var7); super.renderModel(var2, var3, var4, var5, var6, var7);
Model var9 = modelCache.getModel(this.modelName); Model var9 = modelCache.getModel(this.modelName);
GL11.glEnable(3008); GL11.glEnable(3008);
if(this.allowAlpha) { if(this.allowAlpha) {
@ -38,7 +38,7 @@ public class HumanoidMob extends Mob {
} }
if(this.armor || this.helmet) { if(this.armor || this.helmet) {
GL11.glBindTexture(3553, var1.load("/armor/plate.png")); new TextureLocation("/armor/plate.png").bindTexture();
GL11.glDisable(2884); GL11.glDisable(2884);
HumanoidModel var8; HumanoidModel var8;
(var8 = (HumanoidModel)modelCache.getModel("humanoid.armor")).head.render = this.helmet; (var8 = (HumanoidModel)modelCache.getModel("humanoid.armor")).head.render = this.helmet;

View File

@ -5,7 +5,7 @@ import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.mob.ai.AI; import com.mojang.minecraft.mob.ai.AI;
import com.mojang.minecraft.mob.ai.BasicAI; import com.mojang.minecraft.mob.ai.BasicAI;
import com.mojang.minecraft.model.ModelManager; import com.mojang.minecraft.model.ModelManager;
import com.mojang.minecraft.render.TextureManager; import com.mojang.minecraft.render.TextureLocation;
import com.mojang.util.MathHelper; import com.mojang.util.MathHelper;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -204,12 +204,11 @@ public class Mob extends Entity {
} }
protected void bindTexture(TextureManager var1) { protected void bindTexture() {
this.textureId = var1.load(this.textureName); new TextureLocation(textureName).bindTexture();
GL11.glBindTexture(3553, this.textureId);
} }
public void render(TextureManager var1, float var2) { public void render(float var2) {
if(this.modelName != null) { if(this.modelName != null) {
float var3; float var3;
if((var3 = (float)this.attackTime - var2) < 0.0F) { if((var3 = (float)this.attackTime - var2) < 0.0F) {
@ -288,14 +287,14 @@ public class Mob extends Entity {
GL11.glScalef(-1.0F, 1.0F, 1.0F); GL11.glScalef(-1.0F, 1.0F, 1.0F);
modelCache.getModel(this.modelName).attackOffset = var3 / 5.0F; modelCache.getModel(this.modelName).attackOffset = var3 / 5.0F;
this.bindTexture(var1); this.bindTexture();
this.renderModel(var1, var8, var2, var5, var6, var7, var9); this.renderModel(var8, var2, var5, var6, var7, var9);
if(this.invulnerableTime > this.invulnerableDuration - 10) { if(this.invulnerableTime > this.invulnerableDuration - 10) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F);
GL11.glEnable(3042); GL11.glEnable(3042);
GL11.glBlendFunc(770, 1); GL11.glBlendFunc(770, 1);
this.bindTexture(var1); this.bindTexture();
this.renderModel(var1, var8, var2, var5, var6, var7, var9); this.renderModel(var8, var2, var5, var6, var7, var9);
GL11.glDisable(3042); GL11.glDisable(3042);
GL11.glBlendFunc(770, 771); GL11.glBlendFunc(770, 771);
} }
@ -310,7 +309,7 @@ public class Mob extends Entity {
} }
} }
public void renderModel(TextureManager var1, float var2, float var3, float var4, float var5, float var6, float var7) { public void renderModel(float var2, float var3, float var4, float var5, float var6, float var7) {
modelCache.getModel(this.modelName).render(var2, var4, (float)this.tickCount + var3, var5, var6, var7); modelCache.getModel(this.modelName).render(var2, var4, (float)this.tickCount + var3, var5, var6, var7);
} }

View File

@ -8,7 +8,8 @@ import com.mojang.minecraft.mob.QuadrupedMob;
import com.mojang.minecraft.mob.Sheep$1; import com.mojang.minecraft.mob.Sheep$1;
import com.mojang.minecraft.model.AnimalModel; import com.mojang.minecraft.model.AnimalModel;
import com.mojang.minecraft.player.Player; import com.mojang.minecraft.player.Player;
import com.mojang.minecraft.render.TextureManager; import com.mojang.minecraft.render.TextureLocation;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public class Sheep extends QuadrupedMob { public class Sheep extends QuadrupedMob {
@ -78,15 +79,15 @@ public class Sheep extends QuadrupedMob {
} }
} }
public void renderModel(TextureManager var1, float var2, float var3, float var4, float var5, float var6, float var7) { public void renderModel(float var2, float var3, float var4, float var5, float var6, float var7) {
AnimalModel var8; AnimalModel var8;
float var9 = (var8 = (AnimalModel)modelCache.getModel(this.modelName)).head.y; float var9 = (var8 = (AnimalModel)modelCache.getModel(this.modelName)).head.y;
float var10 = var8.head.z; float var10 = var8.head.z;
var8.head.y += (this.grazeO + (this.graze - this.grazeO) * var3) * 8.0F; var8.head.y += (this.grazeO + (this.graze - this.grazeO) * var3) * 8.0F;
var8.head.z -= this.grazeO + (this.graze - this.grazeO) * var3; var8.head.z -= this.grazeO + (this.graze - this.grazeO) * var3;
super.renderModel(var1, var2, var3, var4, var5, var6, var7); super.renderModel(var2, var3, var4, var5, var6, var7);
if(this.hasFur) { if(this.hasFur) {
GL11.glBindTexture(3553, var1.load("/mob/sheep_fur.png")); new TextureLocation("/mob/sheep_fur.png").bindTexture();
GL11.glDisable(2884); GL11.glDisable(2884);
AnimalModel var11; AnimalModel var11;
(var11 = (AnimalModel)modelCache.getModel("sheep.fur")).head.yaw = var8.head.yaw; (var11 = (AnimalModel)modelCache.getModel("sheep.fur")).head.yaw = var8.head.yaw;

View File

@ -5,7 +5,8 @@ import com.mojang.minecraft.gui.FontRenderer;
import com.mojang.minecraft.mob.HumanoidMob; import com.mojang.minecraft.mob.HumanoidMob;
import com.mojang.minecraft.net.PositionUpdate; import com.mojang.minecraft.net.PositionUpdate;
import com.mojang.minecraft.net.SkinDownloadThread; import com.mojang.minecraft.net.SkinDownloadThread;
import com.mojang.minecraft.render.TextureManager; import com.mojang.minecraft.render.TextureLocation;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -24,8 +25,6 @@ public class NetworkPlayer extends HumanoidMob {
public String name; public String name;
public String displayName; public String displayName;
int tickCount = 0; int tickCount = 0;
private TextureManager textures;
public NetworkPlayer(Minecraft var1, int var2, String var3, int var4, int var5, int var6, float var7, float var8) { public NetworkPlayer(Minecraft var1, int var2, String var3, int var4, int var5, int var6, float var7, float var8) {
super(var1.level, (float)var4, (float)var5, (float)var6); super(var1.level, (float)var4, (float)var5, (float)var6);
@ -59,42 +58,11 @@ public class NetworkPlayer extends HumanoidMob {
this.onGround = true; this.onGround = true;
} }
public void bindTexture(TextureManager var1) { public void bindTexture() {
this.textures = var1; new TextureLocation("/char.png").bindTexture();
if(this.newTexture != null) {
BufferedImage var2 = this.newTexture;
int[] var3 = new int[512];
var2.getRGB(32, 0, 32, 16, var3, 0, 32);
int var5 = 0;
boolean var10001;
while(true) {
if(var5 >= var3.length) {
var10001 = false;
break;
}
if(var3[var5] >>> 24 < 128) {
var10001 = true;
break;
}
++var5;
}
this.hasHair = var10001;
this.a = var1.load(this.newTexture);
this.newTexture = null;
}
if(this.a < 0) {
GL11.glBindTexture(3553, var1.load("/char.png"));
} else {
GL11.glBindTexture(3553, this.a);
}
} }
public void renderHover(TextureManager var1, float var2) { public void renderHover(float var2) {
FontRenderer var3 = this.minecraft.fontRenderer; FontRenderer var3 = this.minecraft.fontRenderer;
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef(this.xo + (this.x - this.xo) * var2, this.yo + (this.y - this.yo) * var2 + 0.8F + this.renderOffset, this.zo + (this.z - this.zo) * var2); GL11.glTranslatef(this.xo + (this.x - this.xo) * var2, this.yo + (this.y - this.yo) * var2 + 0.8F + this.renderOffset, this.zo + (this.z - this.zo) * var2);
@ -218,18 +186,4 @@ public class NetworkPlayer extends HumanoidMob {
this.moveQueue.add(new PositionUpdate(var3, var4)); this.moveQueue.add(new PositionUpdate(var3, var4));
this.moveQueue.add(new PositionUpdate(var1, var2)); this.moveQueue.add(new PositionUpdate(var1, var2));
} }
public void clear() {
if(this.a >= 0 && this.textures != null) {
TextureManager var10000 = this.textures;
int var1 = this.a;
TextureManager var2 = this.textures;
var10000.textureImages.remove(Integer.valueOf(var1));
var2.idBuffer.clear();
var2.idBuffer.put(var1);
var2.idBuffer.flip();
GL11.glDeleteTextures(var2.idBuffer.get());
}
}
} }

View File

@ -2,24 +2,18 @@ package com.mojang.minecraft.particle;
import com.mojang.minecraft.Entity; import com.mojang.minecraft.Entity;
import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.particle.Particle;
import com.mojang.minecraft.render.TextureManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public final class ParticleManager { public final class ParticleManager {
public List[] particles = new List[2]; public List[] particles = new List[2];
public TextureManager textureManager;
public ParticleManager(Level var1) {
public ParticleManager(Level var1, TextureManager var2) {
if(var1 != null) { if(var1 != null) {
var1.particleEngine = this; var1.particleEngine = this;
} }
this.textureManager = var2;
for(int var3 = 0; var3 < 2; ++var3) { for(int var3 = 0; var3 < 2; ++var3) {
this.particles[var3] = new ArrayList(); this.particles[var3] = new ArrayList();
} }

View File

@ -4,14 +4,12 @@ import com.mojang.minecraft.Entity;
import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.mob.Mob; import com.mojang.minecraft.mob.Mob;
import com.mojang.minecraft.model.HumanoidModel; import com.mojang.minecraft.model.HumanoidModel;
import com.mojang.minecraft.player.InputHandler; import com.mojang.minecraft.render.TextureLocation;
import com.mojang.minecraft.player.Inventory;
import com.mojang.minecraft.player.Player$1;
import com.mojang.minecraft.render.TextureManager;
import com.mojang.util.MathHelper; import com.mojang.util.MathHelper;
import java.awt.image.BufferedImage;
import net.PeytonPlayz585.minecraft.MinecraftImage;
import java.util.List; import java.util.List;
import org.lwjgl.opengl.GL11;
public class Player extends Mob { public class Player extends Mob {
@ -26,7 +24,7 @@ public class Player extends Mob {
public int score = 0; public int score = 0;
public int arrows = 20; public int arrows = 20;
private static int newTextureId = -1; private static int newTextureId = -1;
public static BufferedImage newTexture; public static MinecraftImage newTexture;
public Player(Level var1) { public Player(Level var1) {
@ -86,7 +84,7 @@ public class Player extends Mob {
} }
public void render(TextureManager var1, float var2) {} public void render(float var2) {}
public void releaseAllKeys() { public void releaseAllKeys() {
this.input.resetKeys(); this.input.resetKeys();
@ -132,20 +130,8 @@ public class Player extends Mob {
return true; return true;
} }
public void bindTexture(TextureManager var1) { public void bindTexture() {
if(newTexture != null) { new TextureLocation("/char.png").bindTexture();
newTextureId = var1.load(newTexture);
newTexture = null;
}
int var2;
if(newTextureId < 0) {
var2 = var1.load("/char.png");
GL11.glBindTexture(3553, var2);
} else {
var2 = newTextureId;
GL11.glBindTexture(3553, var2);
}
} }
public void hurt(Entity var1, int var2) { public void hurt(Entity var1, int var2) {

View File

@ -3,10 +3,6 @@ package com.mojang.minecraft.render;
import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.Level; import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.player.Player; import com.mojang.minecraft.player.Player;
import com.mojang.minecraft.render.Chunk;
import com.mojang.minecraft.render.ChunkDistanceComparator;
import com.mojang.minecraft.render.ShapeRenderer;
import com.mojang.minecraft.render.TextureManager;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -17,11 +13,10 @@ import org.lwjgl.opengl.GL11;
public final class LevelRenderer { public final class LevelRenderer {
public Level level; public Level level;
public TextureManager textureManager;
public int listId; public int listId;
public IntBuffer buffer = BufferUtils.createIntBuffer(65536); public IntBuffer buffer = BufferUtils.createIntBuffer(65536);
public IntBuffer buffer_fast = BufferUtils.createIntBuffer(4096); public IntBuffer buffer_fast = BufferUtils.createIntBuffer(4096);
public List chunks = new ArrayList(); public List<Chunk> chunks = new ArrayList<Chunk>();
private Chunk[] loadQueue; private Chunk[] loadQueue;
public Chunk[] chunkCache; public Chunk[] chunkCache;
private int xChunks; private int xChunks;
@ -37,9 +32,8 @@ public final class LevelRenderer {
public float cracks; public float cracks;
public LevelRenderer(Minecraft var1, TextureManager var2) { public LevelRenderer(Minecraft var1) {
this.minecraft = var1; this.minecraft = var1;
this.textureManager = var2;
this.listId = GL11.glGenLists(2); this.listId = GL11.glGenLists(2);
this.baseListId = GL11.glGenLists(4096 << 6 << 1); this.baseListId = GL11.glGenLists(4096 << 6 << 1);
} }
@ -201,7 +195,7 @@ 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) {
GL11.glBindTexture(3553, this.textureManager.load("/terrain.png")); new TextureLocation("/terrain.png").bindTexture();
GL11.glCallLists(this.buffer); GL11.glCallLists(this.buffer);
} }
@ -211,7 +205,7 @@ public final class LevelRenderer {
this.buffer_fast.put(this.chunkDataCache, 0, var6); this.buffer_fast.put(this.chunkDataCache, 0, var6);
this.buffer_fast.flip(); this.buffer_fast.flip();
if(this.buffer_fast.remaining() > 0) { if(this.buffer_fast.remaining() > 0) {
GL11.glBindTexture(3553, this.textureManager.load("/terrain.png")); new TextureLocation("/terrain.png").bindTexture();
GL11.glCallLists(this.buffer_fast); GL11.glCallLists(this.buffer_fast);
} }

View File

@ -0,0 +1,136 @@
package com.mojang.minecraft.render;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.HashMap;
import org.lwjgl.opengl.GL11;
import com.mojang.minecraft.GameSettings;
import com.mojang.minecraft.render.texture.TextureFX;
import net.PeytonPlayz585.lwjgl.LWJGLUtils;
import net.PeytonPlayz585.minecraft.GLAllocation;
import net.PeytonPlayz585.minecraft.MinecraftImage;
public class RenderEngine {
public int getTexture(String s) {
TextureBase texturebase = new TextureBase();
Integer integer = (Integer) textureMap.get(s);
if (integer != null) {
return integer.intValue();
}
try {
singleIntBuffer.clear();
GLAllocation.generateTextureNames(singleIntBuffer);
int i = singleIntBuffer.get(0);
if(s.equals("/terrain.png")) {
useMipmaps = true;
}
setupTexture(readTextureImage(texturebase.func_6481_a(s)), i);
useMipmaps = false;
textureMap.put(s, Integer.valueOf(i));
return i;
} catch (IOException ioexception) {
throw new RuntimeException("!!");
}
}
public void setupTexture(MinecraftImage bufferedimage, int i) {
bindTexture(i);
if (useMipmaps) {
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, GL11.GL_NEAREST_MIPMAP_LINEAR);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, GL11.GL_NEAREST /* GL_LINEAR */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, GL11.GL_TEXTURE_MAX_LEVEL, 4);
} else {
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, 9728 /* GL_NEAREST */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, 9728 /* GL_NEAREST */);
}
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10242 /* GL_TEXTURE_WRAP_S */, 10497 /* GL_REPEAT */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10243 /* GL_TEXTURE_WRAP_T */, 10497 /* GL_REPEAT */);
int j = bufferedimage.w;
int k = bufferedimage.h;
int ai[] = bufferedimage.data;
byte abyte0[] = new byte[j * k * 4];
for (int l = 0; l < ai.length; l++) {
int j1 = ai[l] >> 24 & 0xff;
int l1 = ai[l] >> 16 & 0xff;
int j2 = ai[l] >> 8 & 0xff;
int l2 = ai[l] >> 0 & 0xff;
if (options != null && options.anaglyph) {
int j3 = (l1 * 30 + j2 * 59 + l2 * 11) / 100;
int l3 = (l1 * 30 + j2 * 70) / 100;
int j4 = (l1 * 30 + l2 * 70) / 100;
l1 = j3;
j2 = l3;
l2 = j4;
}
abyte0[l * 4 + 0] = (byte) l1;
abyte0[l * 4 + 1] = (byte) j2;
abyte0[l * 4 + 2] = (byte) l2;
abyte0[l * 4 + 3] = (byte) j1;
}
imageDataB1.clear();
imageDataB1.put(abyte0);
imageDataB1.position(0).limit(abyte0.length);
GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, 0, 6408 /* GL_RGBA */, j, k, 0, 6408 /* GL_RGBA */,
5121 /* GL_UNSIGNED_BYTE */, imageDataB1);
if (useMipmaps) {
for (int i1 = 1; i1 <= 4; i1++) {
int k1 = j >> i1 - 1;
int i2 = j >> i1;
int k2 = k >> i1;
imageDataB2.clear();
for (int i3 = 0; i3 < i2; i3++) {
for (int k3 = 0; k3 < k2; k3++) {
int i4 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 0) * k1) * 4);
int k4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 0) * k1) * 4);
int l4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 1) * k1) * 4);
int i5 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 1) * k1) * 4);
int j5 = averageColor(averageColor(i4, k4), averageColor(l4, i5));
imageDataB2.putInt((i3 + k3 * i2) * 4, j5);
}
}
GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, i1, 6408 /* GL_RGBA */, i2, k2, 0, 6408 /* GL_RGBA */,
5121 /* GL_UNSIGNED_BYTE */, imageDataB2);
ByteBuffer tmp = imageDataB1;
imageDataB1 = imageDataB2;
imageDataB2 = tmp;
}
}
}
public void bindTexture(int i) {
if (i < 0) {
return;
} else {
GL11.glBindTexture(3553 /* GL_TEXTURE_2D */, i);
return;
}
}
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 MinecraftImage readTextureImage(byte[] inputstream) throws IOException {
return LWJGLUtils.loadPNG(inputstream);
}
public static boolean useMipmaps = false;
private HashMap textureMap;
private HashMap textureNameToImageMap;
private IntBuffer singleIntBuffer;
private ByteBuffer imageDataB1;
private ByteBuffer imageDataB2;
private java.util.List<TextureFX> textureList;
private GameSettings options;
}

View File

@ -0,0 +1,14 @@
package com.mojang.minecraft.render;
import org.lwjgl.opengl.GL11;
public class TextureBase {
public TextureBase() {
//This overrides the default Java constructor insuring non-instability
}
public byte[] func_6481_a(String s) {
return GL11.loadResourceBytes(s);
}
}

View File

@ -0,0 +1,43 @@
package com.mojang.minecraft.render;
import java.util.ArrayList;
public class TextureLocation {
private String path;
private int glObject;
public TextureLocation(String path) {
this.path = path;
this.glObject = -1;
locations.add(this);
}
public static void freeTextures() {
for (TextureLocation l : locations) {
l.glObject = -1;
}
}
public int getTexturePointer() {
RenderEngine r = new RenderEngine();
if (glObject == -1) {
glObject = r.getTexture(path);
if (glObject == -1) {
System.err.println("could not load: " + path);
}
}
return glObject;
}
public void bindTexture() {
RenderEngine r = new RenderEngine();
int i = getTexturePointer();
if(i != -1) {
r.bindTexture(i);
}
}
private static final ArrayList<TextureLocation> locations = new ArrayList();
}

View File

@ -1,99 +0,0 @@
package com.mojang.minecraft.render;
import com.mojang.minecraft.GameSettings;
import com.mojang.minecraft.render.texture.TextureFX;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.imageio.ImageIO;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
public class TextureManager {
public HashMap textures = new HashMap();
public HashMap textureImages = new HashMap();
public IntBuffer idBuffer = BufferUtils.createIntBuffer(1);
public ByteBuffer textureBuffer = BufferUtils.createByteBuffer(262144);
public List animations = new ArrayList();
public GameSettings settings;
public TextureManager(GameSettings var1) {
this.settings = var1;
}
public final int load(String var1) {
Integer var2;
if((var2 = (Integer)this.textures.get(var1)) != null) {
return var2.intValue();
} else {
try {
this.idBuffer.clear();
GL11.glGenTextures(this.idBuffer);
int var4 = this.idBuffer.get(0);
this.load(ImageIO.read(TextureManager.class.getResourceAsStream(var1)), var4);
this.textures.put(var1, Integer.valueOf(var4));
return var4;
} catch (IOException var3) {
throw new RuntimeException("!!");
}
}
}
public final int load(BufferedImage var1) {
this.idBuffer.clear();
GL11.glGenTextures(this.idBuffer);
int var2 = this.idBuffer.get(0);
this.load(var1, var2);
this.textureImages.put(Integer.valueOf(var2), var1);
return var2;
}
public void load(BufferedImage var1, int var2) {
GL11.glBindTexture(3553, var2);
GL11.glTexParameteri(3553, 10241, 9728);
GL11.glTexParameteri(3553, 10240, 9728);
var2 = var1.getWidth();
int var3 = var1.getHeight();
int[] var4 = new int[var2 * var3];
byte[] var5 = new byte[var2 * var3 << 2];
var1.getRGB(0, 0, var2, var3, var4, 0, var2);
for(int var11 = 0; var11 < var4.length; ++var11) {
int var6 = var4[var11] >>> 24;
int var7 = var4[var11] >> 16 & 255;
int var8 = var4[var11] >> 8 & 255;
int var9 = var4[var11] & 255;
if(this.settings.anaglyph) {
int var10 = (var7 * 30 + var8 * 59 + var9 * 11) / 100;
var8 = (var7 * 30 + var8 * 70) / 100;
var9 = (var7 * 30 + var9 * 70) / 100;
var7 = var10;
var8 = var8;
var9 = var9;
}
var5[var11 << 2] = (byte)var7;
var5[(var11 << 2) + 1] = (byte)var8;
var5[(var11 << 2) + 2] = (byte)var9;
var5[(var11 << 2) + 3] = (byte)var6;
}
this.textureBuffer.clear();
this.textureBuffer.put(var5);
this.textureBuffer.position(0).limit(var5.length);
GL11.glTexImage2D(3553, 0, 6408, var2, var3, 0, 6408, 5121, this.textureBuffer);
}
public final void registerAnimation(TextureFX var1) {
this.animations.add(var1);
var1.animate();
}
}