Update (Some) code

This commit is contained in:
PeytonPlayz595 2023-10-10 23:02:34 +00:00
parent b561cc0528
commit 5e4915809e
32 changed files with 509 additions and 1576 deletions

View File

@ -1,6 +1,5 @@
package com.mojang.minecraft; package com.mojang.minecraft;
import com.mojang.comm.SocketConnection;
import com.mojang.minecraft.character.Vec3; import com.mojang.minecraft.character.Vec3;
import com.mojang.minecraft.character.Zombie; import com.mojang.minecraft.character.Zombie;
import com.mojang.minecraft.character.ZombieModel; import com.mojang.minecraft.character.ZombieModel;
@ -16,9 +15,6 @@ import com.mojang.minecraft.level.LevelIO;
import com.mojang.minecraft.level.levelgen.LevelGen; import com.mojang.minecraft.level.levelgen.LevelGen;
import com.mojang.minecraft.level.liquid.Liquid; import com.mojang.minecraft.level.liquid.Liquid;
import com.mojang.minecraft.level.tile.Tile; import com.mojang.minecraft.level.tile.Tile;
import com.mojang.minecraft.net.ConnectionManager;
import com.mojang.minecraft.net.NetworkPlayer;
import com.mojang.minecraft.net.Packet;
import com.mojang.minecraft.particle.ParticleEngine; import com.mojang.minecraft.particle.ParticleEngine;
import com.mojang.minecraft.phys.AABB; import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.player.Inventory; import com.mojang.minecraft.player.Inventory;
@ -33,14 +29,6 @@ import com.mojang.minecraft.renderer.Textures;
import com.mojang.minecraft.renderer.texture.TextureFX; import com.mojang.minecraft.renderer.texture.TextureFX;
import com.mojang.minecraft.renderer.texture.TextureLavaFX; import com.mojang.minecraft.renderer.texture.TextureLavaFX;
import com.mojang.minecraft.renderer.texture.TextureWaterFX; import com.mojang.minecraft.renderer.texture.TextureWaterFX;
import com.mojang.minecraft.sound.SoundManager;
import com.mojang.minecraft.sound.SoundPlayer;
import java.awt.AWTException;
import java.awt.Canvas;
import java.awt.Component;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Robot;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
@ -51,19 +39,11 @@ import java.nio.ByteBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.util.Iterator; import java.util.Iterator;
import java.util.TreeSet; import java.util.TreeSet;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.swing.JOptionPane;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Controllers;
import org.lwjgl.input.Cursor;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display; import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.GLU;
public final class Minecraft implements Runnable { public final class Minecraft implements Runnable {
private boolean fullscreen = false; private boolean fullscreen = false;
@ -76,10 +56,8 @@ public final class Minecraft implements Runnable {
public ParticleEngine particleEngine; public ParticleEngine particleEngine;
public User user = null; public User user = null;
public String minecraftUri; public String minecraftUri;
public Canvas parent;
public boolean appletMode = false; public boolean appletMode = false;
public volatile boolean pause = false; public volatile boolean pause = false;
private Cursor emptyCursor;
public Textures textures; public Textures textures;
public Font font; public Font font;
public int editMode = 0; public int editMode = 0;
@ -88,7 +66,6 @@ public final class Minecraft implements Runnable {
public RenderHelper renderHelper = new RenderHelper(this); public RenderHelper renderHelper = new RenderHelper(this);
public LevelIO levelIo = new LevelIO(this.loadingScreen); public LevelIO levelIo = new LevelIO(this.loadingScreen);
private LevelGen levelGen = new LevelGen(this.loadingScreen); private LevelGen levelGen = new LevelGen(this.loadingScreen);
public SoundManager soundManager = new SoundManager();
private BackgroundDownloader backgroundDownloader; private BackgroundDownloader backgroundDownloader;
private int ticksRan = 0; private int ticksRan = 0;
public String loadMapUser = null; public String loadMapUser = null;
@ -97,8 +74,6 @@ public final class Minecraft implements Runnable {
public InGameHud hud; public InGameHud hud;
public boolean hideGui = false; public boolean hideGui = false;
public ZombieModel playerModel = new ZombieModel(); public ZombieModel playerModel = new ZombieModel();
public ConnectionManager connectionManager;
public SoundPlayer soundPlayer;
public HitResult hitResult = null; public HitResult hitResult = null;
public Options options; public Options options;
String server = null; String server = null;
@ -108,24 +83,14 @@ public final class Minecraft implements Runnable {
public boolean mouseGrabbed = false; public boolean mouseGrabbed = false;
private int prevFrameTime = 0; private int prevFrameTime = 0;
public Minecraft(Canvas var1, int var2, int var3, boolean var4) { public Minecraft(int var2, int var3, boolean var4) {
new SleepThread(this); new SleepThread(this);
this.parent = var1; this.parent = var1;
this.width = var2; this.width = var2;
this.height = var3; this.height = var3;
this.fullscreen = false;
this.textures = new Textures(); this.textures = new Textures();
this.textures.registerTextureFX(new TextureLavaFX()); this.textures.registerTextureFX(new TextureLavaFX());
this.textures.registerTextureFX(new TextureWaterFX()); this.textures.registerTextureFX(new TextureWaterFX());
if(var1 != null) {
try {
this.robot = new Robot();
return;
} catch (AWTException var5) {
var5.printStackTrace();
}
}
} }
public final void setScreen(Screen var1) { public final void setScreen(Screen var1) {
@ -139,16 +104,8 @@ public final class Minecraft implements Runnable {
if(this.mouseGrabbed) { if(this.mouseGrabbed) {
this.player.releaseAllKeys(); this.player.releaseAllKeys();
this.mouseGrabbed = false; this.mouseGrabbed = false;
if(this.appletMode) {
try {
Mouse.setNativeCursor((Cursor)null);
} catch (LWJGLException var4) {
var4.printStackTrace();
}
} else {
Mouse.setGrabbed(false); Mouse.setGrabbed(false);
} }
}
int var2 = this.width * 240 / this.height; int var2 = this.width * 240 / this.height;
int var3 = this.height * 240 / this.height; int var3 = this.height * 240 / this.height;
@ -163,29 +120,17 @@ public final class Minecraft implements Runnable {
private static void checkGlError(String var0) { private static void checkGlError(String var0) {
int var1 = GL11.glGetError(); int var1 = GL11.glGetError();
if(var1 != 0) { if(var1 != 0) {
String var2 = GLU.gluErrorString(var1); String var2 = GL11.gluErrorString(var1);
System.out.println("########## GL ERROR ##########"); System.out.println("########## GL ERROR ##########");
System.out.println("@ " + var0); System.out.println("@ " + var0);
System.out.println(var1 + ": " + var2); System.out.println(var1 + ": " + var2);
System.exit(0); Exception e = new Exception(var0);
e.printStackTrace();
} }
} }
public final void destroy() { public final void destroy() {
try {
if(this.soundPlayer != null) {
SoundPlayer var1 = this.soundPlayer;
var1.running = false;
}
if(this.backgroundDownloader != null) {
BackgroundDownloader var4 = this.backgroundDownloader;
var4.closing = true;
}
} catch (Exception var3) {
}
Minecraft var5 = this; Minecraft var5 = this;
if(!this.appletMode) { if(!this.appletMode) {
try { try {
@ -194,50 +139,13 @@ public final class Minecraft implements Runnable {
var2.printStackTrace(); var2.printStackTrace();
} }
} }
Mouse.destroy();
Keyboard.destroy();
Display.destroy();
} }
public final void run() { public final void run() {
this.running = true; this.running = true;
try {
Minecraft var4 = this;
if(this.parent != null) {
Display.setParent(this.parent);
} else if(this.fullscreen) {
Display.setFullscreen(true); Display.setFullscreen(true);
this.width = Display.getDisplayMode().getWidth(); this.width = Display.getWidth();
this.height = Display.getDisplayMode().getHeight(); this.height = Display.getHeight();
} else {
Display.setDisplayMode(new DisplayMode(this.width, this.height));
}
Display.setTitle("Minecraft 0.0.23a_01");
try {
Display.create();
} catch (LWJGLException var38) {
var38.printStackTrace();
try {
Thread.sleep(1000L);
} catch (InterruptedException var37) {
}
Display.create();
}
Keyboard.create();
Mouse.create();
try {
Controllers.create();
} catch (Exception var36) {
var36.printStackTrace();
}
checkGlError("Pre startup"); checkGlError("Pre startup");
GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_TEXTURE_2D);
@ -256,9 +164,7 @@ public final class Minecraft implements Runnable {
IntBuffer var7 = BufferUtils.createIntBuffer(256); IntBuffer var7 = BufferUtils.createIntBuffer(256);
var7.clear().limit(256); var7.clear().limit(256);
GL11.glViewport(0, 0, this.width, this.height); GL11.glViewport(0, 0, this.width, this.height);
if(this.server != null && this.user != null) {
this.level = null;
} else {
boolean var8 = false; boolean var8 = false;
try { try {
@ -285,7 +191,6 @@ public final class Minecraft implements Runnable {
if(!var8) { if(!var8) {
this.generateLevel(1); this.generateLevel(1);
} }
}
this.levelRenderer = new LevelRenderer(this.textures); this.levelRenderer = new LevelRenderer(this.textures);
this.particleEngine = new ParticleEngine(this.level, this.textures); this.particleEngine = new ParticleEngine(this.level, this.textures);
@ -326,48 +231,8 @@ public final class Minecraft implements Runnable {
this.setLevel(this.level); this.setLevel(this.level);
} }
if(this.appletMode) {
try {
var4.emptyCursor = new Cursor(16, 16, 0, 0, 1, var7, (IntBuffer)null);
} catch (LWJGLException var34) {
var34.printStackTrace();
}
}
try {
var4.soundPlayer = new SoundPlayer(var4.options);
SoundPlayer var10 = var4.soundPlayer;
try {
AudioFormat var58 = new AudioFormat(44100.0F, 16, 2, true, true);
var10.dataLine = AudioSystem.getSourceDataLine(var58);
var10.dataLine.open(var58, 4410);
var10.dataLine.start();
var10.running = true;
Thread var63 = new Thread(var10);
var63.setDaemon(true);
var63.setPriority(10);
var63.start();
} catch (Exception var32) {
var32.printStackTrace();
var10.running = false;
}
var4.backgroundDownloader = new BackgroundDownloader(var52, var4);
var4.backgroundDownloader.start();
} catch (Exception var33) {
}
checkGlError("Post startup"); checkGlError("Post startup");
this.hud = new InGameHud(this, this.width, this.height); this.hud = new InGameHud(this, this.width, this.height);
if(this.server != null && this.user != null) {
this.connectionManager = new ConnectionManager(this, this.server, this.port, this.user.name, this.user.mpPass);
}
} catch (Exception var43) {
var43.printStackTrace();
JOptionPane.showMessageDialog((Component)null, var43.toString(), "Failed to start Minecraft", 0);
return;
}
long var1 = System.currentTimeMillis(); long var1 = System.currentTimeMillis();
int var3 = 0; int var3 = 0;

View File

@ -35,14 +35,17 @@ public class Gui {
float var13 = (float)(var5 & 255) / 255.0F; float var13 = (float)(var5 & 255) / 255.0F;
GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glBegin(GL11.GL_QUADS);
GL11.glColor4f(var7, var8, var12, var6); Tesselator tesselator = Tesselator.instance;
GL11.glVertex2f((float)var2, (float)var1); tesselator.begin(GL11.GL_QUADS);
GL11.glVertex2f((float)var0, (float)var1); tesselator.setColorRGBA_F(var7, var8, var12, var6);
GL11.glColor4f(var10, var11, var13, var9); tesselator.vertex((float)var2, (float)var1);
GL11.glVertex2f((float)var0, (float)var3); tesselator.vertex((float)var0, (float)var1);
GL11.glVertex2f((float)var2, (float)var3); tesselator.setColorRGBA_F(var10, var11, var13, var9);
tesselator.vertex((float)var0, (float)var3);
tesselator.vertex((float)var2, (float)var3);
GL11.glEnd(); GL11.glEnd();
GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_BLEND);
} }

View File

@ -1,43 +0,0 @@
package com.mojang.minecraft.net;
import com.mojang.comm.SocketConnection;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.gui.ErrorScreen;
import java.io.ByteArrayOutputStream;
import java.util.HashMap;
public final class ConnectionManager {
public ByteArrayOutputStream levelBuffer;
public SocketConnection connection;
public Minecraft minecraft;
public boolean processData = false;
public boolean connected = false;
public HashMap players = new HashMap();
public ConnectionManager(Minecraft var1, String var2, int var3, String var4, String var5) {
var1.hideGui = true;
this.minecraft = var1;
(new ConnectionThread(this, var2, var3, var4, var5, var1)).start();
}
public final void sendBlockChange(int var1, int var2, int var3, int var4, int var5) {
this.connection.sendPacket(Packet.PLACE_OR_REMOVE_TILE, new Object[]{Integer.valueOf(var1), Integer.valueOf(var2), Integer.valueOf(var3), Integer.valueOf(var4), Integer.valueOf(var5)});
}
public final void disconnect(Exception var1) {
this.connection.disconnect();
this.minecraft.setScreen(new ErrorScreen("Disconnected!", var1.getMessage()));
var1.printStackTrace();
}
public final boolean isConnected() {
if(this.connection != null) {
SocketConnection var1 = this.connection;
if(var1.connected) {
return true;
}
}
return false;
}
}

View File

@ -1,51 +0,0 @@
package com.mojang.minecraft.net;
import com.mojang.comm.SocketConnection;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.gui.ErrorScreen;
import java.io.IOException;
final class ConnectionThread extends Thread {
private String ip;
private int port;
private String username;
private String mpPass;
private Minecraft e;
private ConnectionManager connectionManager;
ConnectionThread(ConnectionManager var1, String var2, int var3, String var4, String var5, Minecraft var6) {
this.connectionManager = var1;
this.ip = var2;
this.port = var3;
this.username = var4;
this.mpPass = var5;
this.e = var6;
}
public final void run() {
ConnectionManager var1;
boolean var2;
try {
ConnectionManager var10000 = this.connectionManager;
SocketConnection var5 = new SocketConnection(this.ip, this.port);
var1 = var10000;
var1.connection = var5;
var1 = this.connectionManager;
ConnectionManager var6 = this.connectionManager;
SocketConnection var4 = var1.connection;
var4.manager = var6;
var1 = this.connectionManager;
var1.connection.sendPacket(Packet.LOGIN, new Object[]{Byte.valueOf((byte)6), this.username, this.mpPass, Integer.valueOf(0)});
var2 = true;
var1 = this.connectionManager;
var1.processData = var2;
} catch (IOException var3) {
this.e.hideGui = false;
this.e.connectionManager = null;
this.e.setScreen(new ErrorScreen("Failed to connect", "You failed to connect to the server. It\'s probably down!"));
var2 = false;
var1 = this.connectionManager;
var1.processData = var2;
}
}
}

View File

@ -1,320 +0,0 @@
package com.mojang.minecraft.net;
import com.mojang.minecraft.Entity;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.character.ZombieModel;
import com.mojang.minecraft.gui.Font;
import com.mojang.minecraft.renderer.Textures;
import java.awt.image.BufferedImage;
import java.util.LinkedList;
import java.util.List;
import org.lwjgl.opengl.GL11;
public class NetworkPlayer extends Entity {
public static final long serialVersionUID = 77479605454997290L;
private ZombieModel zombieModel;
private float animStep;
private float animStepO;
private List moveQueue = new LinkedList();
private Minecraft minecraft;
private int xp;
private int yp;
private int zp;
private float yBodyRot = 0.0F;
private float yBodyRotO = 0.0F;
private float oRun;
private float run;
private transient int skin = -1;
public transient BufferedImage newTexture = null;
public String name;
public String displayName;
int tickCount = 0;
private Textures textures;
public NetworkPlayer(Minecraft var1, int var2, String var3, int var4, int var5, int var6, float var7, float var8) {
super(var1.level);
this.minecraft = var1;
this.zombieModel = var1.playerModel;
this.displayName = var3;
var3 = Font.removeColorCodes(var3);
this.name = var3;
this.xp = var4;
this.yp = var5;
this.zp = var6;
this.setPos((float)var4 / 32.0F, (float)var5 / 32.0F, (float)var6 / 32.0F);
this.xRot = var8;
this.yRot = var7;
(new NetworkSkinDownloadThread(this)).start();
}
public void tick() {
super.tick();
this.animStepO = this.animStep;
this.yBodyRotO = this.yBodyRot;
this.yRotO = this.yRot;
this.xRotO = this.xRot;
++this.tickCount;
int var1 = 5;
do {
if(this.moveQueue.size() > 0) {
this.setPos((PlayerMove)this.moveQueue.remove(0));
}
} while(var1-- > 0 && this.moveQueue.size() > 10);
float var7 = this.x - this.xo;
float var2 = this.z - this.zo;
float var3 = (float)Math.sqrt((double)(var7 * var7 + var2 * var2));
float var4 = this.yBodyRot;
float var5 = 0.0F;
this.oRun = this.run;
float var6 = 0.0F;
if(var3 != 0.0F) {
var6 = 1.0F;
var5 = var3 * 3.0F;
var4 = -((float)Math.atan2((double)var2, (double)var7) * 180.0F / (float)Math.PI + 90.0F);
}
this.run += (var6 - this.run) * 0.3F;
for(var7 = var4 - this.yBodyRot; var7 < -180.0F; var7 += 360.0F) {
}
while(var7 >= 180.0F) {
var7 -= 360.0F;
}
this.yBodyRot += var7 * 0.1F;
for(var7 = this.yRot - this.yBodyRot; var7 < -180.0F; var7 += 360.0F) {
}
while(var7 >= 180.0F) {
var7 -= 360.0F;
}
boolean var8 = var7 < -90.0F || var7 >= 90.0F;
if(var7 < -75.0F) {
var7 = -75.0F;
}
if(var7 >= 75.0F) {
var7 = 75.0F;
}
this.yBodyRot = this.yRot - var7;
this.yBodyRot += var7 * 0.1F;
if(var8) {
var5 = -var5;
}
while(this.yRot - this.yRotO < -180.0F) {
this.yRotO -= 360.0F;
}
while(this.yRot - this.yRotO >= 180.0F) {
this.yRotO += 360.0F;
}
while(this.yBodyRot - this.yBodyRotO < -180.0F) {
this.yBodyRotO -= 360.0F;
}
while(this.yBodyRot - this.yBodyRotO >= 180.0F) {
this.yBodyRotO += 360.0F;
}
while(this.xRot - this.xRotO < -180.0F) {
this.xRotO -= 360.0F;
}
while(this.xRot - this.xRotO >= 180.0F) {
this.xRotO += 360.0F;
}
this.animStep += var5;
}
public void render(Textures var1, float var2) {
this.textures = var1;
float var3 = this.oRun + (this.run - this.oRun) * var2;
GL11.glEnable(GL11.GL_TEXTURE_2D);
if(this.newTexture != null) {
this.skin = var1.addTexture(this.newTexture);
this.newTexture = null;
}
if(this.skin < 0) {
GL11.glBindTexture(GL11.GL_TEXTURE_2D, var1.getTextureId("/char.png"));
} else {
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.skin);
}
while(this.yBodyRotO - this.yBodyRot < -180.0F) {
this.yBodyRotO += 360.0F;
}
while(this.yBodyRotO - this.yBodyRot >= 180.0F) {
this.yBodyRotO -= 360.0F;
}
float var9;
for(var9 = this.yBodyRotO + (this.yBodyRot - this.yBodyRotO) * var2; this.xRotO - this.xRot < -180.0F; this.xRotO += 360.0F) {
}
while(this.xRotO - this.xRot >= 180.0F) {
this.xRotO -= 360.0F;
}
while(this.yRotO - this.yRot < -180.0F) {
this.yRotO += 360.0F;
}
while(this.yRotO - this.yRot >= 180.0F) {
this.yRotO -= 360.0F;
}
float var4 = this.yRotO + (this.yRot - this.yRotO) * var2;
float var5 = this.xRotO + (this.xRot - this.xRotO) * var2;
var4 = -(var4 - var9);
GL11.glPushMatrix();
float var6 = this.animStepO + (this.animStep - this.animStepO) * var2;
float var7 = this.getBrightness();
GL11.glColor3f(var7, var7, var7);
var7 = 1.0F / 16.0F;
float var8 = (float)(-Math.abs(Math.cos((double)var6 * 0.6662D)) * 5.0D * (double)var3 - 23.0D);
GL11.glTranslatef(this.xo + (this.x - this.xo) * var2, this.yo + (this.y - this.yo) * var2 - 1.62F, this.zo + (this.z - this.zo) * var2);
GL11.glScalef(1.0F, -1.0F, 1.0F);
GL11.glTranslatef(0.0F, var8 * var7, 0.0F);
GL11.glRotatef(var9, 0.0F, 1.0F, 0.0F);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glScalef(-1.0F, 1.0F, 1.0F);
this.zombieModel.render(var6, var3, (float)this.tickCount + var2, var4, var5, var7);
GL11.glEnable(GL11.GL_ALPHA_TEST);
Font var10 = this.minecraft.font;
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslatef(this.xo + (this.x - this.xo) * var2, this.yo + (this.y - this.yo) * var2 + 0.8F, this.zo + (this.z - this.zo) * var2);
GL11.glRotatef(-this.minecraft.player.yRot, 0.0F, 1.0F, 0.0F);
var2 = 0.05F;
GL11.glScalef(var2, -var2, var2);
GL11.glTranslatef((float)(-var10.width(this.displayName)) / 2.0F, 0.0F, 0.0F);
GL11.glNormal3f(1.0F, -1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_LIGHT0);
if(this.name.equalsIgnoreCase("Notch")) {
var10.draw(this.displayName, 0, 0, 16776960);
} else {
var10.draw(this.displayName, 0, 0, 16777215);
}
GL11.glEnable(GL11.GL_LIGHT0);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glTranslatef(1.0F, 1.0F, -0.05F);
var10.draw(this.name, 0, 0, 5263440);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_TEXTURE_2D);
}
public void queue(byte var1, byte var2, byte var3, float var4, float var5) {
float var6 = var4 - this.yRot;
float var7;
for(var7 = var5 - this.xRot; var6 >= 180.0F; var6 -= 360.0F) {
}
while(var6 < -180.0F) {
var6 += 360.0F;
}
while(var7 >= 180.0F) {
var7 -= 360.0F;
}
while(var7 < -180.0F) {
var7 += 360.0F;
}
var6 = this.yRot + var6 * 0.5F;
var7 = this.xRot + var7 * 0.5F;
this.moveQueue.add(new PlayerMove(((float)this.xp + (float)var1 / 2.0F) / 32.0F, ((float)this.yp + (float)var2 / 2.0F) / 32.0F, ((float)this.zp + (float)var3 / 2.0F) / 32.0F, var6, var7));
this.xp += var1;
this.yp += var2;
this.zp += var3;
this.moveQueue.add(new PlayerMove((float)this.xp / 32.0F, (float)this.yp / 32.0F, (float)this.zp / 32.0F, var4, var5));
}
public void teleport(short var1, short var2, short var3, float var4, float var5) {
float var6 = var4 - this.yRot;
float var7;
for(var7 = var5 - this.xRot; var6 >= 180.0F; var6 -= 360.0F) {
}
while(var6 < -180.0F) {
var6 += 360.0F;
}
while(var7 >= 180.0F) {
var7 -= 360.0F;
}
while(var7 < -180.0F) {
var7 += 360.0F;
}
var6 = this.yRot + var6 * 0.5F;
var7 = this.xRot + var7 * 0.5F;
this.moveQueue.add(new PlayerMove((float)(this.xp + var1) / 64.0F, (float)(this.yp + var2) / 64.0F, (float)(this.zp + var3) / 64.0F, var6, var7));
this.xp = var1;
this.yp = var2;
this.zp = var3;
this.moveQueue.add(new PlayerMove((float)this.xp / 32.0F, (float)this.yp / 32.0F, (float)this.zp / 32.0F, var4, var5));
}
public void queue(byte var1, byte var2, byte var3) {
this.moveQueue.add(new PlayerMove(((float)this.xp + (float)var1 / 2.0F) / 32.0F, ((float)this.yp + (float)var2 / 2.0F) / 32.0F, ((float)this.zp + (float)var3 / 2.0F) / 32.0F));
this.xp += var1;
this.yp += var2;
this.zp += var3;
this.moveQueue.add(new PlayerMove((float)this.xp / 32.0F, (float)this.yp / 32.0F, (float)this.zp / 32.0F));
}
public void queue(float var1, float var2) {
float var3 = var1 - this.yRot;
float var4;
for(var4 = var2 - this.xRot; var3 >= 180.0F; var3 -= 360.0F) {
}
while(var3 < -180.0F) {
var3 += 360.0F;
}
while(var4 >= 180.0F) {
var4 -= 360.0F;
}
while(var4 < -180.0F) {
var4 += 360.0F;
}
var3 = this.yRot + var3 * 0.5F;
var4 = this.xRot + var4 * 0.5F;
this.moveQueue.add(new PlayerMove(var3, var4));
this.moveQueue.add(new PlayerMove(var1, var2));
}
public void clear() {
if(this.skin >= 0) {
System.out.println("Releasing texture for " + this.name);
int var1 = this.skin;
Textures var2 = this.textures;
var2.idBuffer.clear();
var2.idBuffer.put(var1);
var2.idBuffer.flip();
GL11.glDeleteTextures(var2.idBuffer);
}
}
}

View File

@ -1,38 +0,0 @@
package com.mojang.minecraft.net;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.imageio.ImageIO;
final class NetworkSkinDownloadThread extends Thread {
private NetworkPlayer player;
NetworkSkinDownloadThread(NetworkPlayer var1) {
this.player = var1;
}
public final void run() {
HttpURLConnection var1 = null;
try {
URL var2 = new URL("http://www.minecraft.net/skin/" + this.player.name + ".png");
var1 = (HttpURLConnection)var2.openConnection();
var1.setDoInput(true);
var1.setDoOutput(false);
var1.connect();
if(var1.getResponseCode() != 404) {
System.out.println("Loading texture for " + this.player.name);
this.player.newTexture = ImageIO.read(var1.getInputStream());
return;
}
System.out.println("Failed to load texture for " + this.player.name);
return;
} catch (Exception var5) {
var5.printStackTrace();
} finally {
var1.disconnect();
}
}
}

View File

@ -1,71 +0,0 @@
package com.mojang.minecraft.net;
public final class Packet {
public static final Packet[] PACKETS = new Packet[256];
public static final Packet LOGIN = new Packet(new Class[]{Byte.TYPE, String.class, String.class, Byte.TYPE});
public static final Packet LEVEL_INITIALIZE;
public static final Packet LEVEL_DATA_CHUNK;
public static final Packet LEVEL_FINALIZE;
public static final Packet PLACE_OR_REMOVE_TILE;
public static final Packet SET_TILE;
public static final Packet PLAYER_JOIN;
public static final Packet PLAYER_TELEPORT;
public static final Packet PLAYER_MOVE_AND_ROTATE;
public static final Packet PLAYER_MOVE;
public static final Packet PLAYER_ROTATE;
public static final Packet PLAYER_DISCONNECT;
public static final Packet CHAT_MESSAGE;
public static final Packet KICK_PLAYER;
public final int size;
private static int nextId;
public final byte id = (byte)(nextId++);
public Class[] fields;
private Packet(Class... var1) {
PACKETS[this.id] = this;
this.fields = new Class[var1.length];
int var2 = 0;
for(int var3 = 0; var3 < var1.length; ++var3) {
Class var4 = var1[var3];
this.fields[var3] = var4;
if(var4 == Long.TYPE) {
var2 += 8;
} else if(var4 == Integer.TYPE) {
var2 += 4;
} else if(var4 == Short.TYPE) {
var2 += 2;
} else if(var4 == Byte.TYPE) {
++var2;
} else if(var4 == Float.TYPE) {
var2 += 4;
} else if(var4 == Double.TYPE) {
var2 += 8;
} else if(var4 == byte[].class) {
var2 += 1024;
} else if(var4 == String.class) {
var2 += 64;
}
}
this.size = var2;
}
static {
new Packet(new Class[0]);
LEVEL_INITIALIZE = new Packet(new Class[0]);
LEVEL_DATA_CHUNK = new Packet(new Class[]{Short.TYPE, byte[].class, Byte.TYPE});
LEVEL_FINALIZE = new Packet(new Class[]{Short.TYPE, Short.TYPE, Short.TYPE});
PLACE_OR_REMOVE_TILE = new Packet(new Class[]{Short.TYPE, Short.TYPE, Short.TYPE, Byte.TYPE, Byte.TYPE});
SET_TILE = new Packet(new Class[]{Short.TYPE, Short.TYPE, Short.TYPE, Byte.TYPE});
PLAYER_JOIN = new Packet(new Class[]{Byte.TYPE, String.class, Short.TYPE, Short.TYPE, Short.TYPE, Byte.TYPE, Byte.TYPE});
PLAYER_TELEPORT = new Packet(new Class[]{Byte.TYPE, Short.TYPE, Short.TYPE, Short.TYPE, Byte.TYPE, Byte.TYPE});
PLAYER_MOVE_AND_ROTATE = new Packet(new Class[]{Byte.TYPE, Byte.TYPE, Byte.TYPE, Byte.TYPE, Byte.TYPE, Byte.TYPE});
PLAYER_MOVE = new Packet(new Class[]{Byte.TYPE, Byte.TYPE, Byte.TYPE, Byte.TYPE});
PLAYER_ROTATE = new Packet(new Class[]{Byte.TYPE, Byte.TYPE, Byte.TYPE});
PLAYER_DISCONNECT = new Packet(new Class[]{Byte.TYPE});
CHAT_MESSAGE = new Packet(new Class[]{Byte.TYPE, String.class});
KICK_PLAYER = new Packet(new Class[]{String.class});
nextId = 0;
}
}

View File

@ -1,36 +0,0 @@
package com.mojang.minecraft.net;
public final class PlayerMove {
public float x;
public float y;
public float z;
public float yRot;
public float xRot;
public boolean rotating = false;
public boolean moving = false;
public PlayerMove(float var1, float var2, float var3, float var4, float var5) {
this.x = var1;
this.y = var2;
this.z = var3;
this.yRot = var4;
this.xRot = var5;
this.rotating = true;
this.moving = true;
}
public PlayerMove(float var1, float var2, float var3) {
this.x = var1;
this.y = var2;
this.z = var3;
this.moving = true;
this.rotating = false;
}
public PlayerMove(float var1, float var2) {
this.yRot = var1;
this.xRot = var2;
this.rotating = true;
this.moving = false;
}
}

View File

@ -378,30 +378,33 @@ public final class LevelRenderer {
} }
} }
GL11.glBegin(GL11.GL_LINE_STRIP); Tesselator tesselator = Tesselator.instance;
GL11.glVertex3f(var2, var3, var4); tesselator.begin(GL11.GL_LINE_STRIP);
GL11.glVertex3f(var2 + 1.0F, var3, var4); tesselator.vertex(var2, var3, var4);
GL11.glVertex3f(var2 + 1.0F, var3, var4 + 1.0F); tesselator.vertex(var2 + 1.0F, var3, var4);
GL11.glVertex3f(var2, var3, var4 + 1.0F); tesselator.vertex(var2 + 1.0F, var3, var4 + 1.0F);
GL11.glVertex3f(var2, var3, var4); tesselator.vertex(var2, var3, var4 + 1.0F);
GL11.glEnd(); tesselator.vertex(var2, var3, var4);
GL11.glBegin(GL11.GL_LINE_STRIP); tesselator.end();
GL11.glVertex3f(var2, var3 + 1.0F, var4);
GL11.glVertex3f(var2 + 1.0F, var3 + 1.0F, var4); tesselator.begin(GL11.GL_LINE_STRIP);
GL11.glVertex3f(var2 + 1.0F, var3 + 1.0F, var4 + 1.0F); tesselator.vertex(var2, var3 + 1.0F, var4);
GL11.glVertex3f(var2, var3 + 1.0F, var4 + 1.0F); tesselator.vertex(var2 + 1.0F, var3 + 1.0F, var4);
GL11.glVertex3f(var2, var3 + 1.0F, var4); tesselator.vertex(var2 + 1.0F, var3 + 1.0F, var4 + 1.0F);
GL11.glEnd(); tesselator.vertex(var2, var3 + 1.0F, var4 + 1.0F);
GL11.glBegin(GL11.GL_LINES); tesselator.vertex(var2, var3 + 1.0F, var4);
GL11.glVertex3f(var2, var3, var4); tesselator.end();
GL11.glVertex3f(var2, var3 + 1.0F, var4);
GL11.glVertex3f(var2 + 1.0F, var3, var4); tesselator.begin(GL11.GL_LINES);
GL11.glVertex3f(var2 + 1.0F, var3 + 1.0F, var4); tesselator.vertex(var2, var3, var4);
GL11.glVertex3f(var2 + 1.0F, var3, var4 + 1.0F); tesselator.vertex(var2, var3 + 1.0F, var4);
GL11.glVertex3f(var2 + 1.0F, var3 + 1.0F, var4 + 1.0F); tesselator.vertex(var2 + 1.0F, var3, var4);
GL11.glVertex3f(var2, var3, var4 + 1.0F); tesselator.vertex(var2 + 1.0F, var3 + 1.0F, var4);
GL11.glVertex3f(var2, var3 + 1.0F, var4 + 1.0F); tesselator.vertex(var2 + 1.0F, var3, var4 + 1.0F);
GL11.glEnd(); tesselator.vertex(var2 + 1.0F, var3 + 1.0F, var4 + 1.0F);
tesselator.vertex(var2, var3, var4 + 1.0F);
tesselator.vertex(var2, var3 + 1.0F, var4 + 1.0F);
tesselator.end();
GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_BLEND);
} }

View File

@ -1,149 +1,332 @@
package com.mojang.minecraft.renderer; package com.mojang.minecraft.renderer;
import java.nio.FloatBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Float32Array;
import org.teavm.jso.typedarrays.Int32Array;
public final class Tesselator { public class Tesselator {
private FloatBuffer buffer = BufferUtils.createFloatBuffer(524288);
private float[] array = new float[524288]; /** The byte buffer used for GL allocation. */
private int vertices = 0; private Int32Array intBuffer;
private float u; private Float32Array floatBuffer;
private float v;
private float r; /**
private float g; * The number of vertices to be drawn in the next draw call. Reset to 0 between
private float b; * draw calls.
*/
private int vertexCount = 0;
/** The first coordinate to be used for the texture. */
private float textureU;
/** The second coordinate to be used for the texture. */
private float textureV;
/** The color (RGBA) value to be used for the following draw call. */
private int color;
/**
* Whether the current draw object for this tessellator has color values.
*/
private boolean hasColor = false; private boolean hasColor = false;
/**
* Whether the current draw object for this tessellator has texture coordinates.
*/
private boolean hasTexture = false; private boolean hasTexture = false;
private int len = 3;
private int p = 0;
private boolean noColor = false;
public static Tesselator instance = new Tesselator();
public final void end() { /** The index into the raw buffer to be used for the next data. */
if(this.vertices > 0) { private int rawBufferIndex = 0;
this.buffer.clear();
this.buffer.put(this.array, 0, this.p); /**
this.buffer.flip(); * The number of vertices manually added to the given draw call. This differs
if(this.hasTexture && this.hasColor) { * from vertexCount because it adds extra vertices when converting quads to
GL11.glInterleavedArrays(GL11.GL_T2F_C3F_V3F, 0, (FloatBuffer)this.buffer); * triangles.
} else if(this.hasTexture) { */
GL11.glInterleavedArrays(GL11.GL_T2F_V3F, 0, (FloatBuffer)this.buffer); private int addedVertices = 0;
} else if(this.hasColor) {
GL11.glInterleavedArrays(GL11.GL_C3F_V3F, 0, (FloatBuffer)this.buffer); /** Disables all color information for the following draw call. */
private boolean isColorDisabled = false;
/**
* An offset to be applied along the x-axis for all vertices in this draw call.
*/
private double xOffset;
/**
* An offset to be applied along the y-axis for all vertices in this draw call.
*/
private double yOffset;
/**
* An offset to be applied along the z-axis for all vertices in this draw call.
*/
private double zOffset;
/** The static instance of the Tessellator. */
public static final Tesselator instance = new Tesselator(525000);
/** Whether this tessellator is currently in draw mode. */
private boolean isDrawing = false;
/** Whether we are currently using VBO or not. */
private boolean useVBO = false;
/** The size of the buffers used (in integers). */
private int bufferSize;
private int drawMode;
private Tesselator(int par1) {
this.bufferSize = par1;
ArrayBuffer a = ArrayBuffer.create(par1 * 4);
this.intBuffer = Int32Array.create(a);
this.floatBuffer = Float32Array.create(a);
}
/**
* Draws the data set up in this tessellator and resets the state to prepare for
* new drawing.
*/
public int end() {
if (!this.isDrawing) {
return 0;
} else { } else {
GL11.glInterleavedArrays(GL11.GL_V3F, 0, (FloatBuffer)this.buffer); this.isDrawing = false;
}
if (this.vertexCount > 0) {
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
if (this.hasTexture) { if (this.hasTexture) {
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glEnableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY);
} }
if (this.hasColor) { if (this.hasColor) {
GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glEnableVertexAttrib(GL11.GL_COLOR_ARRAY);
} }
GL11.glDrawArrays(GL11.GL_QUADS, GL11.GL_POINTS, this.vertices); if (this.hasNormals) {
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY);
}
GL11.glDrawArrays(drawMode, 0, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 7));
if (this.hasTexture) { if (this.hasTexture) {
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glDisableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY);
} }
if (this.hasColor) { if (this.hasColor) {
GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); GL11.glDisableVertexAttrib(GL11.GL_COLOR_ARRAY);
}
if (this.hasNormals) {
GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY);
} }
} }
this.clear(); int var1 = this.rawBufferIndex * 4;
this.reset();
return var1;
}
} }
private void clear() { /**
this.vertices = 0; * Clears the tessellator state in preparation for new drawing.
this.buffer.clear(); */
this.p = 0; private void reset() {
this.vertexCount = 0;
//this.byteBuffer.clear();
this.rawBufferIndex = 0;
this.addedVertices = 0;
} }
public final void begin() { /**
this.clear(); * Resets tessellator state and prepares for drawing (with the specified draw
* mode).
*/
public void begin() {
this.drawMode = 7;
this.isDrawing = true;
this.reset();
this.hasColor = false; this.hasColor = false;
this.hasTexture = false; this.hasTexture = false;
this.noColor = false; this.isColorDisabled = false;
} }
public final void color(float var1, float var2, float var3) { public void begin(int drawMode) {
if(!this.noColor) { this.drawMode = drawMode;
if(!this.hasColor) { if (this.isDrawing) {
this.len += 3; this.draw();
} }
this.isDrawing = true;
this.hasColor = true; this.reset();
this.r = var1; this.hasColor = false;
this.g = var2; this.hasTexture = false;
this.b = var3; this.isColorDisabled = false;
}
}
public final void color(int var1, int var2, int var3) {
byte var10001 = (byte)var1;
byte var10002 = (byte)var2;
byte var6 = (byte)var3;
byte var5 = var10002;
byte var4 = var10001;
if(!this.noColor) {
if(!this.hasColor) {
this.len += 3;
}
this.hasColor = true;
this.r = (float)(var4 & 255) / 255.0F;
this.g = (float)(var5 & 255) / 255.0F;
this.b = (float)(var6 & 255) / 255.0F;
}
}
public final void vertexUV(float var1, float var2, float var3, float var4, float var5) {
if(!this.hasTexture) {
this.len += 2;
} }
/**
* Sets the texture coordinates.
*/
public void setTextureUV(double par1, double par3) {
this.hasTexture = true; this.hasTexture = true;
this.u = var4; this.textureU = (float) par1;
this.v = var5; this.textureV = (float) par3;
this.vertex(var1, var2, var3);
} }
public final void vertex(float var1, float var2, float var3) { /**
* Sets the RGB values as specified, converting from floats between 0 and 1 to
* integers from 0-255.
*/
public void setColorOpaque_F(float par1, float par2, float par3) {
this.setColorOpaque((int) (par1 * 255.0F), (int) (par2 * 255.0F), (int) (par3 * 255.0F));
}
/**
* Sets the RGBA values for the color, converting from floats between 0 and 1 to
* integers from 0-255.
*/
public void setColorRGBA_F(float par1, float par2, float par3, float par4) {
this.setColorRGBA((int) (par1 * 255.0F), (int) (par2 * 255.0F), (int) (par3 * 255.0F), (int) (par4 * 255.0F));
}
/**
* Sets the RGB values as specified, and sets alpha to opaque.
*/
public void color(int par1, int par2, int par3) {
this.setColorRGBA(par1, par2, par3, 255);
}
/**
* Sets the RGBA values for the color. Also clamps them to 0-255.
*/
public void setColorRGBA(int par1, int par2, int par3, int par4) {
if (!this.isColorDisabled) {
if (par1 > 255) {
par1 = 255;
}
if (par2 > 255) {
par2 = 255;
}
if (par3 > 255) {
par3 = 255;
}
if (par4 > 255) {
par4 = 255;
}
if (par1 < 0) {
par1 = 0;
}
if (par2 < 0) {
par2 = 0;
}
if (par3 < 0) {
par3 = 0;
}
if (par4 < 0) {
par4 = 0;
}
this.hasColor = true;
this.color = par4 << 24 | par3 << 16 | par2 << 8 | par1;
}
}
/**
* Adds a vertex specifying both x,y,z and the texture u,v for it.
*/
public void vertexUV(double par1, double par3, double par5, double par7, double par9) {
this.setTextureUV(par7, par9);
this.addVertex(par1, par3, par5);
}
/**
* Adds a vertex with the specified x,y,z to the current draw call. It will
* trigger a draw() if the buffer gets full.
*/
public void vertex(double par1, double par3, double par5) {
if(this.addedVertices > 65534) return;
++this.addedVertices;
++this.vertexCount;
int bufferIndex = this.rawBufferIndex;
Int32Array intBuffer0 = intBuffer;
Float32Array floatBuffer0 = floatBuffer;
floatBuffer0.set(bufferIndex + 0, (float) (par1 + this.xOffset));
floatBuffer0.set(bufferIndex + 1, (float) (par3 + this.yOffset));
floatBuffer0.set(bufferIndex + 2, (float) (par5 + this.zOffset));
if (this.hasTexture) { if (this.hasTexture) {
this.array[this.p++] = this.u; floatBuffer0.set(bufferIndex + 3, this.textureU);
this.array[this.p++] = this.v; floatBuffer0.set(bufferIndex + 4, this.textureV);
} }
if (this.hasColor) { if (this.hasColor) {
this.array[this.p++] = this.r; intBuffer0.set(bufferIndex + 5, this.color);
this.array[this.p++] = this.g;
this.array[this.p++] = this.b;
} }
this.array[this.p++] = var1; this.rawBufferIndex += 7;
this.array[this.p++] = var2;
this.array[this.p++] = var3;
++this.vertices;
if(this.vertices % 4 == 0 && this.p >= 524288 - (this.len << 2)) {
this.end();
} }
/**
* Sets the color to the given opaque value (stored as byte values packed in an
* integer).
*/
public void setColorOpaque_I(int par1) {
int var2 = par1 >> 16 & 255;
int var3 = par1 >> 8 & 255;
int var4 = par1 & 255;
this.setColorOpaque(var2, var3, var4);
} }
public final void color(int var1) { /**
int var2 = var1 >> 16 & 255; * Sets the color to the given color (packed as bytes in integer) and alpha
int var3 = var1 >> 8 & 255; * values.
var1 &= 255; */
this.color(var2, var3, var1); public void setColorRGBA_I(int par1, int par2) {
int var3 = par1 >> 16 & 255;
int var4 = par1 >> 8 & 255;
int var5 = par1 & 255;
this.setColorRGBA(var3, var4, var5, par2);
} }
public final void noColor() { /**
this.noColor = true; * Disables colors for the current draw call.
*/
public void disableColor() {
this.isColorDisabled = true;
}
/**
* Sets the normal for the current draw call.
*/
public void setNormal(float par1, float par2, float par3) {
GL11.glNormal3f(par1, par2, par3);
}
/**
* Sets the translation for all vertices in the current draw call.
*/
public void setTranslationD(double par1, double par3, double par5) {
this.xOffset = par1;
this.yOffset = par3;
this.zOffset = par5;
}
/**
* Offsets the translation for all vertices in the current draw call.
*/
public void setTranslationF(float par1, float par2, float par3) {
this.xOffset += (float) par1;
this.yOffset += (float) par2;
this.zOffset += (float) par3;
} }
} }

View File

@ -1,5 +0,0 @@
package com.mojang.minecraft.sound;
public interface Audio {
boolean play(int[] var1, int[] var2, int var3);
}

View File

@ -1,9 +0,0 @@
package com.mojang.minecraft.sound;
public class AudioInfo {
public float volume = 1.0F;
public int update(short[] var1, int var2) {
return 0;
}
}

View File

@ -1,40 +0,0 @@
package com.mojang.minecraft.sound;
import com.mojang.minecraft.Entity;
public abstract class BaseSoundPos implements SoundPos {
private Entity listener;
public BaseSoundPos(Entity var1) {
this.listener = var1;
}
public final float getRotationDiff(float var1, float var2) {
var1 -= this.listener.x;
var2 -= this.listener.z;
float var3 = (float)Math.sqrt((double)(var1 * var1 + var2 * var2));
var1 /= var3;
var2 /= var3;
var3 /= 2.0F;
if(var3 > 1.0F) {
var3 = 1.0F;
}
float var4 = (float)Math.cos((double)(-this.listener.yRot) * Math.PI / 180.0D + Math.PI);
float var5 = (float)Math.sin((double)(-this.listener.yRot) * Math.PI / 180.0D + Math.PI);
return (var5 * var2 - var4 * var1) * var3;
}
public final float getDistanceSq(float var1, float var2, float var3) {
var1 -= this.listener.x;
var2 -= this.listener.y;
float var4 = var3 - this.listener.z;
var4 = (float)Math.sqrt((double)(var1 * var1 + var2 * var2 + var4 * var4));
var4 = 1.0F - var4 / 32.0F;
if(var4 < 0.0F) {
var4 = 0.0F;
}
return var4;
}
}

View File

@ -1,20 +0,0 @@
package com.mojang.minecraft.sound;
import com.mojang.minecraft.Entity;
public final class EntitySoundPos extends BaseSoundPos {
private Entity source;
public EntitySoundPos(Entity var1, Entity var2) {
super(var2);
this.source = var1;
}
public final float getRotationDiff() {
return super.getRotationDiff(this.source.x, this.source.z);
}
public final float getDistanceSq() {
return super.getDistanceSq(this.source.x, this.source.y, this.source.z);
}
}

View File

@ -1,24 +0,0 @@
package com.mojang.minecraft.sound;
import com.mojang.minecraft.Entity;
public final class LevelSoundPos extends BaseSoundPos {
private float x;
private float y;
private float z;
public LevelSoundPos(float var1, float var2, float var3, Entity var4) {
super(var4);
this.x = var1;
this.y = var2;
this.z = var3;
}
public final float getRotationDiff() {
return super.getRotationDiff(this.x, this.z);
}
public final float getDistanceSq() {
return super.getDistanceSq(this.x, this.y, this.z);
}
}

View File

@ -1,66 +0,0 @@
package com.mojang.minecraft.sound;
import de.jarnbjo.ogg.LogicalOggStreamImpl;
import de.jarnbjo.ogg.OnDemandUrlStream;
import de.jarnbjo.vorbis.VorbisStream;
import java.io.IOException;
import java.net.URL;
import java.nio.ByteBuffer;
public final class Music implements Audio {
ByteBuffer playing = ByteBuffer.allocate(176400);
ByteBuffer current = ByteBuffer.allocate(176400);
private ByteBuffer processing = null;
ByteBuffer previous = null;
VorbisStream stream;
SoundPlayer player;
boolean finished = false;
boolean stopped = false;
public Music(SoundPlayer var1, URL var2) throws IOException {
this.player = var1;
OnDemandUrlStream var3 = new OnDemandUrlStream(var2);
LogicalOggStreamImpl var4 = (LogicalOggStreamImpl)var3.logicalStreams.values().iterator().next();
this.stream = new VorbisStream(var4);
(new MusicThread(this)).start();
}
public final boolean play(int[] var1, int[] var2, int var3) {
if(!this.player.options.music) {
this.stopped = true;
return false;
} else {
var3 = var3;
int var4 = 0;
while(var3 > 0 && (this.processing != null || this.previous != null)) {
if(this.processing == null && this.previous != null) {
this.processing = this.previous;
this.previous = null;
}
if(this.processing != null && this.processing.remaining() > 0) {
int var5 = this.processing.remaining() / 4;
if(var5 > var3) {
var5 = var3;
}
for(int var6 = 0; var6 < var5; ++var6) {
var1[var4 + var6] += this.processing.getShort();
var2[var4 + var6] += this.processing.getShort();
}
var4 += var5;
var3 -= var5;
}
if(this.current == null && this.processing != null && this.processing.remaining() == 0) {
this.current = this.processing;
this.processing = null;
}
}
return this.processing != null || this.previous != null || !this.finished;
}
}
}

View File

@ -1,98 +0,0 @@
package com.mojang.minecraft.sound;
import de.jarnbjo.ogg.EndOfOggStreamException;
import de.jarnbjo.vorbis.VorbisStream;
import java.nio.ByteBuffer;
final class MusicThread extends Thread {
private Music music;
public MusicThread(Music var1) {
this.music = var1;
this.setPriority(10);
this.setDaemon(true);
}
public final void run() {
try {
Music var1;
do {
if(this.music.stopped) {
return;
}
var1 = this.music;
ByteBuffer var2;
if(var1.playing == null) {
var1 = this.music;
if(var1.current != null) {
var1 = this.music;
var2 = var1.current;
var1 = this.music;
var1.playing = var2;
var2 = null;
var1 = this.music;
var1.current = null;
var1 = this.music;
var1.playing.clear();
}
}
var1 = this.music;
if(var1.playing != null) {
var1 = this.music;
if(var1.playing.remaining() != 0) {
while(true) {
var1 = this.music;
if(var1.playing.remaining() == 0) {
break;
}
var1 = this.music;
VorbisStream var10000 = var1.stream;
var1 = this.music;
var2 = var1.playing;
VorbisStream var9 = var10000;
int var10 = var9.readPcm(var2.array(), var2.position(), var2.remaining());
var2.position(var2.position() + var10);
boolean var11 = var10 <= 0;
if(var11) {
this.music.finished = true;
this.music.stopped = true;
break;
}
}
}
}
var1 = this.music;
if(var1.playing != null) {
var1 = this.music;
if(var1.previous == null) {
var1 = this.music;
var1.playing.flip();
var1 = this.music;
var2 = var1.playing;
var1 = this.music;
var1.previous = var2;
var2 = null;
var1 = this.music;
var1.playing = var2;
}
}
Thread.sleep(10L);
var1 = this.music;
} while(var1.player.running);
return;
} catch (EndOfOggStreamException var6) {
return;
} catch (Exception var7) {
var7.printStackTrace();
} finally {
this.music.finished = true;
}
}
}

View File

@ -1,58 +0,0 @@
package com.mojang.minecraft.sound;
public final class Sound implements Audio {
private AudioInfo info;
private SoundPos pos;
private float pitch = 0.0F;
private float volume = 1.0F;
private static short[] data = new short[1];
public Sound(AudioInfo var1, SoundPos var2) {
this.info = var1;
this.pos = var2;
this.pitch = var2.getRotationDiff();
this.volume = var2.getDistanceSq() * var1.volume;
}
public final boolean play(int[] var1, int[] var2, int var3) {
if(data.length < var3) {
data = new short[var3];
}
int var4 = this.info.update(data, var3);
boolean var5 = var4 > 0;
float var6 = this.pos.getRotationDiff();
float var7 = this.pos.getDistanceSq() * this.info.volume;
int var8 = (int)((this.pitch > 0.0F ? 1.0F - this.pitch : 1.0F) * this.volume * 65536.0F);
int var9 = (int)((this.pitch < 0.0F ? 1.0F + this.pitch : 1.0F) * this.volume * 65536.0F);
int var10 = (int)((var6 > 0.0F ? 1.0F - var6 : 1.0F) * var7 * 65536.0F);
int var11 = (int)((var6 < 0.0F ? var6 + 1.0F : 1.0F) * var7 * 65536.0F);
var10 -= var8;
var11 -= var9;
int var12;
int var13;
int var14;
if(var10 == 0 && var11 == 0) {
if(var8 >= 0 || var9 != 0) {
var12 = var8;
var13 = var9;
for(var14 = 0; var14 < var4; ++var14) {
var1[var14] += data[var14] * var12 >> 16;
var2[var14] += data[var14] * var13 >> 16;
}
}
} else {
for(var12 = 0; var12 < var4; ++var12) {
var13 = var8 + var10 * var12 / var3;
var14 = var9 + var11 * var12 / var3;
var1[var12] += data[var12] * var13 >> 16;
var2[var12] += data[var12] * var14 >> 16;
}
}
this.pitch = var6;
this.volume = var7;
return var5;
}
}

View File

@ -1,11 +0,0 @@
package com.mojang.minecraft.sound;
public final class SoundData {
public final short[] data;
public final float length;
public SoundData(short[] var1, float var2) {
this.data = var1;
this.length = var2;
}
}

View File

@ -1,32 +0,0 @@
package com.mojang.minecraft.sound;
public final class SoundInfo extends AudioInfo {
private SoundData data;
private float seek = 0.0F;
private float pitch;
public SoundInfo(SoundData var1, float var2, float var3) {
this.data = var1;
this.pitch = var2 * 44100.0F / var1.length;
this.volume = var3;
}
public final int update(short[] var1, int var2) {
if(this.seek >= (float)this.data.data.length) {
return 0;
} else {
for(int var3 = 0; var3 < var2; ++var3) {
int var4 = (int)this.seek;
short var5 = this.data.data[var4];
short var6 = var4 < this.data.data.length - 1 ? this.data.data[var4 + 1] : 0;
var1[var3] = (short)((int)((float)var5 + (float)(var6 - var5) * (this.seek - (float)var4)));
this.seek += this.pitch;
if(this.seek >= (float)this.data.data.length) {
return var3;
}
}
return var2;
}
}
}

View File

@ -1,99 +0,0 @@
package com.mojang.minecraft.sound;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
public final class SoundManager {
private SoundReader reader = new SoundReader();
public Map sounds = new HashMap();
private Map music = new HashMap();
public Random random = new Random();
public long lastMusic = System.currentTimeMillis() + 60000L;
public final AudioInfo getAudioInfo(String var1, float var2, float var3) {
List var4 = null;
Map var5 = this.sounds;
synchronized(var5) {
var4 = (List)this.sounds.get(var1);
}
if(var4 == null) {
return null;
} else {
SoundData var7 = (SoundData)var4.get(this.random.nextInt(var4.size()));
return new SoundInfo(var7, var3, var2);
}
}
public void registerSound(File var1, String var2) {
try {
var2 = var2.substring(0, var2.length() - 4);
for(var2 = var2.replaceAll("/", "."); Character.isDigit(var2.charAt(var2.length() - 1)); var2 = var2.substring(0, var2.length() - 1)) {
}
SoundData var7 = SoundReader.read(var1.toURI().toURL());
Map var3 = this.sounds;
synchronized(var3) {
Object var4 = (List)this.sounds.get(var2);
if(var4 == null) {
var4 = new ArrayList();
this.sounds.put(var2, var4);
}
((List)var4).add(var7);
}
} catch (Exception var6) {
var6.printStackTrace();
}
}
public final void registerMusic(String var1, File var2) {
Map var3 = this.music;
synchronized(var3) {
var1 = var1.substring(0, var1.length() - 4);
for(var1 = var1.replaceAll("/", "."); Character.isDigit(var1.charAt(var1.length() - 1)); var1 = var1.substring(0, var1.length() - 1)) {
}
Object var4 = (List)this.music.get(var1);
if(var4 == null) {
var4 = new ArrayList();
this.music.put(var1, var4);
}
((List)var4).add(var2);
}
}
public boolean playMusic(SoundPlayer var1, String var2) {
List var3 = null;
Map var4 = this.music;
synchronized(var4) {
var3 = (List)this.music.get(var2);
}
if(var3 == null) {
return false;
} else {
File var8 = (File)var3.get(this.random.nextInt(var3.size()));
try {
var1.play(new Music(var1, var8.toURI().toURL()));
} catch (MalformedURLException var5) {
var5.printStackTrace();
} catch (IOException var6) {
var6.printStackTrace();
}
return true;
}
}
}

View File

@ -1,104 +0,0 @@
package com.mojang.minecraft.sound;
import com.mojang.minecraft.Options;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.sound.sampled.SourceDataLine;
public final class SoundPlayer implements Runnable {
public boolean running = false;
public SourceDataLine dataLine;
private List audioQueue = new ArrayList();
public Options options;
public SoundPlayer(Options var1) {
this.options = var1;
}
public final void play(Audio var1) {
if(this.running) {
List var2 = this.audioQueue;
synchronized(var2) {
this.audioQueue.add(var1);
}
}
}
public final void play(AudioInfo var1, SoundPos var2) {
this.play(new Sound(var1, var2));
}
public final void run() {
int[] var1 = new int[4410];
int[] var2 = new int[4410];
for(byte[] var3 = new byte[17640]; this.running; this.dataLine.write(var3, 0, 17640)) {
try {
Thread.sleep(1L);
} catch (InterruptedException var10) {
var10.printStackTrace();
}
Arrays.fill(var1, 0, 4410, 0);
Arrays.fill(var2, 0, 4410, 0);
boolean var4 = true;
int[] var6 = var2;
int[] var5 = var1;
List var12 = this.audioQueue;
synchronized(var12) {
int var8 = 0;
while(true) {
if(var8 >= var12.size()) {
break;
}
Audio var9 = (Audio)var12.get(var8);
boolean var16 = var9.play(var5, var6, 4410);
if(!var16) {
var12.remove(var8--);
}
++var8;
}
}
int var13;
if(!this.options.music && !this.options.sound) {
for(var13 = 0; var13 < 4410; ++var13) {
var3[var13 << 2] = 0;
var3[(var13 << 2) + 1] = 0;
var3[(var13 << 2) + 2] = 0;
var3[(var13 << 2) + 3] = 0;
}
} else {
for(var13 = 0; var13 < 4410; ++var13) {
int var14 = var1[var13];
int var15 = var2[var13];
if(var14 < -32000) {
var14 = -32000;
}
if(var15 < -32000) {
var15 = -32000;
}
if(var14 >= 32000) {
var14 = 32000;
}
if(var15 >= 32000) {
var15 = 32000;
}
var3[var13 << 2] = (byte)(var14 >> 8);
var3[(var13 << 2) + 1] = (byte)var14;
var3[(var13 << 2) + 2] = (byte)(var15 >> 8);
var3[(var13 << 2) + 3] = (byte)var15;
}
}
}
}
}

View File

@ -1,7 +0,0 @@
package com.mojang.minecraft.sound;
public interface SoundPos {
float getRotationDiff();
float getDistanceSq();
}

View File

@ -1,72 +0,0 @@
package com.mojang.minecraft.sound;
import de.jarnbjo.ogg.EndOfOggStreamException;
import de.jarnbjo.ogg.LogicalOggStreamImpl;
import de.jarnbjo.ogg.OnDemandUrlStream;
import de.jarnbjo.vorbis.IdentificationHeader;
import de.jarnbjo.vorbis.VorbisStream;
import java.io.IOException;
import java.net.URL;
public final class SoundReader {
public static SoundData read(URL var0) throws IOException {
OnDemandUrlStream var11 = new OnDemandUrlStream(var0);
LogicalOggStreamImpl var12 = (LogicalOggStreamImpl)var11.logicalStreams.values().iterator().next();
VorbisStream var13 = new VorbisStream(var12);
byte[] var1 = new byte[4096];
int var2 = 0;
boolean var3 = false;
IdentificationHeader var15 = var13.identificationHeader;
int var4 = var15.channels;
short[] var5 = new short[4096];
int var6 = 0;
while(true) {
int var16;
do {
if(var2 < 0) {
if(var6 != var5.length) {
short[] var18 = var5;
var5 = new short[var6];
System.arraycopy(var18, 0, var5, 0, var6);
}
IdentificationHeader var14 = var13.identificationHeader;
return new SoundData(var5, (float)var14.sampleRate);
}
var16 = 0;
try {
while(var16 < var1.length) {
var2 = var13.readPcm(var1, var16, var1.length - var16);
if(var2 <= 0) {
break;
}
var16 += var2;
}
} catch (EndOfOggStreamException var10) {
var2 = -1;
}
} while(var16 <= 0);
boolean var7 = false;
int var8;
for(int var17 = 0; var17 < var16; var5[var6++] = (short)(var8 / var4)) {
var8 = 0;
for(int var9 = 0; var9 < var4; ++var9) {
var8 += var1[var17++] << 8 | var1[var17++] & 255;
}
if(var6 == var5.length) {
short[] var19 = var5;
var5 = new short[var5.length << 1];
System.arraycopy(var19, 0, var5, 0, var6);
}
}
}
}
}

View File

@ -0,0 +1,19 @@
package org.lwjgl;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
public class BufferUtils extends GLAllocation {
public static FloatBuffer createFloatBuffer(int i1) {
return createDirectFloatBuffer(i1);
}
public static IntBuffer createIntBuffer(int i1) {
return createDirectIntBuffer(i1);
}
public static ByteBuffer createByteBuffer(int i1) {
return createDirectByteBuffer(i1);
}
}

View File

@ -0,0 +1,60 @@
package org.lwjgl;
import java.nio.*;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
public class GLAllocation {
public GLAllocation() {
}
public static synchronized int generateDisplayLists(int i) {
int j = GL11.glGenLists(i);
displayLists.add(Integer.valueOf(j));
displayLists.add(Integer.valueOf(i));
return j;
}
public static synchronized void generateTextureNames(IntBuffer intbuffer) {
for (int i = intbuffer.position(); i < intbuffer.limit(); i++) {
int tx = GL11.glGenTextures();
intbuffer.put(i, tx);
textureNames.add(Integer.valueOf(tx));
}
}
public static synchronized void deleteTexturesAndDisplayLists() {
for (int i = 0; i < displayLists.size(); i += 2) {
GL11.glDeleteLists(((Integer) displayLists.get(i)).intValue(),
((Integer) displayLists.get(i + 1)).intValue());
}
for (int j = 0; j < textureNames.size(); j++) {
GL11.glDeleteTextures(((Integer) textureNames.get(j)).intValue());
}
displayLists.clear();
textureNames.clear();
}
public static ByteBuffer createDirectByteBuffer(int par0) {
return ByteBuffer.wrap(new byte[par0]).order(ByteOrder.nativeOrder());
}
public static IntBuffer createDirectIntBuffer(int par0) {
return IntBuffer.wrap(new int[par0]);
}
public static FloatBuffer createDirectFloatBuffer(int par0) {
return FloatBuffer.wrap(new float[par0]);
}
private static List displayLists = new ArrayList();
private static List textureNames = new ArrayList();
}

View File

@ -13,7 +13,11 @@ public class Display {
LWJGLMain.updateDisplay(); LWJGLMain.updateDisplay();
} }
public static HTMLCanvasElement getDisplayMode() { public static int getWidth() {
return LWJGLMain.canvas; return LWJGLMain.getCanvasWidth();
}
public static int getHeight() {
return LWJGLMain.getCanvasHeight();
} }
} }