c0.0.23a_01 src code

This commit is contained in:
PeytonPlayz595 2023-10-10 17:59:45 +00:00
parent b19b0c99e4
commit b561cc0528
385 changed files with 9060 additions and 26653 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

0
CREDITS Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

View File

@ -0,0 +1,151 @@
package com.mojang.comm;
import com.mojang.minecraft.net.ConnectionManager;
import com.mojang.minecraft.net.Packet;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.Arrays;
public final class SocketConnection {
public volatile boolean connected;
public SocketChannel socketChannel = SocketChannel.open();
public ByteBuffer readBuffer = ByteBuffer.allocate(1048576);
public ByteBuffer writeBuffer = ByteBuffer.allocate(1048576);
public ConnectionManager manager;
private Socket socket;
private boolean initialized = false;
private byte[] stringPacket = new byte[64];
public SocketConnection(String var1, int var2) throws IOException {
this.socketChannel.connect(new InetSocketAddress(var1, var2));
this.socketChannel.configureBlocking(false);
System.currentTimeMillis();
this.socket = this.socketChannel.socket();
this.connected = true;
this.readBuffer.clear();
this.writeBuffer.clear();
this.socket.setTcpNoDelay(true);
this.socket.setTrafficClass(24);
this.socket.setKeepAlive(false);
this.socket.setReuseAddress(false);
this.socket.setSoTimeout(100);
this.socket.getInetAddress().toString();
}
public final void disconnect() {
try {
if(this.writeBuffer.position() > 0) {
this.writeBuffer.flip();
this.socketChannel.write(this.writeBuffer);
this.writeBuffer.compact();
}
} catch (Exception var2) {
}
this.connected = false;
try {
this.socketChannel.close();
} catch (Exception var1) {
}
this.socket = null;
this.socketChannel = null;
}
public final void sendPacket(Packet var1, Object... var2) {
if(this.connected) {
this.writeBuffer.put(var1.id);
for(int var3 = 0; var3 < var2.length; ++var3) {
Class var10001 = var1.fields[var3];
Object var6 = var2[var3];
Class var5 = var10001;
SocketConnection var4 = this;
if(this.connected) {
try {
if(var5 == Long.TYPE) {
var4.writeBuffer.putLong(((Long)var6).longValue());
} else if(var5 == Integer.TYPE) {
var4.writeBuffer.putInt(((Number)var6).intValue());
} else if(var5 == Short.TYPE) {
var4.writeBuffer.putShort(((Number)var6).shortValue());
} else if(var5 == Byte.TYPE) {
var4.writeBuffer.put(((Number)var6).byteValue());
} else if(var5 == Double.TYPE) {
var4.writeBuffer.putDouble(((Double)var6).doubleValue());
} else if(var5 == Float.TYPE) {
var4.writeBuffer.putFloat(((Float)var6).floatValue());
} else {
byte[] var8;
if(var5 != String.class) {
if(var5 == byte[].class) {
var8 = (byte[])((byte[])var6);
if(var8.length < 1024) {
var8 = Arrays.copyOf(var8, 1024);
}
var4.writeBuffer.put(var8);
}
} else {
var8 = ((String)var6).getBytes("UTF-8");
Arrays.fill(var4.stringPacket, (byte)32);
int var9;
for(var9 = 0; var9 < 64 && var9 < var8.length; ++var9) {
var4.stringPacket[var9] = var8[var9];
}
for(var9 = var8.length; var9 < 64; ++var9) {
var4.stringPacket[var9] = 32;
}
var4.writeBuffer.put(var4.stringPacket);
}
}
} catch (Exception var7) {
this.manager.disconnect(var7);
}
}
}
}
}
public Object read(Class var1) {
if(!this.connected) {
return null;
} else {
try {
if(var1 == Long.TYPE) {
return Long.valueOf(this.readBuffer.getLong());
} else if(var1 == Integer.TYPE) {
return Integer.valueOf(this.readBuffer.getInt());
} else if(var1 == Short.TYPE) {
return Short.valueOf(this.readBuffer.getShort());
} else if(var1 == Byte.TYPE) {
return Byte.valueOf(this.readBuffer.get());
} else if(var1 == Double.TYPE) {
return Double.valueOf(this.readBuffer.getDouble());
} else if(var1 == Float.TYPE) {
return Float.valueOf(this.readBuffer.getFloat());
} else if(var1 == String.class) {
this.readBuffer.get(this.stringPacket);
return (new String(this.stringPacket, "UTF-8")).trim();
} else if(var1 == byte[].class) {
byte[] var3 = new byte[1024];
this.readBuffer.get(var3);
return var3;
} else {
return null;
}
} catch (Exception var2) {
this.manager.disconnect(var2);
return null;
}
}
}
}

View File

@ -0,0 +1,112 @@
package com.mojang.minecraft;
import com.mojang.minecraft.sound.SoundManager;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
public final class BackgroundDownloader extends Thread {
private File resourcesFolder;
private Minecraft minecraft;
boolean closing = false;
public BackgroundDownloader(File var1, Minecraft var2) {
this.minecraft = var2;
this.setName("Resource download thread");
this.setDaemon(true);
this.resourcesFolder = new File(var1, "resources/");
if(!this.resourcesFolder.exists() && !this.resourcesFolder.mkdirs()) {
throw new RuntimeException("The working directory could not be created: " + this.resourcesFolder);
}
}
public final void run() {
try {
ArrayList var1 = new ArrayList();
URL var2 = new URL("http://www.minecraft.net/resources/");
BufferedReader var3 = new BufferedReader(new InputStreamReader(var2.openStream()));
String var4 = null;
while(true) {
var4 = var3.readLine();
if(var4 == null) {
var3.close();
for(int var11 = 0; var11 < var1.size(); ++var11) {
String var6 = (String)var1.get(var11);
URL var5 = var2;
BackgroundDownloader var12 = this;
try {
label58: {
String[] var16 = var6.split(",");
String var7 = var16[0];
int var8 = Integer.parseInt(var16[1]);
Long.parseLong(var16[2]);
File var17 = new File(var12.resourcesFolder, var7);
String var19;
if(!var17.exists() || var17.length() != (long)var8) {
var17.getParentFile().mkdirs();
var19 = var7.replaceAll(" ", "%20");
var12.downloadResource(new URL(var5, var19), var17);
if(var12.closing) {
break label58;
}
}
Minecraft var13 = var12.minecraft;
int var18 = var7.indexOf("/");
var19 = var7.substring(0, var18);
String var14 = var7.substring(var18 + 1);
if(var19.equalsIgnoreCase("sound")) {
SoundManager var15 = var13.soundManager;
var15.registerSound(var17, var14);
} else if(var19.equalsIgnoreCase("music")) {
var13.soundManager.registerMusic(var14, var17);
}
}
} catch (Exception var9) {
var9.printStackTrace();
}
if(this.closing) {
return;
}
}
return;
}
var1.add(var4);
}
} catch (IOException var10) {
var10.printStackTrace();
}
}
private void downloadResource(URL var1, File var2) throws IOException {
System.out.println("Downloading " + var1);
byte[] var3 = new byte[4096];
DataInputStream var5 = new DataInputStream(var1.openStream());
DataOutputStream var6 = new DataOutputStream(new FileOutputStream(var2));
boolean var4 = false;
do {
int var7 = var5.read(var3);
if(var7 < 0) {
var5.close();
var6.close();
return;
}
var6.write(var3, 0, var7);
} while(!this.closing);
}
}

View File

@ -0,0 +1,11 @@
package com.mojang.minecraft;
public final class ChatLine {
public String message;
public int counter;
public ChatLine(String var1) {
this.message = var1;
this.counter = 0;
}
}

View File

@ -0,0 +1,266 @@
package com.mojang.minecraft;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.liquid.Liquid;
import com.mojang.minecraft.level.tile.Tile;
import com.mojang.minecraft.net.PlayerMove;
import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.renderer.Textures;
import java.io.Serializable;
import java.util.ArrayList;
public class Entity implements Serializable {
public static final long serialVersionUID = 0L;
protected Level level;
public float xo;
public float yo;
public float zo;
public float x;
public float y;
public float z;
public float xd;
public float yd;
public float zd;
public float yRot;
public float xRot;
public float yRotO;
public float xRotO;
public AABB bb;
public boolean onGround = false;
public boolean horizontalCollision = false;
public boolean removed = false;
public float heightOffset = 0.0F;
protected float bbWidth = 0.6F;
public float bbHeight = 1.8F;
private float walkDist = 0.0F;
public boolean makeStepSound = true;
public Entity(Level var1) {
this.level = var1;
this.setPos(0.0F, 0.0F, 0.0F);
}
protected void resetPos() {
if(this.level != null) {
float var1 = (float)this.level.xSpawn + 0.5F;
float var2 = (float)this.level.ySpawn;
for(float var3 = (float)this.level.zSpawn + 0.5F; var2 > 0.0F; ++var2) {
this.setPos(var1, var2, var3);
if(this.level.getCubes(this.bb).size() == 0) {
break;
}
}
this.xd = this.yd = this.zd = 0.0F;
this.yRot = this.level.rotSpawn;
this.xRot = 0.0F;
}
}
public void remove() {
this.removed = true;
}
public void setSize(float var1, float var2) {
this.bbWidth = var1;
this.bbHeight = var2;
}
public void setPos(PlayerMove var1) {
if(var1.moving) {
this.setPos(var1.x, var1.y, var1.z);
} else {
this.setPos(this.x, this.y, this.z);
}
if(var1.rotating) {
this.setRot(var1.yRot, var1.xRot);
} else {
this.setRot(this.yRot, this.xRot);
}
}
protected void setRot(float var1, float var2) {
this.yRot = var1;
this.xRot = var2;
}
public void setPos(float var1, float var2, float var3) {
this.x = var1;
this.y = var2;
this.z = var3;
float var4 = this.bbWidth / 2.0F;
float var5 = this.bbHeight / 2.0F;
this.bb = new AABB(var1 - var4, var2 - var5, var3 - var4, var1 + var4, var2 + var5, var3 + var4);
}
public void turn(float var1, float var2) {
float var3 = this.xRot;
float var4 = this.yRot;
this.yRot = (float)((double)this.yRot + (double)var1 * 0.15D);
this.xRot = (float)((double)this.xRot - (double)var2 * 0.15D);
if(this.xRot < -90.0F) {
this.xRot = -90.0F;
}
if(this.xRot > 90.0F) {
this.xRot = 90.0F;
}
this.xRotO += this.xRot - var3;
this.yRotO += this.yRot - var4;
}
public void interpolateTurn(float var1, float var2) {
this.yRot = (float)((double)this.yRot + (double)var1 * 0.15D);
this.xRot = (float)((double)this.xRot - (double)var2 * 0.15D);
if(this.xRot < -90.0F) {
this.xRot = -90.0F;
}
if(this.xRot > 90.0F) {
this.xRot = 90.0F;
}
}
public void tick() {
this.xo = this.x;
this.yo = this.y;
this.zo = this.z;
this.xRotO = this.xRot;
this.yRotO = this.yRot;
}
public boolean isFree(float var1, float var2, float var3) {
AABB var4 = this.bb.cloneMove(var1, var2, var3);
ArrayList var5 = this.level.getCubes(var4);
return var5.size() > 0 ? false : !this.level.containsAnyLiquid(var4);
}
public void move(float var1, float var2, float var3) {
float var4 = this.x;
float var5 = this.z;
float var6 = var1;
float var7 = var2;
float var8 = var3;
ArrayList var9 = this.level.getCubes(this.bb.expand(var1, var2, var3));
int var10;
for(var10 = 0; var10 < var9.size(); ++var10) {
var2 = ((AABB)var9.get(var10)).clipYCollide(this.bb, var2);
}
this.bb.move(0.0F, var2, 0.0F);
for(var10 = 0; var10 < var9.size(); ++var10) {
var1 = ((AABB)var9.get(var10)).clipXCollide(this.bb, var1);
}
this.bb.move(var1, 0.0F, 0.0F);
for(var10 = 0; var10 < var9.size(); ++var10) {
var3 = ((AABB)var9.get(var10)).clipZCollide(this.bb, var3);
}
this.bb.move(0.0F, 0.0F, var3);
this.horizontalCollision = var6 != var1 || var8 != var3;
this.onGround = var7 != var2 && var7 < 0.0F;
if(var6 != var1) {
this.xd = 0.0F;
}
if(var7 != var2) {
this.yd = 0.0F;
}
if(var8 != var3) {
this.zd = 0.0F;
}
this.x = (this.bb.x0 + this.bb.x1) / 2.0F;
this.y = this.bb.y0 + this.heightOffset;
this.z = (this.bb.z0 + this.bb.z1) / 2.0F;
float var13 = this.x - var4;
var1 = this.z - var5;
this.walkDist = (float)((double)this.walkDist + Math.sqrt((double)(var13 * var13 + var1 * var1)) * 0.6D);
if(this.makeStepSound) {
int var11 = this.level.getTile((int)this.x, (int)(this.y - 0.2F - this.heightOffset), (int)this.z);
if(this.walkDist > 1.0F && var11 > 0) {
Tile.SoundType var12 = Tile.tiles[var11].soundType;
if(var12 != Tile.SoundType.none) {
this.walkDist -= (float)((int)this.walkDist);
this.playSound("step." + var12.name, var12.getVolume() * (12.0F / 16.0F), var12.getPitch());
}
}
}
}
public boolean isInWater() {
return this.level.containsLiquid(this.bb.grow(0.0F, -0.4F, 0.0F), Liquid.water);
}
public boolean isInLava() {
return this.level.containsLiquid(this.bb.grow(0.0F, -0.4F, 0.0F), Liquid.lava);
}
public void moveRelative(float var1, float var2, float var3) {
float var4 = (float)Math.sqrt((double)(var1 * var1 + var2 * var2));
if(var4 >= 0.01F) {
if(var4 < 1.0F) {
var4 = 1.0F;
}
var4 = var3 / var4;
var1 *= var4;
var2 *= var4;
var3 = (float)Math.sin((double)this.yRot * Math.PI / 180.0D);
var4 = (float)Math.cos((double)this.yRot * Math.PI / 180.0D);
this.xd += var1 * var4 - var2 * var3;
this.zd += var2 * var4 + var1 * var3;
}
}
public boolean isLit() {
int var1 = (int)this.x;
int var2 = (int)this.y;
int var3 = (int)this.z;
return this.level.isLit(var1, var2, var3);
}
public float getBrightness() {
int var1 = (int)this.x;
int var2 = (int)(this.y + this.heightOffset / 2.0F);
int var3 = (int)this.z;
return this.level.getBrightness(var1, var2, var3);
}
public void render(Textures var1, float var2) {
}
public void setLevel(Level var1) {
this.level = var1;
}
public void playSound(String var1, float var2, float var3) {
this.level.playSound(var1, this, var2, var3);
}
public void moveTo(float var1, float var2, float var3, float var4, float var5) {
this.xo = this.x = var1;
this.yo = this.y = var2;
this.zo = this.z = var3;
this.yRot = var4;
this.xRot = var5;
this.setPos(var1, var2, var3);
}
public float distanceTo(Entity var1) {
float var2 = this.x - var1.x;
float var3 = this.y - var1.y;
float var4 = this.z - var1.z;
return (float)Math.sqrt((double)(var2 * var2 + var3 * var3 + var4 * var4));
}
}

View File

@ -0,0 +1,15 @@
package com.mojang.minecraft;
public final class HitResult {
public int x;
public int y;
public int z;
public int f;
public HitResult(int var1, int var2, int var3, int var4, int var5) {
this.x = var2;
this.y = var3;
this.z = var4;
this.f = var5;
}
}

View File

@ -0,0 +1,11 @@
package com.mojang.minecraft;
public final class KeyBinding {
public String name;
public int key;
public KeyBinding(String var1, int var2) {
this.name = var1;
this.key = var2;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,94 @@
package com.mojang.minecraft;
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Canvas;
public class MinecraftApplet extends Applet {
private Canvas canvas;
private Minecraft minecraft;
private Thread thread = null;
public void init() {
this.canvas = new Canvas() {
public final synchronized void addNotify() {
super.addNotify();
MinecraftApplet.this.startGameThread();
}
public final synchronized void removeNotify() {
MinecraftApplet.this.stopGameThread();
super.removeNotify();
}
};
this.minecraft = new Minecraft(this.canvas, this.getWidth(), this.getHeight(), false);
this.minecraft.minecraftUri = this.getDocumentBase().getHost();
if(this.getDocumentBase().getPort() > 0) {
this.minecraft.minecraftUri = this.minecraft.minecraftUri + ":" + this.getDocumentBase().getPort();
}
if(this.getParameter("username") != null && this.getParameter("sessionid") != null) {
this.minecraft.user = new User(this.getParameter("username"), this.getParameter("sessionid"));
if(this.getParameter("mppass") != null) {
this.minecraft.user.mpPass = this.getParameter("mppass");
}
}
if(this.getParameter("loadmap_user") != null && this.getParameter("loadmap_id") != null) {
this.minecraft.loadMapUser = this.getParameter("loadmap_user");
this.minecraft.loadMapId = Integer.parseInt(this.getParameter("loadmap_id"));
} else if(this.getParameter("server") != null && this.getParameter("port") != null) {
Minecraft var10000 = this.minecraft;
String var10001 = this.getParameter("server");
int var3 = Integer.parseInt(this.getParameter("port"));
String var2 = var10001;
Minecraft var1 = var10000;
var1.server = var2;
var1.port = var3;
}
this.minecraft.appletMode = true;
this.setLayout(new BorderLayout());
this.add(this.canvas, "Center");
this.canvas.setFocusable(true);
this.validate();
}
public void startGameThread() {
if(this.thread == null) {
this.thread = new Thread(this.minecraft);
this.thread.start();
}
}
public void start() {
this.minecraft.pause = false;
}
public void stop() {
this.minecraft.pause = true;
}
public void destroy() {
this.stopGameThread();
}
public void stopGameThread() {
if(this.thread != null) {
Minecraft var1 = this.minecraft;
var1.running = false;
try {
this.thread.join(1000L);
} catch (InterruptedException var3) {
try {
this.minecraft.destroy();
} catch (Exception var2) {
var2.printStackTrace();
}
}
this.thread = null;
}
}
}

View File

@ -0,0 +1,27 @@
package com.mojang.minecraft;
final class OSMap {
static final int[] osValues = new int[Minecraft.OS.values().length];
static {
try {
osValues[Minecraft.OS.linux.ordinal()] = 1;
} catch (NoSuchFieldError var3) {
}
try {
osValues[Minecraft.OS.solaris.ordinal()] = 2;
} catch (NoSuchFieldError var2) {
}
try {
osValues[Minecraft.OS.windows.ordinal()] = 3;
} catch (NoSuchFieldError var1) {
}
try {
osValues[Minecraft.OS.macos.ordinal()] = 4;
} catch (NoSuchFieldError var0) {
}
}
}

View File

@ -0,0 +1,138 @@
package com.mojang.minecraft;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import org.lwjgl.input.Keyboard;
public final class Options {
private static final String[] RENDER_DISTANCES = new String[]{"FAR", "NORMAL", "SHORT", "TINY"};
public boolean music = true;
public boolean sound = true;
public boolean invertMouse = false;
public boolean showFPS = false;
public int renderDistance = 0;
public KeyBinding forward = new KeyBinding("Forward", 17);
public KeyBinding left = new KeyBinding("Left", 30);
public KeyBinding back = new KeyBinding("Back", 31);
public KeyBinding right = new KeyBinding("Right", 32);
public KeyBinding jump = new KeyBinding("Jump", 57);
public KeyBinding build = new KeyBinding("Build", 48);
public KeyBinding chat = new KeyBinding("Chat", 20);
public KeyBinding toggleFog = new KeyBinding("Toggle fog", 33);
public KeyBinding save = new KeyBinding("Save location", 28);
public KeyBinding load = new KeyBinding("Load location", 19);
public KeyBinding[] keyBindings = new KeyBinding[]{this.forward, this.left, this.back, this.right, this.jump, this.build, this.chat, this.toggleFog, this.save, this.load};
private File optionsFile;
public Options(Minecraft var1, File var2) {
this.optionsFile = new File(var2, "options.txt");
this.loadOptions();
}
public final String getKeyBinding(int var1) {
return this.keyBindings[var1].name + ": " + Keyboard.getKeyName(this.keyBindings[var1].key);
}
public final void setKeyBinding(int var1, int var2) {
this.keyBindings[var1].key = var2;
this.saveOptions();
}
public final void setOption(int var1, int var2) {
if(var1 == 0) {
this.music = !this.music;
}
if(var1 == 1) {
this.sound = !this.sound;
}
if(var1 == 2) {
this.invertMouse = !this.invertMouse;
}
if(var1 == 3) {
this.showFPS = !this.showFPS;
}
if(var1 == 4) {
this.renderDistance = this.renderDistance + var2 & 3;
}
this.saveOptions();
}
public final String getOption(int var1) {
return var1 == 0 ? "Music: " + (this.music ? "ON" : "OFF") : (var1 == 1 ? "Sound: " + (this.sound ? "ON" : "OFF") : (var1 == 2 ? "Invert mouse: " + (this.invertMouse ? "ON" : "OFF") : (var1 == 3 ? "Show FPS: " + (this.showFPS ? "ON" : "OFF") : (var1 == 4 ? "Render distance: " + RENDER_DISTANCES[this.renderDistance] : ""))));
}
private void loadOptions() {
try {
if(this.optionsFile.exists()) {
BufferedReader var1 = new BufferedReader(new FileReader(this.optionsFile));
String var2 = null;
while(true) {
var2 = var1.readLine();
if(var2 == null) {
var1.close();
return;
}
String[] var5 = var2.split(":");
if(var5[0].equals("music")) {
this.music = var5[1].equals("true");
}
if(var5[0].equals("sound")) {
this.sound = var5[1].equals("true");
}
if(var5[0].equals("invertYMouse")) {
this.invertMouse = var5[1].equals("true");
}
if(var5[0].equals("showFrameRate")) {
this.showFPS = var5[1].equals("true");
}
if(var5[0].equals("viewDistance")) {
this.renderDistance = Integer.parseInt(var5[1]);
}
for(int var3 = 0; var3 < this.keyBindings.length; ++var3) {
if(var5[0].equals("key_" + this.keyBindings[var3].name)) {
this.keyBindings[var3].key = Integer.parseInt(var5[1]);
}
}
}
}
} catch (Exception var4) {
System.out.println("Failed to load options");
var4.printStackTrace();
}
}
private void saveOptions() {
try {
PrintWriter var1 = new PrintWriter(new FileWriter(this.optionsFile));
var1.println("music:" + this.music);
var1.println("sound:" + this.sound);
var1.println("invertYMouse:" + this.invertMouse);
var1.println("showFrameRate:" + this.showFPS);
var1.println("viewDistance:" + this.renderDistance);
for(int var2 = 0; var2 < this.keyBindings.length; ++var2) {
var1.println("key_" + this.keyBindings[var2].name + ":" + this.keyBindings[var2].key);
}
var1.close();
} catch (Exception var3) {
System.out.println("Failed to save options");
var3.printStackTrace();
}
}
}

View File

@ -0,0 +1,90 @@
package com.mojang.minecraft;
import com.mojang.minecraft.renderer.Tesselator;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
public final class ProgressListener {
private String title = "";
private Minecraft minecraft;
private String text = "";
public ProgressListener(Minecraft var1) {
this.minecraft = var1;
}
public final void beginLevelLoading(String var1) {
if(!this.minecraft.running) {
throw new StopGameException();
} else {
this.text = var1;
int var3 = this.minecraft.width * 240 / this.minecraft.height;
int var2 = this.minecraft.height * 240 / this.minecraft.height;
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0.0D, (double)var3, (double)var2, 0.0D, 100.0D, 300.0D);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glTranslatef(0.0F, 0.0F, -200.0F);
}
}
public final void levelLoadUpdate(String var1) {
if(!this.minecraft.running) {
throw new StopGameException();
} else {
this.title = var1;
this.setLoadingProgress(-1);
}
}
public final void setLoadingProgress(int var1) {
if(!this.minecraft.running) {
throw new StopGameException();
} else {
int var2 = this.minecraft.width * 240 / this.minecraft.height;
int var3 = this.minecraft.height * 240 / this.minecraft.height;
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_COLOR_BUFFER_BIT);
Tesselator var4 = Tesselator.instance;
GL11.glEnable(GL11.GL_TEXTURE_2D);
int var5 = this.minecraft.textures.getTextureId("/dirt.png");
GL11.glBindTexture(GL11.GL_TEXTURE_2D, var5);
float var8 = 32.0F;
var4.begin();
var4.color(4210752);
var4.vertexUV(0.0F, (float)var3, 0.0F, 0.0F, (float)var3 / var8);
var4.vertexUV((float)var2, (float)var3, 0.0F, (float)var2 / var8, (float)var3 / var8);
var4.vertexUV((float)var2, 0.0F, 0.0F, (float)var2 / var8, 0.0F);
var4.vertexUV(0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
var4.end();
if(var1 >= 0) {
var5 = var2 / 2 - 50;
int var6 = var3 / 2 + 16;
GL11.glDisable(GL11.GL_TEXTURE_2D);
var4.begin();
var4.color(8421504);
var4.vertex((float)var5, (float)var6, 0.0F);
var4.vertex((float)var5, (float)(var6 + 2), 0.0F);
var4.vertex((float)(var5 + 100), (float)(var6 + 2), 0.0F);
var4.vertex((float)(var5 + 100), (float)var6, 0.0F);
var4.color(8454016);
var4.vertex((float)var5, (float)var6, 0.0F);
var4.vertex((float)var5, (float)(var6 + 2), 0.0F);
var4.vertex((float)(var5 + var1), (float)(var6 + 2), 0.0F);
var4.vertex((float)(var5 + var1), (float)var6, 0.0F);
var4.end();
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
this.minecraft.font.drawShadow(this.text, (var2 - this.minecraft.font.width(this.text)) / 2, var3 / 2 - 4 - 16, 16777215);
this.minecraft.font.drawShadow(this.title, (var2 - this.minecraft.font.width(this.title)) / 2, var3 / 2 - 4 + 8, 16777215);
Display.update();
try {
Thread.yield();
} catch (Exception var7) {
}
}
}
}

View File

@ -0,0 +1,17 @@
package com.mojang.minecraft;
final class SleepThread extends Thread {
SleepThread(Minecraft var1) {
this.setDaemon(true);
this.start();
}
public final void run() {
while(true) {
try {
Thread.sleep(2147483647L);
} catch (InterruptedException var1) {
}
}
}
}

View File

@ -0,0 +1,4 @@
package com.mojang.minecraft;
public class StopGameException extends Error {
}

View File

@ -0,0 +1,19 @@
package com.mojang.minecraft;
public final class Timer {
float ticksPerSecond;
double lastHRTime;
public int ticks;
public float a;
public float timeScale = 1.0F;
public float fps = 0.0F;
long lastSyncSysClock;
long lastSyncHRClock;
double timeSyncAdjustment = 1.0D;
public Timer(float var1) {
this.ticksPerSecond = var1;
this.lastSyncSysClock = System.currentTimeMillis();
this.lastSyncHRClock = System.nanoTime() / 1000000L;
}
}

View File

@ -0,0 +1,52 @@
package com.mojang.minecraft;
import com.mojang.minecraft.level.tile.Tile;
import java.util.ArrayList;
import java.util.List;
public final class User {
public static List creativeTiles;
public String name;
public String sessionId;
public String mpPass;
public User(String var1, String var2) {
this.name = var1;
this.sessionId = var2;
}
static {
(creativeTiles = new ArrayList()).add(Tile.rock);
creativeTiles.add(Tile.wood);
creativeTiles.add(Tile.dirt);
creativeTiles.add(Tile.stoneBrick);
creativeTiles.add(Tile.log);
creativeTiles.add(Tile.leaf);
creativeTiles.add(Tile.bush);
creativeTiles.add(Tile.plantYellow);
creativeTiles.add(Tile.plantRed);
creativeTiles.add(Tile.mushroomBrown);
creativeTiles.add(Tile.mushroomRed);
creativeTiles.add(Tile.sand);
creativeTiles.add(Tile.gravel);
creativeTiles.add(Tile.glass);
creativeTiles.add(Tile.sponge);
creativeTiles.add(Tile.blockGold);
creativeTiles.add(Tile.clothRed);
creativeTiles.add(Tile.clothOrange);
creativeTiles.add(Tile.clothYellow);
creativeTiles.add(Tile.clothChartreuse);
creativeTiles.add(Tile.clothGreen);
creativeTiles.add(Tile.clothSpringGreen);
creativeTiles.add(Tile.clothCyan);
creativeTiles.add(Tile.clothCapri);
creativeTiles.add(Tile.clothUltramarine);
creativeTiles.add(Tile.clothViolet);
creativeTiles.add(Tile.clothPurple);
creativeTiles.add(Tile.clothMagenta);
creativeTiles.add(Tile.clothRose);
creativeTiles.add(Tile.clothDarkGray);
creativeTiles.add(Tile.clothGray);
creativeTiles.add(Tile.clothWhite);
}
}

View File

@ -0,0 +1,98 @@
package com.mojang.minecraft.character;
import org.lwjgl.opengl.GL11;
public final class Cube {
private Vertex[] vertices;
private Polygon[] polygons;
private int xTexOffs;
private int yTexOffs;
private float x;
private float y;
private float z;
public float xRot;
public float yRot;
public float zRot;
private boolean compiled = false;
private int list = 0;
public Cube(int var1, int var2) {
this.xTexOffs = var1;
this.yTexOffs = var2;
}
public final void addBox(float var1, float var2, float var3, int var4, int var5, int var6) {
this.vertices = new Vertex[8];
this.polygons = new Polygon[6];
float var7 = var1 + (float)var4;
float var8 = var2 + (float)var5;
float var9 = var3 + (float)var6;
Vertex var10 = new Vertex(var1, var2, var3, 0.0F, 0.0F);
Vertex var11 = new Vertex(var7, var2, var3, 0.0F, 8.0F);
Vertex var12 = new Vertex(var7, var8, var3, 8.0F, 8.0F);
Vertex var16 = new Vertex(var1, var8, var3, 8.0F, 0.0F);
Vertex var13 = new Vertex(var1, var2, var9, 0.0F, 0.0F);
Vertex var15 = new Vertex(var7, var2, var9, 0.0F, 8.0F);
Vertex var17 = new Vertex(var7, var8, var9, 8.0F, 8.0F);
Vertex var14 = new Vertex(var1, var8, var9, 8.0F, 0.0F);
this.vertices[0] = var10;
this.vertices[1] = var11;
this.vertices[2] = var12;
this.vertices[3] = var16;
this.vertices[4] = var13;
this.vertices[5] = var15;
this.vertices[6] = var17;
this.vertices[7] = var14;
this.polygons[0] = new Polygon(new Vertex[]{var15, var11, var12, var17}, this.xTexOffs + var6 + var4, this.yTexOffs + var6, this.xTexOffs + var6 + var4 + var6, this.yTexOffs + var6 + var5);
this.polygons[1] = new Polygon(new Vertex[]{var10, var13, var14, var16}, this.xTexOffs, this.yTexOffs + var6, this.xTexOffs + var6, this.yTexOffs + var6 + var5);
this.polygons[2] = new Polygon(new Vertex[]{var15, var13, var10, var11}, this.xTexOffs + var6, this.yTexOffs, this.xTexOffs + var6 + var4, this.yTexOffs + var6);
this.polygons[3] = new Polygon(new Vertex[]{var12, var16, var14, var17}, this.xTexOffs + var6 + var4, this.yTexOffs, this.xTexOffs + var6 + var4 + var4, this.yTexOffs + var6);
this.polygons[4] = new Polygon(new Vertex[]{var11, var10, var16, var12}, this.xTexOffs + var6, this.yTexOffs + var6, this.xTexOffs + var6 + var4, this.yTexOffs + var6 + var5);
this.polygons[5] = new Polygon(new Vertex[]{var13, var15, var17, var14}, this.xTexOffs + var6 + var4 + var6, this.yTexOffs + var6, this.xTexOffs + var6 + var4 + var6 + var4, this.yTexOffs + var6 + var5);
}
public final void setPos(float var1, float var2, float var3) {
this.x = var1;
this.y = var2;
this.z = 0.0F;
}
public final void render(float var1) {
if(!this.compiled) {
float var3 = var1;
Cube var2 = this;
this.list = GL11.glGenLists(1);
GL11.glNewList(this.list, GL11.GL_COMPILE);
GL11.glBegin(GL11.GL_QUADS);
for(int var4 = 0; var4 < var2.polygons.length; ++var4) {
Polygon var10000 = var2.polygons[var4];
float var6 = var3;
Polygon var5 = var10000;
Vec3 var7 = var5.vertices[1].pos.subtract(var5.vertices[0].pos).normalize();
Vec3 var8 = var5.vertices[1].pos.subtract(var5.vertices[2].pos).normalize();
var7 = (new Vec3(var7.y * var8.z - var7.z * var8.y, var7.z * var8.x - var7.x * var8.z, var7.x * var8.y - var7.y * var8.x)).normalize();
GL11.glNormal3f(var7.x, var7.y, var7.z);
for(int var10 = 0; var10 < 4; ++var10) {
Vertex var11 = var5.vertices[var10];
GL11.glTexCoord2f(var11.u / 64.0F, var11.v / 32.0F);
GL11.glVertex3f(var11.pos.x * var6, var11.pos.y * var6, var11.pos.z * var6);
}
}
GL11.glEnd();
GL11.glEndList();
var2.compiled = true;
}
float var9 = 57.29578F;
GL11.glPushMatrix();
GL11.glTranslatef(this.x * var1, this.y * var1, this.z * var1);
GL11.glRotatef(this.zRot * var9, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(this.yRot * var9, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(this.xRot * var9, 1.0F, 0.0F, 0.0F);
GL11.glCallList(this.list);
GL11.glPopMatrix();
}
}

View File

@ -0,0 +1,17 @@
package com.mojang.minecraft.character;
public final class Polygon {
public Vertex[] vertices;
private Polygon(Vertex[] var1) {
this.vertices = var1;
}
public Polygon(Vertex[] var1, int var2, int var3, int var4, int var5) {
this(var1);
var1[0] = var1[0].remap((float)var4, (float)var3);
var1[1] = var1[1].remap((float)var2, (float)var3);
var1[2] = var1[2].remap((float)var2, (float)var5);
var1[3] = var1[3].remap((float)var4, (float)var5);
}
}

View File

@ -0,0 +1,22 @@
package com.mojang.minecraft.character;
public final class Vec3 {
public float x;
public float y;
public float z;
public Vec3(float var1, float var2, float var3) {
this.x = var1;
this.y = var2;
this.z = var3;
}
public final Vec3 subtract(Vec3 var1) {
return new Vec3(this.x - var1.x, this.y - var1.y, this.z - var1.z);
}
public final Vec3 normalize() {
float var1 = (float)Math.sqrt((double)(this.x * this.x + this.y * this.y + this.z * this.z));
return new Vec3(this.x / var1, this.y / var1, this.z / var1);
}
}

View File

@ -0,0 +1,27 @@
package com.mojang.minecraft.character;
public final class Vertex {
public Vec3 pos;
public float u;
public float v;
public Vertex(float var1, float var2, float var3, float var4, float var5) {
this(new Vec3(var1, var2, var3), var4, var5);
}
public final Vertex remap(float var1, float var2) {
return new Vertex(this, var1, var2);
}
private Vertex(Vertex var1, float var2, float var3) {
this.pos = var1.pos;
this.u = var2;
this.v = var3;
}
private Vertex(Vec3 var1, float var2, float var3) {
this.pos = var1;
this.u = var2;
this.v = var3;
}
}

View File

@ -0,0 +1,75 @@
package com.mojang.minecraft.character;
import com.mojang.minecraft.Entity;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.renderer.Textures;
import org.lwjgl.opengl.GL11;
public class Zombie extends Entity {
public static final long serialVersionUID = 77479605454997290L;
private static ZombieModel zombieModel = new ZombieModel();
public float rot;
public float timeOffs;
public float speed;
public float rotA = (float)(Math.random() + 1.0D) * 0.01F;
public Zombie(Level var1, float var2, float var3, float var4) {
super(var1);
this.setPos(var2, var3, var4);
this.timeOffs = (float)Math.random() * 1239813.0F;
this.rot = (float)(Math.random() * Math.PI * 2.0D);
this.speed = 1.0F;
}
public void tick() {
this.xo = this.x;
this.yo = this.y;
this.zo = this.z;
float var1 = 0.0F;
float var2 = 0.0F;
if(this.y < -100.0F) {
this.remove();
}
this.rot += this.rotA;
this.rotA = (float)((double)this.rotA * 0.99D);
this.rotA = (float)((double)this.rotA + (Math.random() - Math.random()) * Math.random() * Math.random() * (double)0.08F);
var1 = (float)Math.sin((double)this.rot);
var2 = (float)Math.cos((double)this.rot);
if(this.onGround && Math.random() < 0.08D) {
this.yd = 0.5F;
}
this.moveRelative(var1, var2, this.onGround ? 0.1F : 0.02F);
this.yd = (float)((double)this.yd - 0.08D);
this.move(this.xd, this.yd, this.zd);
this.xd *= 0.91F;
this.yd *= 0.98F;
this.zd *= 0.91F;
if(this.onGround) {
this.xd *= 0.7F;
this.zd *= 0.7F;
}
}
public void render(Textures var1, float var2) {
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, var1.getTextureId("/char.png"));
GL11.glPushMatrix();
double var3 = (double)System.nanoTime() / 1.0E9D * 10.0D * (double)this.speed + (double)this.timeOffs;
float var6 = this.getBrightness();
GL11.glColor3f(var6, var6, var6);
var6 = 0.058333334F;
float var5 = (float)(-Math.abs(Math.sin(var3 * 0.6662D)) * 5.0D - 23.0D);
GL11.glTranslatef(this.xo + (this.x - this.xo) * var2, this.yo + (this.y - this.yo) * var2, this.zo + (this.z - this.zo) * var2);
GL11.glScalef(1.0F, -1.0F, 1.0F);
GL11.glTranslatef(0.0F, var5 * var6, 0.0F);
var2 = 57.29578F;
GL11.glRotatef(this.rot * var2 + 180.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(-1.0F, 1.0F, 1.0F);
zombieModel.render((float)var3, 1.0F, 0.0F, 0.0F, 0.0F, var6);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_TEXTURE_2D);
}
}

View File

@ -0,0 +1,49 @@
package com.mojang.minecraft.character;
public final class ZombieModel {
private Cube head = new Cube(0, 0);
private Cube body;
private Cube arm0;
private Cube arm1;
private Cube leg0;
private Cube leg1;
public ZombieModel() {
this.head.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8);
this.body = new Cube(16, 16);
this.body.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4);
this.arm0 = new Cube(40, 16);
this.arm0.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4);
this.arm0.setPos(-5.0F, 2.0F, 0.0F);
this.arm1 = new Cube(40, 16);
this.arm1.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4);
this.arm1.setPos(5.0F, 2.0F, 0.0F);
this.leg0 = new Cube(0, 16);
this.leg0.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4);
this.leg0.setPos(-2.0F, 12.0F, 0.0F);
this.leg1 = new Cube(0, 16);
this.leg1.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4);
this.leg1.setPos(2.0F, 12.0F, 0.0F);
}
public final void render(float var1, float var2, float var3, float var4, float var5, float var6) {
this.head.yRot = var4 / 57.29578F;
this.head.xRot = var5 / 57.29578F;
this.arm0.xRot = (float)Math.cos((double)var1 * 0.6662D + Math.PI) * 2.0F * var2;
this.arm0.zRot = (float)(Math.cos((double)var1 * 0.2312D) + 1.0D) * var2;
this.arm1.xRot = (float)Math.cos((double)var1 * 0.6662D) * 2.0F * var2;
this.arm1.zRot = (float)(Math.cos((double)var1 * 0.2812D) - 1.0D) * var2;
this.leg0.xRot = (float)Math.cos((double)var1 * 0.6662D) * 1.4F * var2;
this.leg1.xRot = (float)Math.cos((double)var1 * 0.6662D + Math.PI) * 1.4F * var2;
this.arm0.zRot += (float)Math.cos((double)var3 * 0.09D) * 0.05F + 0.05F;
this.arm1.zRot -= (float)Math.cos((double)var3 * 0.09D) * 0.05F + 0.05F;
this.arm0.xRot += (float)Math.sin((double)var3 * 0.067D) * 0.05F;
this.arm1.xRot -= (float)Math.sin((double)var3 * 0.067D) * 0.05F;
this.head.render(var6);
this.body.render(var6);
this.arm0.render(var6);
this.arm1.render(var6);
this.leg0.render(var6);
this.leg1.render(var6);
}
}

View File

@ -0,0 +1,29 @@
package com.mojang.minecraft.gui;
public class Button extends Gui {
int x;
int y;
public int w;
public int h;
public String msg;
public int id;
public boolean enabled;
public boolean visible;
public Button(int var1, int var2, int var3, String var4) {
this(var1, var2, var3, 200, 20, var4);
}
protected Button(int var1, int var2, int var3, int var4, int var5, String var6) {
this.x = 200;
this.y = 20;
this.enabled = true;
this.visible = true;
this.id = var1;
this.w = var2;
this.h = var3;
this.x = var4;
this.y = 20;
this.msg = var6;
}
}

View File

@ -0,0 +1,67 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.net.ConnectionManager;
import com.mojang.minecraft.net.Packet;
import org.lwjgl.input.Keyboard;
public final class ChatScreen extends Screen {
private String typedMsg = "";
private int counter = 0;
public final void init() {
Keyboard.enableRepeatEvents(true);
}
public final void closeScreen() {
Keyboard.enableRepeatEvents(false);
}
public final void tick() {
++this.counter;
}
protected final void keyPressed(char var1, int var2) {
if(var2 == 1) {
this.minecraft.setScreen((Screen)null);
} else if(var2 == 28) {
ConnectionManager var10000 = this.minecraft.connectionManager;
String var4 = this.typedMsg.trim();
ConnectionManager var3 = var10000;
var4 = var4.trim();
if(var4.length() > 0) {
var3.connection.sendPacket(Packet.CHAT_MESSAGE, new Object[]{Integer.valueOf(-1), var4});
}
this.minecraft.setScreen((Screen)null);
} else {
if(var2 == 14 && this.typedMsg.length() > 0) {
this.typedMsg = this.typedMsg.substring(0, this.typedMsg.length() - 1);
}
if("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ,.:-_\'*!\\\"#%/()=+?[]{}<>@|$;".indexOf(var1) >= 0 && this.typedMsg.length() < 64 - (this.minecraft.user.name.length() + 2)) {
this.typedMsg = this.typedMsg + var1;
}
}
}
public final void render(int var1, int var2) {
fill(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
drawString(this.font, "> " + this.typedMsg + (this.counter / 6 % 2 == 0 ? "_" : ""), 4, this.height - 12, 14737632);
}
protected final void mousePressed(int var1, int var2, int var3) {
if(var3 == 0 && this.minecraft.hud.hoveredUsername != null) {
if(this.typedMsg.length() > 0 && !this.typedMsg.endsWith(" ")) {
this.typedMsg = this.typedMsg + " ";
}
this.typedMsg = this.typedMsg + this.minecraft.hud.hoveredUsername;
var1 = 64 - (this.minecraft.user.name.length() + 2);
if(this.typedMsg.length() > var1) {
this.typedMsg = this.typedMsg.substring(0, var1);
}
}
}
}

View File

@ -0,0 +1,52 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.Options;
public final class ControlsScreen extends Screen {
private Screen parent;
private String title = "Controls";
private Options options;
private int selectedKey = -1;
public ControlsScreen(Screen var1, Options var2) {
this.parent = var1;
this.options = var2;
}
public final void init() {
for(int var1 = 0; var1 < this.options.keyBindings.length; ++var1) {
this.buttons.add(new KeyBindingButton(var1, this.width / 2 - 155 + var1 % 2 * 160, this.height / 6 + 24 * (var1 >> 1), this.options.getKeyBinding(var1)));
}
this.buttons.add(new Button(200, this.width / 2 - 100, this.height / 6 + 168, "Done"));
}
protected final void buttonClicked(Button var1) {
for(int var2 = 0; var2 < this.options.keyBindings.length; ++var2) {
((Button)this.buttons.get(var2)).msg = this.options.getKeyBinding(var2);
}
if(var1.id == 200) {
this.minecraft.setScreen(this.parent);
} else {
this.selectedKey = var1.id;
var1.msg = "> " + this.options.getKeyBinding(var1.id) + " <";
}
}
protected final void keyPressed(char var1, int var2) {
if(this.selectedKey >= 0) {
this.options.setKeyBinding(this.selectedKey, var2);
((Button)this.buttons.get(this.selectedKey)).msg = this.options.getKeyBinding(this.selectedKey);
this.selectedKey = -1;
} else {
super.keyPressed(var1, var2);
}
}
public final void render(int var1, int var2) {
fillGradient(0, 0, this.width, this.height, 1610941696, -1607454624);
drawCenteredString(this.font, this.title, this.width / 2, 20, 16777215);
super.render(var1, var2);
}
}

View File

@ -0,0 +1,24 @@
package com.mojang.minecraft.gui;
public final class ErrorScreen extends Screen {
private String title;
private String desc;
public ErrorScreen(String var1, String var2) {
this.title = var1;
this.desc = var2;
}
public final void init() {
}
public final void render(int var1, int var2) {
fillGradient(0, 0, this.width, this.height, -12574688, -11530224);
drawCenteredString(this.font, this.title, this.width / 2, 90, 16777215);
drawCenteredString(this.font, this.desc, this.width / 2, 110, 16777215);
super.render(var1, var2);
}
protected final void keyPressed(char var1, int var2) {
}
}

View File

@ -0,0 +1,147 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.renderer.Tesselator;
import com.mojang.minecraft.renderer.Textures;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.lwjgl.opengl.GL11;
public final class Font {
private int[] charWidths = new int[256];
private int fontTexture = 0;
public Font(String var1, Textures var2) {
BufferedImage var3;
try {
var3 = ImageIO.read(Textures.class.getResourceAsStream(var1));
} catch (IOException var13) {
throw new RuntimeException(var13);
}
int var4 = var3.getWidth();
int var5 = var3.getHeight();
int[] var6 = new int[var4 * var5];
var3.getRGB(0, 0, var4, var5, var6, 0, var4);
for(int var14 = 0; var14 < 128; ++var14) {
var5 = var14 % 16;
int var7 = var14 / 16;
int var8 = 0;
for(boolean var9 = false; var8 < 8 && !var9; ++var8) {
int var10 = (var5 << 3) + var8;
var9 = true;
for(int var11 = 0; var11 < 8 && var9; ++var11) {
int var12 = ((var7 << 3) + var11) * var4;
var12 = var6[var10 + var12] & 255;
if(var12 > 128) {
var9 = false;
}
}
}
if(var14 == 32) {
var8 = 4;
}
this.charWidths[var14] = var8;
}
this.fontTexture = var2.getTextureId(var1);
}
public final void drawShadow(String var1, int var2, int var3, int var4) {
this.draw(var1, var2 + 1, var3 + 1, var4, true);
this.draw(var1, var2, var3, var4);
}
public final void draw(String var1, int var2, int var3, int var4) {
this.draw(var1, var2, var3, var4, false);
}
private void draw(String var1, int var2, int var3, int var4, boolean var5) {
if(var1 != null) {
char[] var12 = var1.toCharArray();
if(var5) {
var4 = (var4 & 16579836) >> 2;
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.fontTexture);
Tesselator var6 = Tesselator.instance;
var6.begin();
var6.color(var4);
int var7 = 0;
for(int var8 = 0; var8 < var12.length; ++var8) {
int var9;
if(var12[var8] == 38 && var12.length > var8 + 1) {
var4 = "0123456789abcdef".indexOf(var12[var8 + 1]);
if(var4 < 0) {
var4 = 15;
}
var9 = (var4 & 8) << 3;
int var10 = (var4 & 1) * 191 + var9;
int var11 = ((var4 & 2) >> 1) * 191 + var9;
var4 = ((var4 & 4) >> 2) * 191 + var9;
var4 = var4 << 16 | var11 << 8 | var10;
var8 += 2;
if(var5) {
var4 = (var4 & 16579836) >> 2;
}
var6.color(var4);
}
var4 = var12[var8] % 16 << 3;
var9 = var12[var8] / 16 << 3;
float var13 = 7.99F;
var6.vertexUV((float)(var2 + var7), (float)var3 + var13, 0.0F, (float)var4 / 128.0F, ((float)var9 + var13) / 128.0F);
var6.vertexUV((float)(var2 + var7) + var13, (float)var3 + var13, 0.0F, ((float)var4 + var13) / 128.0F, ((float)var9 + var13) / 128.0F);
var6.vertexUV((float)(var2 + var7) + var13, (float)var3, 0.0F, ((float)var4 + var13) / 128.0F, (float)var9 / 128.0F);
var6.vertexUV((float)(var2 + var7), (float)var3, 0.0F, (float)var4 / 128.0F, (float)var9 / 128.0F);
var7 += this.charWidths[var12[var8]];
}
var6.end();
GL11.glDisable(GL11.GL_TEXTURE_2D);
}
}
public final int width(String var1) {
if(var1 == null) {
return 0;
} else {
char[] var4 = var1.toCharArray();
int var2 = 0;
for(int var3 = 0; var3 < var4.length; ++var3) {
if(var4[var3] == 38) {
++var3;
} else {
var2 += this.charWidths[var4[var3]];
}
}
return var2;
}
}
public static String removeColorCodes(String var0) {
char[] var3 = var0.toCharArray();
String var1 = "";
for(int var2 = 0; var2 < var3.length; ++var2) {
if(var3[var2] == 38) {
++var2;
} else {
var1 = var1 + var3[var2];
}
}
return var1;
}
}

View File

@ -0,0 +1,68 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.renderer.Tesselator;
import org.lwjgl.opengl.GL11;
public class Gui {
protected float zLevel = 0.0F;
protected static void fill(int var0, int var1, int var2, int var3, int var4) {
float var5 = (float)(var4 >>> 24) / 255.0F;
float var6 = (float)(var4 >> 16 & 255) / 255.0F;
float var7 = (float)(var4 >> 8 & 255) / 255.0F;
float var9 = (float)(var4 & 255) / 255.0F;
Tesselator var8 = Tesselator.instance;
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(var6, var7, var9, var5);
var8.begin();
var8.vertex((float)var0, (float)var3, 0.0F);
var8.vertex((float)var2, (float)var3, 0.0F);
var8.vertex((float)var2, (float)var1, 0.0F);
var8.vertex((float)var0, (float)var1, 0.0F);
var8.end();
GL11.glDisable(GL11.GL_BLEND);
}
protected static void fillGradient(int var0, int var1, int var2, int var3, int var4, int var5) {
float var6 = (float)(var4 >>> 24) / 255.0F;
float var7 = (float)(var4 >> 16 & 255) / 255.0F;
float var8 = (float)(var4 >> 8 & 255) / 255.0F;
float var12 = (float)(var4 & 255) / 255.0F;
float var9 = (float)(var5 >>> 24) / 255.0F;
float var10 = (float)(var5 >> 16 & 255) / 255.0F;
float var11 = (float)(var5 >> 8 & 255) / 255.0F;
float var13 = (float)(var5 & 255) / 255.0F;
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glBegin(GL11.GL_QUADS);
GL11.glColor4f(var7, var8, var12, var6);
GL11.glVertex2f((float)var2, (float)var1);
GL11.glVertex2f((float)var0, (float)var1);
GL11.glColor4f(var10, var11, var13, var9);
GL11.glVertex2f((float)var0, (float)var3);
GL11.glVertex2f((float)var2, (float)var3);
GL11.glEnd();
GL11.glDisable(GL11.GL_BLEND);
}
public static void drawCenteredString(Font var0, String var1, int var2, int var3, int var4) {
var0.drawShadow(var1, var2 - var0.width(var1) / 2, var3, var4);
}
public static void drawString(Font var0, String var1, int var2, int var3, int var4) {
var0.drawShadow(var1, var2, var3, var4);
}
public final void blit(int var1, int var2, int var3, int var4, int var5, int var6) {
float var7 = 0.00390625F;
float var8 = 0.00390625F;
Tesselator var9 = Tesselator.instance;
var9.begin();
var9.vertexUV((float)var1, (float)(var2 + var6), this.zLevel, (float)var3 * var7, (float)(var4 + var6) * var8);
var9.vertexUV((float)(var1 + var5), (float)(var2 + var6), this.zLevel, (float)(var3 + var5) * var7, (float)(var4 + var6) * var8);
var9.vertexUV((float)(var1 + var5), (float)var2, this.zLevel, (float)(var3 + var5) * var7, (float)var4 * var8);
var9.vertexUV((float)var1, (float)var2, this.zLevel, (float)var3 * var7, (float)var4 * var8);
var9.end();
}
}

View File

@ -0,0 +1,150 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.ChatLine;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.tile.Tile;
import com.mojang.minecraft.net.ConnectionManager;
import com.mojang.minecraft.net.NetworkPlayer;
import com.mojang.minecraft.player.Inventory;
import com.mojang.minecraft.renderer.Tesselator;
import com.mojang.minecraft.renderer.Textures;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
public final class InGameHud extends Gui {
public List messages = new ArrayList();
private Minecraft minecraft;
private int scaledWidth;
private int scaledHeight;
public String hoveredUsername = null;
public InGameHud(Minecraft var1, int var2, int var3) {
this.minecraft = var1;
this.scaledWidth = var2 * 240 / var3;
this.scaledHeight = var3 * 240 / var3;
}
public final void render(boolean var1, int var2, int var3) {
Font var4 = this.minecraft.font;
this.minecraft.renderHelper.initGui();
Textures var5 = this.minecraft.textures;
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.minecraft.textures.getTextureId("/gui.png"));
GL11.glEnable(GL11.GL_TEXTURE_2D);
Tesselator var6 = Tesselator.instance;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL11.GL_BLEND);
Inventory var7 = this.minecraft.player.inventory;
this.zLevel = -90.0F;
this.blit(this.scaledWidth / 2 - 91, this.scaledHeight - 22, 0, 0, 182, 22);
this.blit(this.scaledWidth / 2 - 91 - 1 + var7.selectedSlot * 20, this.scaledHeight - 22 - 1, 0, 22, 24, 22);
GL11.glDisable(GL11.GL_BLEND);
int var8;
int var9;
int var10;
for(var8 = 0; var8 < var7.slots.length; ++var8) {
var9 = var7.slots[var8];
if(var9 > 0) {
GL11.glPushMatrix();
GL11.glTranslatef((float)(this.scaledWidth / 2 - 90 + var8 * 20), (float)(this.scaledHeight - 16), -50.0F);
GL11.glScalef(10.0F, 10.0F, 10.0F);
GL11.glTranslatef(1.0F, 0.5F, 0.0F);
GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-1.5F, 0.5F, 0.5F);
GL11.glScalef(-1.0F, -1.0F, -1.0F);
var10 = var5.getTextureId("/terrain.png");
GL11.glBindTexture(GL11.GL_TEXTURE_2D, var10);
GL11.glEnable(GL11.GL_TEXTURE_2D);
var6.begin();
Tile.tiles[var9].render(var6, this.minecraft.level, 0, -2, 0, 0);
var6.end();
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glPopMatrix();
}
}
var4.drawShadow("0.0.23a_01", 2, 2, 16777215);
if(this.minecraft.options.showFPS) {
var4.drawShadow(this.minecraft.fpsString, 2, 12, 16777215);
}
byte var18 = 10;
boolean var19 = false;
if(this.minecraft.screen instanceof ChatScreen) {
var18 = 20;
var19 = true;
}
for(var10 = 0; var10 < this.messages.size() && var10 < var18; ++var10) {
if(((ChatLine)this.messages.get(var10)).counter < 200 || var19) {
var4.drawShadow(((ChatLine)this.messages.get(var10)).message, 2, this.scaledHeight - 8 - var10 * 9 - 20, 16777215);
}
}
var10 = this.scaledWidth / 2;
int var11 = this.scaledHeight / 2;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
var6.begin();
var6.vertex((float)(var10 + 1), (float)(var11 - 4), 0.0F);
var6.vertex((float)var10, (float)(var11 - 4), 0.0F);
var6.vertex((float)var10, (float)(var11 + 5), 0.0F);
var6.vertex((float)(var10 + 1), (float)(var11 + 5), 0.0F);
var6.vertex((float)(var10 + 5), (float)var11, 0.0F);
var6.vertex((float)(var10 - 4), (float)var11, 0.0F);
var6.vertex((float)(var10 - 4), (float)(var11 + 1), 0.0F);
var6.vertex((float)(var10 + 5), (float)(var11 + 1), 0.0F);
var6.end();
this.hoveredUsername = null;
if(Keyboard.isKeyDown(Keyboard.KEY_TAB) && this.minecraft.connectionManager != null && this.minecraft.connectionManager.isConnected()) {
ConnectionManager var12 = this.minecraft.connectionManager;
ArrayList var15 = new ArrayList();
var15.add(var12.minecraft.user.name);
Iterator var13 = var12.players.values().iterator();
while(var13.hasNext()) {
NetworkPlayer var20 = (NetworkPlayer)var13.next();
var15.add(var20.name);
}
ArrayList var14 = var15;
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glBegin(GL11.GL_QUADS);
GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.7F);
GL11.glVertex2f((float)(var10 + 128), (float)(var11 - 68 - 12));
GL11.glVertex2f((float)(var10 - 128), (float)(var11 - 68 - 12));
GL11.glColor4f(0.2F, 0.2F, 0.2F, 0.8F);
GL11.glVertex2f((float)(var10 - 128), (float)(var11 + 68));
GL11.glVertex2f((float)(var10 + 128), (float)(var11 + 68));
GL11.glEnd();
GL11.glDisable(GL11.GL_BLEND);
String var16 = "Connected players:";
var4.drawShadow(var16, var10 - var4.width(var16) / 2, var11 - 64 - 12, 16777215);
for(int var17 = 0; var17 < var14.size(); ++var17) {
var8 = var10 + var17 % 2 * 120 - 120;
var9 = var11 - 64 + (var17 / 2 << 3);
if(var1 && var2 >= var8 && var3 >= var9 && var2 < var8 + 120 && var3 < var9 + 8) {
this.hoveredUsername = (String)var14.get(var17);
var4.draw((String)var14.get(var17), var8 + 2, var9, 16777215);
} else {
var4.draw((String)var14.get(var17), var8, var9, 15658734);
}
}
}
}
public final void addChatMessage(String var1) {
this.messages.add(0, new ChatLine(var1));
while(this.messages.size() > 50) {
this.messages.remove(this.messages.size() - 1);
}
}
}

View File

@ -0,0 +1,81 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.User;
import com.mojang.minecraft.level.tile.Tile;
import com.mojang.minecraft.player.Inventory;
import com.mojang.minecraft.renderer.Tesselator;
import com.mojang.minecraft.renderer.Textures;
import org.lwjgl.opengl.GL11;
public final class InventoryScreen extends Screen {
public InventoryScreen() {
this.allowUserInput = true;
}
private int getTileAtSlot(int var1, int var2) {
for(int var3 = 0; var3 < User.creativeTiles.size(); ++var3) {
int var4 = this.width / 2 + var3 % 8 * 24 - 96 - 3;
int var5 = this.height / 2 + var3 / 8 * 24 - 48 + 3;
if(var1 >= var4 && var1 <= var4 + 24 && var2 >= var5 - 12 && var2 <= var5 + 12) {
return var3;
}
}
return -1;
}
public final void render(int var1, int var2) {
var1 = this.getTileAtSlot(var1, var2);
fillGradient(this.width / 2 - 120, 30, this.width / 2 + 120, 180, -1878719232, -1070583712);
if(var1 >= 0) {
var2 = this.width / 2 + var1 % 8 * 24 - 96;
int var3 = this.height / 2 + var1 / 8 * 24 - 48;
fillGradient(var2 - 3, var3 - 8, var2 + 23, var3 + 24 - 6, -1862270977, -1056964609);
}
drawCenteredString(this.font, "Select block", this.width / 2, 40, 16777215);
Textures var7 = this.minecraft.textures;
Tesselator var8 = Tesselator.instance;
var2 = var7.getTextureId("/terrain.png");
GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2);
GL11.glEnable(GL11.GL_TEXTURE_2D);
for(var2 = 0; var2 < User.creativeTiles.size(); ++var2) {
Tile var4 = (Tile)User.creativeTiles.get(var2);
GL11.glPushMatrix();
int var5 = this.width / 2 + var2 % 8 * 24 - 96;
int var6 = this.height / 2 + var2 / 8 * 24 - 48;
GL11.glTranslatef((float)var5, (float)var6, 0.0F);
GL11.glScalef(10.0F, 10.0F, 10.0F);
GL11.glTranslatef(1.0F, 0.5F, 8.0F);
GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
if(var1 == var2) {
GL11.glScalef(1.6F, 1.6F, 1.6F);
}
GL11.glTranslatef(-1.5F, 0.5F, 0.5F);
GL11.glScalef(-1.0F, -1.0F, -1.0F);
var8.begin();
var4.render(var8, this.minecraft.level, 0, -2, 0, 0);
var8.end();
GL11.glPopMatrix();
}
GL11.glDisable(GL11.GL_TEXTURE_2D);
}
protected final void mousePressed(int var1, int var2, int var3) {
if(var3 == 0) {
Inventory var10000 = this.minecraft.player.inventory;
var2 = this.getTileAtSlot(var1, var2);
Inventory var4 = var10000;
if(var2 >= 0) {
var4.setTile((Tile)User.creativeTiles.get(var2));
}
this.minecraft.setScreen((Screen)null);
}
}
}

View File

@ -0,0 +1,7 @@
package com.mojang.minecraft.gui;
public final class KeyBindingButton extends Button {
public KeyBindingButton(int var1, int var2, int var3, String var4) {
super(var1, var2, var3, 150, 20, var4);
}
}

View File

@ -0,0 +1,89 @@
package com.mojang.minecraft.gui;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
public class LoadLevelScreen extends Screen implements Runnable {
private Screen parent;
private boolean finished = false;
private boolean loaded = false;
private String[] levels = null;
private String status = "";
protected String title = "Load level";
public LoadLevelScreen(Screen var1) {
this.parent = var1;
}
public void run() {
try {
this.status = "Getting level list..";
URL var1 = new URL("http://" + this.minecraft.minecraftUri + "/listmaps.jsp?user=" + this.minecraft.user.name);
BufferedReader var3 = new BufferedReader(new InputStreamReader(var1.openConnection().getInputStream()));
this.levels = var3.readLine().split(";");
if(this.levels.length >= 5) {
this.setLevels(this.levels);
this.loaded = true;
return;
}
this.status = this.levels[0];
this.finished = true;
} catch (Exception var2) {
var2.printStackTrace();
this.status = "Failed to load levels";
this.finished = true;
}
}
protected void setLevels(String[] var1) {
for(int var2 = 0; var2 < 5; ++var2) {
((Button)this.buttons.get(var2)).enabled = !var1[var2].equals("-");
((Button)this.buttons.get(var2)).msg = var1[var2];
((Button)this.buttons.get(var2)).visible = true;
}
}
public final void init() {
(new Thread(this)).start();
for(int var1 = 0; var1 < 5; ++var1) {
this.buttons.add(new Button(var1, this.width / 2 - 100, this.height / 4 + var1 * 24, "---"));
((Button)this.buttons.get(var1)).visible = false;
}
this.buttons.add(new Button(5, this.width / 2 - 100, this.height / 4 + 144, "Cancel"));
}
protected final void buttonClicked(Button var1) {
if(var1.enabled) {
if(this.loaded && var1.id < 5) {
this.loadLevel(var1.id);
}
if(this.finished || this.loaded && var1.id == 5) {
this.minecraft.setScreen(this.parent);
}
}
}
protected void loadLevel(int var1) {
this.minecraft.loadLevel(this.minecraft.user.name, var1);
this.minecraft.setScreen((Screen)null);
this.minecraft.grabMouse();
}
public final void render(int var1, int var2) {
fillGradient(0, 0, this.width, this.height, 1610941696, -1607454624);
drawCenteredString(this.font, this.title, this.width / 2, 40, 16777215);
if(!this.loaded) {
drawCenteredString(this.font, this.status, this.width / 2, this.height / 2 - 4, 16777215);
}
super.render(var1, var2);
}
}

View File

@ -0,0 +1,81 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.Minecraft;
import org.lwjgl.input.Keyboard;
public final class NameLevelScreen extends Screen {
private Screen parent;
private String title = "Enter level name:";
private int id;
private String name;
private int counter = 0;
public NameLevelScreen(Screen var1, String var2, int var3) {
this.parent = var1;
this.id = var3;
this.name = var2;
if(this.name.equals("-")) {
this.name = "";
}
}
public final void init() {
this.buttons.clear();
Keyboard.enableRepeatEvents(true);
this.buttons.add(new Button(0, this.width / 2 - 100, this.height / 4 + 120, "Save"));
this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 4 + 144, "Cancel"));
((Button)this.buttons.get(0)).enabled = this.name.trim().length() > 1;
}
public final void closeScreen() {
Keyboard.enableRepeatEvents(false);
}
public final void tick() {
++this.counter;
}
protected final void buttonClicked(Button var1) {
if(var1.enabled) {
if(var1.id == 0 && this.name.trim().length() > 1) {
Minecraft var10000 = this.minecraft;
int var10001 = this.id;
String var4 = this.name.trim();
int var3 = var10001;
Minecraft var2 = var10000;
var2.levelIo.save(var2.level, var2.minecraftUri, var2.user.name, var2.user.sessionId, var4, var3);
this.minecraft.setScreen((Screen)null);
this.minecraft.grabMouse();
}
if(var1.id == 1) {
this.minecraft.setScreen(this.parent);
}
}
}
protected final void keyPressed(char var1, int var2) {
if(var2 == 14 && this.name.length() > 0) {
this.name = this.name.substring(0, this.name.length() - 1);
}
if("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ,.:-_\'*!\"#%/()=+?[]{}<>".indexOf(var1) >= 0 && this.name.length() < 64) {
this.name = this.name + var1;
}
((Button)this.buttons.get(0)).enabled = this.name.trim().length() > 1;
}
public final void render(int var1, int var2) {
fillGradient(0, 0, this.width, this.height, 1610941696, -1607454624);
drawCenteredString(this.font, this.title, this.width / 2, 40, 16777215);
int var3 = this.width / 2 - 100;
int var4 = this.height / 2 - 10;
fill(var3 - 1, var4 - 1, var3 + 200 + 1, var4 + 20 + 1, -6250336);
fill(var3, var4, var3 + 200, var4 + 20, -16777216);
drawString(this.font, this.name + (this.counter / 6 % 2 == 0 ? "_" : ""), var3 + 4, var4 + 6, 14737632);
super.render(var1, var2);
}
}

View File

@ -0,0 +1,33 @@
package com.mojang.minecraft.gui;
public final class NewLevelScreen extends Screen {
private Screen parent;
public NewLevelScreen(Screen var1) {
this.parent = var1;
}
public final void init() {
this.buttons.clear();
this.buttons.add(new Button(0, this.width / 2 - 100, this.height / 3, "Small"));
this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 3 + 32, "Normal"));
this.buttons.add(new Button(2, this.width / 2 - 100, this.height / 3 + 64, "Huge"));
this.buttons.add(new Button(3, this.width / 2 - 100, this.height / 3 + 96, "Cancel"));
}
protected final void buttonClicked(Button var1) {
if(var1.id == 3) {
this.minecraft.setScreen(this.parent);
} else {
this.minecraft.generateLevel(var1.id);
this.minecraft.setScreen((Screen)null);
this.minecraft.grabMouse();
}
}
public final void render(int var1, int var2) {
fillGradient(0, 0, this.width, this.height, 1610941696, -1607454624);
drawCenteredString(this.font, "Generate new level", this.width / 2, 40, 16777215);
super.render(var1, var2);
}
}

View File

@ -0,0 +1,47 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.Options;
public final class OptionsScreen extends Screen {
private Screen parent;
private String title = "Options";
private Options options;
public OptionsScreen(Screen var1, Options var2) {
this.parent = var1;
this.options = var2;
}
public final void init() {
for(int var1 = 0; var1 < 5; ++var1) {
this.buttons.add(new Button(var1, this.width / 2 - 100, this.height / 6 + var1 * 24, this.options.getOption(var1)));
}
this.buttons.add(new Button(10, this.width / 2 - 100, this.height / 6 + 120 + 12, "Controls..."));
this.buttons.add(new Button(20, this.width / 2 - 100, this.height / 6 + 168, "Done"));
}
protected final void buttonClicked(Button var1) {
if(var1.enabled) {
if(var1.id < 5) {
this.options.setOption(var1.id, 1);
var1.msg = this.options.getOption(var1.id);
}
if(var1.id == 10) {
this.minecraft.setScreen(new ControlsScreen(this, this.options));
}
if(var1.id == 20) {
this.minecraft.setScreen(this.parent);
}
}
}
public final void render(int var1, int var2) {
fillGradient(0, 0, this.width, this.height, 1610941696, -1607454624);
drawCenteredString(this.font, this.title, this.width / 2, 20, 16777215);
super.render(var1, var2);
}
}

View File

@ -0,0 +1,55 @@
package com.mojang.minecraft.gui;
public final class PauseScreen extends Screen {
public final void init() {
this.buttons.clear();
this.buttons.add(new Button(0, this.width / 2 - 100, this.height / 4, "Options..."));
this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 4 + 24, "Generate new level..."));
this.buttons.add(new Button(2, this.width / 2 - 100, this.height / 4 + 48, "Save level.."));
this.buttons.add(new Button(3, this.width / 2 - 100, this.height / 4 + 72, "Load level.."));
this.buttons.add(new Button(4, this.width / 2 - 100, this.height / 4 + 120, "Back to game"));
if(this.minecraft.user == null) {
((Button)this.buttons.get(2)).enabled = false;
((Button)this.buttons.get(3)).enabled = false;
}
if(this.minecraft.connectionManager != null) {
((Button)this.buttons.get(1)).enabled = false;
((Button)this.buttons.get(2)).enabled = false;
((Button)this.buttons.get(3)).enabled = false;
}
}
protected final void buttonClicked(Button var1) {
if(var1.id == 0) {
this.minecraft.setScreen(new OptionsScreen(this, this.minecraft.options));
}
if(var1.id == 1) {
this.minecraft.setScreen(new NewLevelScreen(this));
}
if(this.minecraft.user != null) {
if(var1.id == 2) {
this.minecraft.setScreen(new SaveLevelScreen(this));
}
if(var1.id == 3) {
this.minecraft.setScreen(new LoadLevelScreen(this));
}
}
if(var1.id == 4) {
this.minecraft.setScreen((Screen)null);
this.minecraft.grabMouse();
}
}
public final void render(int var1, int var2) {
fillGradient(0, 0, this.width, this.height, 1610941696, -1607454624);
drawCenteredString(this.font, "Game menu", this.width / 2, 40, 16777215);
super.render(var1, var2);
}
}

View File

@ -0,0 +1,20 @@
package com.mojang.minecraft.gui;
public final class SaveLevelScreen extends LoadLevelScreen {
public SaveLevelScreen(Screen var1) {
super(var1);
this.title = "Save level";
}
protected final void setLevels(String[] var1) {
for(int var2 = 0; var2 < 5; ++var2) {
((Button)this.buttons.get(var2)).msg = var1[var2];
((Button)this.buttons.get(var2)).visible = true;
}
}
protected final void loadLevel(int var1) {
this.minecraft.setScreen(new NameLevelScreen(this, ((Button)this.buttons.get(var1)).msg, var1));
}
}

View File

@ -0,0 +1,115 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.Minecraft;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
public class Screen extends Gui {
protected Minecraft minecraft;
protected int width;
protected int height;
protected List buttons = new ArrayList();
public boolean allowUserInput = false;
protected Font font;
public void render(int var1, int var2) {
for(int var3 = 0; var3 < this.buttons.size(); ++var3) {
Button var4 = (Button)this.buttons.get(var3);
Minecraft var5 = this.minecraft;
if(var4.visible) {
Font var8 = var5.font;
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, var5.textures.getTextureId("/gui.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
byte var9 = 1;
boolean var6 = var1 >= var4.w && var2 >= var4.h && var1 < var4.w + var4.x && var2 < var4.h + var4.y;
if(!var4.enabled) {
var9 = 0;
} else if(var6) {
var9 = 2;
}
var4.blit(var4.w, var4.h, 0, 46 + var9 * 20, var4.x / 2, var4.y);
var4.blit(var4.w + var4.x / 2, var4.h, 200 - var4.x / 2, 46 + var9 * 20, var4.x / 2, var4.y);
if(!var4.enabled) {
Button.drawCenteredString(var8, var4.msg, var4.w + var4.x / 2, var4.h + (var4.y - 8) / 2, -6250336);
} else if(var6) {
Button.drawCenteredString(var8, var4.msg, var4.w + var4.x / 2, var4.h + (var4.y - 8) / 2, 16777120);
} else {
Button.drawCenteredString(var8, var4.msg, var4.w + var4.x / 2, var4.h + (var4.y - 8) / 2, 14737632);
}
}
}
}
protected void keyPressed(char var1, int var2) {
if(var2 == 1) {
this.minecraft.setScreen((Screen)null);
this.minecraft.grabMouse();
}
}
protected void mousePressed(int var1, int var2, int var3) {
if(var3 == 0) {
for(var3 = 0; var3 < this.buttons.size(); ++var3) {
Button var4 = (Button)this.buttons.get(var3);
if(var4.enabled && var1 >= var4.w && var2 >= var4.h && var1 < var4.w + var4.x && var2 < var4.h + var4.y) {
this.buttonClicked(var4);
}
}
}
}
protected void buttonClicked(Button var1) {
}
public final void init(Minecraft var1, int var2, int var3) {
this.minecraft = var1;
this.font = var1.font;
this.width = var2;
this.height = var3;
this.init();
}
public void init() {
}
public final void updateEvents() {
while(Mouse.next()) {
this.updateMouseEvents();
}
while(Keyboard.next()) {
this.updateKeyboardEvents();
}
}
public final void updateMouseEvents() {
if(Mouse.getEventButtonState()) {
int var1 = Mouse.getEventX() * this.width / this.minecraft.width;
int var2 = this.height - Mouse.getEventY() * this.height / this.minecraft.height - 1;
this.mousePressed(var1, var2, Mouse.getEventButton());
}
}
public final void updateKeyboardEvents() {
if(Keyboard.getEventKeyState()) {
this.keyPressed(Keyboard.getEventCharacter(), Keyboard.getEventKey());
}
}
public void tick() {
}
public void closeScreen() {
}
}

View File

@ -0,0 +1,16 @@
package com.mojang.minecraft.level;
public final class Coord {
public int x;
public int y;
public int z;
public int id;
public int scheduledTime;
public Coord(int var1, int var2, int var3, int var4) {
this.x = var1;
this.y = var2;
this.z = var3;
this.id = var4;
}
}

View File

@ -0,0 +1,820 @@
package com.mojang.minecraft.level;
import com.mojang.minecraft.Entity;
import com.mojang.minecraft.HitResult;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.character.Vec3;
import com.mojang.minecraft.level.liquid.Liquid;
import com.mojang.minecraft.level.tile.Tile;
import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.renderer.LevelRenderer;
import com.mojang.minecraft.sound.AudioInfo;
import com.mojang.minecraft.sound.EntitySoundPos;
import com.mojang.minecraft.sound.LevelSoundPos;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
public class Level implements Serializable {
public static final long serialVersionUID = 0L;
public int width;
public int height;
public int depth;
public byte[] blocks;
public String name;
public String creator;
public long createTime;
public int xSpawn;
public int ySpawn;
public int zSpawn;
public float rotSpawn;
private transient ArrayList levelListeners = new ArrayList();
private transient int[] heightMap;
private transient Random random = new Random();
private transient int randValue = this.random.nextInt();
private transient ArrayList tickList = new ArrayList();
public ArrayList entities = new ArrayList();
private boolean networkMode = false;
public transient Minecraft rendererContext;
int unprocessed = 0;
private int tickCount = 0;
public void initTransient() {
if(this.blocks == null) {
throw new RuntimeException("The level is corrupt!");
} else {
this.levelListeners = new ArrayList();
this.heightMap = new int[this.width * this.height];
Arrays.fill(this.heightMap, this.depth);
this.calcLightDepths(0, 0, this.width, this.height);
this.random = new Random();
this.randValue = this.random.nextInt();
this.tickList = new ArrayList();
if(this.entities == null) {
this.entities = new ArrayList();
}
if(this.xSpawn == 0 && this.ySpawn == 0 && this.zSpawn == 0) {
this.findSpawn();
}
}
}
public void setData(int var1, int var2, int var3, byte[] var4) {
this.width = var1;
this.height = var3;
this.depth = var2;
this.blocks = var4;
this.heightMap = new int[var1 * var3];
Arrays.fill(this.heightMap, this.depth);
this.calcLightDepths(0, 0, var1, var3);
for(var1 = 0; var1 < this.levelListeners.size(); ++var1) {
((LevelRenderer)this.levelListeners.get(var1)).compileSurroundingGround();
}
this.tickList.clear();
this.findSpawn();
System.gc();
}
public void findSpawn() {
Random var1 = new Random();
int var2 = 0;
int var3;
int var4;
int var5;
do {
++var2;
var3 = var1.nextInt(this.width / 2) + this.width / 4;
var4 = var1.nextInt(this.height / 2) + this.height / 4;
var5 = this.getHighestTile(var3, var4) + 1;
if(var2 == 10000) {
this.xSpawn = var3;
this.ySpawn = -100;
this.zSpawn = var4;
return;
}
} while((float)var5 <= this.getWaterLevel());
this.xSpawn = var3;
this.ySpawn = var5;
this.zSpawn = var4;
}
public void calcLightDepths(int var1, int var2, int var3, int var4) {
for(int var5 = var1; var5 < var1 + var3; ++var5) {
for(int var6 = var2; var6 < var2 + var4; ++var6) {
int var7 = this.heightMap[var5 + var6 * this.width];
int var8;
for(var8 = this.depth - 1; var8 > 0 && !this.isLightBlocker(var5, var8, var6); --var8) {
}
this.heightMap[var5 + var6 * this.width] = var8 + 1;
if(var7 != var8) {
int var9 = var7 < var8 ? var7 : var8;
var7 = var7 > var8 ? var7 : var8;
for(var8 = 0; var8 < this.levelListeners.size(); ++var8) {
LevelRenderer var10 = (LevelRenderer)this.levelListeners.get(var8);
var10.setDirty(var5 - 1, var9 - 1, var6 - 1, var5 + 1, var7 + 1, var6 + 1);
}
}
}
}
}
public void addListener(LevelRenderer var1) {
this.levelListeners.add(var1);
}
public void finalize() {
}
public void removeListener(LevelRenderer var1) {
this.levelListeners.remove(var1);
}
public boolean isLightBlocker(int var1, int var2, int var3) {
Tile var4 = Tile.tiles[this.getTile(var1, var2, var3)];
return var4 == null ? false : var4.blocksLight();
}
public ArrayList getCubes(AABB var1) {
ArrayList var2 = new ArrayList();
int var3 = (int)var1.x0;
int var4 = (int)var1.x1 + 1;
int var5 = (int)var1.y0;
int var6 = (int)var1.y1 + 1;
int var7 = (int)var1.z0;
int var8 = (int)var1.z1 + 1;
if(var1.x0 < 0.0F) {
--var3;
}
if(var1.y0 < 0.0F) {
--var5;
}
if(var1.z0 < 0.0F) {
--var7;
}
for(int var11 = var3; var11 < var4; ++var11) {
for(var3 = var5; var3 < var6; ++var3) {
for(int var9 = var7; var9 < var8; ++var9) {
AABB var10;
if(var11 >= 0 && var3 >= 0 && var9 >= 0 && var11 < this.width && var3 < this.depth && var9 < this.height) {
Tile var12 = Tile.tiles[this.getTile(var11, var3, var9)];
if(var12 != null) {
var10 = var12.getTileAABB(var11, var3, var9);
if(var10 != null) {
var2.add(var10);
}
}
} else if(var11 < 0 || var3 < 0 || var9 < 0 || var11 >= this.width || var9 >= this.height) {
var10 = Tile.unbreakable.getTileAABB(var11, var3, var9);
if(var10 != null) {
var2.add(var10);
}
}
}
}
}
return var2;
}
public void swap(int var1, int var2, int var3, int var4, int var5, int var6) {
if(!this.networkMode) {
int var7 = this.getTile(var1, var2, var3);
int var8 = this.getTile(var4, var5, var6);
this.setTileNoNeighborChange(var1, var2, var3, var8);
this.setTileNoNeighborChange(var4, var5, var6, var7);
this.updateNeighborsAt(var1, var2, var3, var8);
this.updateNeighborsAt(var4, var5, var6, var7);
}
}
public boolean setTileNoNeighborChange(int var1, int var2, int var3, int var4) {
return this.networkMode ? false : this.netSetTileNoNeighborChange(var1, var2, var3, var4);
}
public boolean netSetTileNoNeighborChange(int var1, int var2, int var3, int var4) {
if(var1 >= 0 && var2 >= 0 && var3 >= 0 && var1 < this.width && var2 < this.depth && var3 < this.height) {
if(var4 == this.blocks[(var2 * this.height + var3) * this.width + var1]) {
return false;
} else {
if(var4 == 0 && (var1 == 0 || var3 == 0 || var1 == this.width - 1 || var3 == this.height - 1) && (float)var2 >= this.getGroundLevel() && (float)var2 < this.getWaterLevel()) {
var4 = Tile.water.id;
}
byte var5 = this.blocks[(var2 * this.height + var3) * this.width + var1];
this.blocks[(var2 * this.height + var3) * this.width + var1] = (byte)var4;
if(var5 != 0) {
Tile.tiles[var5].onTileRemoved(this, var1, var2, var3);
}
if(var4 != 0) {
Tile.tiles[var4].onTileAdded(this, var1, var2, var3);
}
this.calcLightDepths(var1, var3, 1, 1);
for(var4 = 0; var4 < this.levelListeners.size(); ++var4) {
LevelRenderer var9 = (LevelRenderer)this.levelListeners.get(var4);
var9.setDirty(var1 - 1, var2 - 1, var3 - 1, var1 + 1, var2 + 1, var3 + 1);
}
return true;
}
} else {
return false;
}
}
public boolean setTile(int var1, int var2, int var3, int var4) {
if(this.networkMode) {
return false;
} else if(this.setTileNoNeighborChange(var1, var2, var3, var4)) {
this.updateNeighborsAt(var1, var2, var3, var4);
return true;
} else {
return false;
}
}
public boolean netSetTile(int var1, int var2, int var3, int var4) {
if(this.netSetTileNoNeighborChange(var1, var2, var3, var4)) {
this.updateNeighborsAt(var1, var2, var3, var4);
return true;
} else {
return false;
}
}
public void updateNeighborsAt(int var1, int var2, int var3, int var4) {
this.updateNeighborAt(var1 - 1, var2, var3, var4);
this.updateNeighborAt(var1 + 1, var2, var3, var4);
this.updateNeighborAt(var1, var2 - 1, var3, var4);
this.updateNeighborAt(var1, var2 + 1, var3, var4);
this.updateNeighborAt(var1, var2, var3 - 1, var4);
this.updateNeighborAt(var1, var2, var3 + 1, var4);
}
public boolean setTileNoUpdate(int var1, int var2, int var3, int var4) {
if(var1 >= 0 && var2 >= 0 && var3 >= 0 && var1 < this.width && var2 < this.depth && var3 < this.height) {
if(var4 == this.blocks[(var2 * this.height + var3) * this.width + var1]) {
return false;
} else {
this.blocks[(var2 * this.height + var3) * this.width + var1] = (byte)var4;
return true;
}
} else {
return false;
}
}
private void updateNeighborAt(int var1, int var2, int var3, int var4) {
if(var1 >= 0 && var2 >= 0 && var3 >= 0 && var1 < this.width && var2 < this.depth && var3 < this.height) {
Tile var5 = Tile.tiles[this.blocks[(var2 * this.height + var3) * this.width + var1]];
if(var5 != null) {
var5.neighborChanged(this, var1, var2, var3, var4);
}
}
}
public boolean isLit(int var1, int var2, int var3) {
return var1 >= 0 && var2 >= 0 && var3 >= 0 && var1 < this.width && var2 < this.depth && var3 < this.height ? var2 >= this.heightMap[var1 + var3 * this.width] : true;
}
public int getTile(int var1, int var2, int var3) {
return var1 >= 0 && var2 >= 0 && var3 >= 0 && var1 < this.width && var2 < this.depth && var3 < this.height ? this.blocks[(var2 * this.height + var3) * this.width + var1] & 255 : 0;
}
public boolean isSolidTile(int var1, int var2, int var3) {
Tile var4 = Tile.tiles[this.getTile(var1, var2, var3)];
return var4 == null ? false : var4.isSolid();
}
public void tickEntities() {
for(int var1 = 0; var1 < this.entities.size(); ++var1) {
((Entity)this.entities.get(var1)).tick();
if(((Entity)this.entities.get(var1)).removed) {
this.entities.remove(var1--);
}
}
}
public void tick() {
++this.tickCount;
int var1 = 1;
int var2;
for(var2 = 1; 1 << var1 < this.width; ++var1) {
}
while(1 << var2 < this.height) {
++var2;
}
int var3 = this.height - 1;
int var4 = this.width - 1;
int var5 = this.depth - 1;
int var6;
int var7;
if(this.tickCount % 5 == 0) {
var6 = this.tickList.size();
for(var7 = 0; var7 < var6; ++var7) {
Coord var8 = (Coord)this.tickList.remove(0);
if(var8.scheduledTime > 0) {
--var8.scheduledTime;
this.tickList.add(var8);
} else if(this.isInLevelBounds(var8.x, var8.y, var8.z)) {
byte var9 = this.blocks[(var8.y * this.height + var8.z) * this.width + var8.x];
if(var9 == var8.id && var9 > 0) {
Tile.tiles[var9].tick(this, var8.x, var8.y, var8.z, this.random);
}
}
}
}
this.unprocessed += this.width * this.height * this.depth;
var6 = this.unprocessed / 200;
this.unprocessed -= var6 * 200;
for(var7 = 0; var7 < var6; ++var7) {
this.randValue = this.randValue * 3 + 1013904223;
int var12 = this.randValue >> 2;
int var13 = var12 & var4;
int var10 = var12 >> var1 & var3;
var12 = var12 >> var1 + var2 & var5;
byte var11 = this.blocks[(var12 * this.height + var10) * this.width + var13];
if(Tile.shouldTick[var11]) {
Tile.tiles[var11].tick(this, var13, var12, var10, this.random);
}
}
}
private boolean isInLevelBounds(int var1, int var2, int var3) {
return var1 >= 0 && var2 >= 0 && var3 >= 0 && var1 < this.width && var2 < this.depth && var3 < this.height;
}
public float getGroundLevel() {
return (float)(this.depth / 2 - 2);
}
public float getWaterLevel() {
return (float)(this.depth / 2);
}
public boolean containsAnyLiquid(AABB var1) {
int var2 = (int)var1.x0;
int var3 = (int)var1.x1 + 1;
int var4 = (int)var1.y0;
int var5 = (int)var1.y1 + 1;
int var6 = (int)var1.z0;
int var7 = (int)var1.z1 + 1;
if(var1.x0 < 0.0F) {
--var2;
}
if(var1.y0 < 0.0F) {
--var4;
}
if(var1.z0 < 0.0F) {
--var6;
}
if(var2 < 0) {
var2 = 0;
}
if(var4 < 0) {
var4 = 0;
}
if(var6 < 0) {
var6 = 0;
}
if(var3 > this.width) {
var3 = this.width;
}
if(var5 > this.depth) {
var5 = this.depth;
}
if(var7 > this.height) {
var7 = this.height;
}
for(int var10 = var2; var10 < var3; ++var10) {
for(var2 = var4; var2 < var5; ++var2) {
for(int var8 = var6; var8 < var7; ++var8) {
Tile var9 = Tile.tiles[this.getTile(var10, var2, var8)];
if(var9 != null && var9.getLiquidType() != Liquid.none) {
return true;
}
}
}
}
return false;
}
public boolean containsLiquid(AABB var1, Liquid var2) {
int var3 = (int)var1.x0;
int var4 = (int)var1.x1 + 1;
int var5 = (int)var1.y0;
int var6 = (int)var1.y1 + 1;
int var7 = (int)var1.z0;
int var8 = (int)var1.z1 + 1;
if(var1.x0 < 0.0F) {
--var3;
}
if(var1.y0 < 0.0F) {
--var5;
}
if(var1.z0 < 0.0F) {
--var7;
}
if(var3 < 0) {
var3 = 0;
}
if(var5 < 0) {
var5 = 0;
}
if(var7 < 0) {
var7 = 0;
}
if(var4 > this.width) {
var4 = this.width;
}
if(var6 > this.depth) {
var6 = this.depth;
}
if(var8 > this.height) {
var8 = this.height;
}
for(int var11 = var3; var11 < var4; ++var11) {
for(var3 = var5; var3 < var6; ++var3) {
for(int var9 = var7; var9 < var8; ++var9) {
Tile var10 = Tile.tiles[this.getTile(var11, var3, var9)];
if(var10 != null && var10.getLiquidType() == var2) {
return true;
}
}
}
}
return false;
}
public void addToTickNextTick(int var1, int var2, int var3, int var4) {
if(!this.networkMode) {
Coord var5 = new Coord(var1, var2, var3, var4);
if(var4 > 0) {
var3 = Tile.tiles[var4].getTickDelay();
var5.scheduledTime = var3;
}
this.tickList.add(var5);
}
}
public boolean isFree(AABB var1) {
for(int var2 = 0; var2 < this.entities.size(); ++var2) {
if(((Entity)this.entities.get(var2)).bb.intersects(var1)) {
return false;
}
}
return true;
}
public boolean isSolid(float var1, float var2, float var3, float var4) {
return this.isSolidTile(var1 - var4, var2 - var4, var3 - var4) ? true : (this.isSolidTile(var1 - var4, var2 - var4, var3 + var4) ? true : (this.isSolidTile(var1 - var4, var2 + var4, var3 - var4) ? true : (this.isSolidTile(var1 - var4, var2 + var4, var3 + var4) ? true : (this.isSolidTile(var1 + var4, var2 - var4, var3 - var4) ? true : (this.isSolidTile(var1 + var4, var2 - var4, var3 + var4) ? true : (this.isSolidTile(var1 + var4, var2 + var4, var3 - var4) ? true : this.isSolidTile(var1 + var4, var2 + var4, var3 + var4)))))));
}
private boolean isSolidTile(float var1, float var2, float var3) {
int var4 = this.getTile((int)var1, (int)var2, (int)var3);
return var4 > 0 && Tile.tiles[var4].isSolid();
}
public int getHighestTile(int var1, int var2) {
int var3;
for(var3 = this.depth; (this.getTile(var1, var3 - 1, var2) == 0 || Tile.tiles[this.getTile(var1, var3 - 1, var2)].getLiquidType() != Liquid.none) && var3 > 0; --var3) {
}
return var3;
}
public void setSpawnPos(int var1, int var2, int var3, float var4) {
this.xSpawn = var1;
this.ySpawn = var2;
this.zSpawn = var3;
this.rotSpawn = var4;
}
public float getBrightness(int var1, int var2, int var3) {
return this.isLit(var1, var2, var3) ? 1.0F : 0.6F;
}
public float getCaveness(float var1, float var2, float var3, float var4) {
int var5 = (int)var1;
int var14 = (int)var2;
int var6 = (int)var3;
float var7 = 0.0F;
float var8 = 0.0F;
for(int var9 = var5 - 6; var9 <= var5 + 6; ++var9) {
for(int var10 = var6 - 6; var10 <= var6 + 6; ++var10) {
if(this.isInLevelBounds(var9, var14, var10) && !this.isSolidTile(var9, var14, var10)) {
float var11 = (float)var9 + 0.5F - var1;
float var12 = (float)var10 + 0.5F - var3;
float var13;
for(var13 = (float)(Math.atan2((double)var12, (double)var11) - (double)var4 * Math.PI / 180.0D + Math.PI * 0.5D); (double)var13 < -Math.PI; var13 = (float)((double)var13 + Math.PI * 2.0D)) {
}
while((double)var13 >= Math.PI) {
var13 = (float)((double)var13 - Math.PI * 2.0D);
}
if(var13 < 0.0F) {
var13 = -var13;
}
var11 = (float)Math.sqrt((double)(var11 * var11 + 4.0F + var12 * var12));
var11 = 1.0F / var11;
if(var13 > 1.0F) {
var11 = 0.0F;
}
if(var11 < 0.0F) {
var11 = 0.0F;
}
var8 += var11;
if(this.isLit(var9, var14, var10)) {
var7 += var11;
}
}
}
}
if(var8 == 0.0F) {
return 0.0F;
} else {
return var7 / var8;
}
}
public float getCaveness(Entity var1) {
float var2 = (float)Math.cos((double)(-var1.yRot) * Math.PI / 180.0D + Math.PI);
float var3 = (float)Math.sin((double)(-var1.yRot) * Math.PI / 180.0D + Math.PI);
float var4 = (float)Math.cos((double)(-var1.xRot) * Math.PI / 180.0D);
float var5 = (float)Math.sin((double)(-var1.xRot) * Math.PI / 180.0D);
float var6 = var1.x;
float var7 = var1.y;
float var21 = var1.z;
float var8 = 1.6F;
float var9 = 0.0F;
float var10 = 0.0F;
for(int var11 = 0; var11 <= 200; ++var11) {
float var12 = ((float)var11 / (float)200 - 0.5F) * 2.0F;
for(int var13 = 0; var13 <= 200; ++var13) {
float var14 = ((float)var13 / (float)200 - 0.5F) * var8;
float var16 = var4 * var14 + var5;
var14 = var4 - var5 * var14;
float var17 = var2 * var12 + var3 * var14;
var16 = var16;
var14 = var2 * var14 - var3 * var12;
for(int var15 = 0; var15 < 10; ++var15) {
float var18 = var6 + var17 * (float)var15 * 0.8F;
float var19 = var7 + var16 * (float)var15 * 0.8F;
float var20 = var21 + var14 * (float)var15 * 0.8F;
if(this.isSolidTile(var18, var19, var20)) {
break;
}
++var9;
if(this.isLit((int)var18, (int)var19, (int)var20)) {
++var10;
}
}
}
}
if(var9 == 0.0F) {
return 0.0F;
} else {
float var22 = var10 / var9;
var22 /= 0.1F;
if(var22 > 1.0F) {
var22 = 1.0F;
}
var22 = 1.0F - var22;
return 1.0F - var22 * var22 * var22;
}
}
public byte[] copyBlocks() {
return Arrays.copyOf(this.blocks, this.blocks.length);
}
public boolean isWater(int var1, int var2, int var3) {
int var4 = this.getTile(var1, var2, var3);
return var4 > 0 && Tile.tiles[var4].getLiquidType() == Liquid.water;
}
public void setNetworkMode(boolean var1) {
this.networkMode = var1;
}
public HitResult clip(Vec3 var1, Vec3 var2) {
if(!Float.isNaN(var1.x) && !Float.isNaN(var1.y) && !Float.isNaN(var1.z)) {
if(!Float.isNaN(var2.x) && !Float.isNaN(var2.y) && !Float.isNaN(var2.z)) {
int var3 = (int)Math.floor((double)var2.x);
int var4 = (int)Math.floor((double)var2.y);
int var5 = (int)Math.floor((double)var2.z);
int var6 = (int)Math.floor((double)var1.x);
int var7 = (int)Math.floor((double)var1.y);
int var8 = (int)Math.floor((double)var1.z);
int var9 = 20;
int var20;
byte var21;
do {
if(var9-- < 0) {
return null;
}
if(Float.isNaN(var1.x) || Float.isNaN(var1.y) || Float.isNaN(var1.z)) {
return null;
}
if(var6 == var3 && var7 == var4 && var8 == var5) {
return null;
}
float var10 = 999.0F;
float var11 = 999.0F;
float var12 = 999.0F;
if(var3 > var6) {
var10 = (float)var6 + 1.0F;
}
if(var3 < var6) {
var10 = (float)var6;
}
if(var4 > var7) {
var11 = (float)var7 + 1.0F;
}
if(var4 < var7) {
var11 = (float)var7;
}
if(var5 > var8) {
var12 = (float)var8 + 1.0F;
}
if(var5 < var8) {
var12 = (float)var8;
}
float var13 = 999.0F;
float var14 = 999.0F;
float var15 = 999.0F;
float var16 = var2.x - var1.x;
float var17 = var2.y - var1.y;
float var18 = var2.z - var1.z;
if(var10 != 999.0F) {
var13 = (var10 - var1.x) / var16;
}
if(var11 != 999.0F) {
var14 = (var11 - var1.y) / var17;
}
if(var12 != 999.0F) {
var15 = (var12 - var1.z) / var18;
}
boolean var19 = false;
if(var13 < var14 && var13 < var15) {
if(var3 > var6) {
var21 = 4;
} else {
var21 = 5;
}
var1.x = var10;
var1.y += var17 * var13;
var1.z += var18 * var13;
} else if(var14 < var15) {
if(var4 > var7) {
var21 = 0;
} else {
var21 = 1;
}
var1.x += var16 * var14;
var1.y = var11;
var1.z += var18 * var14;
} else {
if(var5 > var8) {
var21 = 2;
} else {
var21 = 3;
}
var1.x += var16 * var15;
var1.y += var17 * var15;
var1.z = var12;
}
var6 = (int)Math.floor((double)var1.x);
if(var21 == 5) {
--var6;
}
var7 = (int)Math.floor((double)var1.y);
if(var21 == 1) {
--var7;
}
var8 = (int)Math.floor((double)var1.z);
if(var21 == 3) {
--var8;
}
var20 = this.getTile(var6, var7, var8);
} while(var20 <= 0 || Tile.tiles[var20].getLiquidType() != Liquid.none);
return new HitResult(0, var6, var7, var8, var21);
} else {
return null;
}
} else {
return null;
}
}
public void playSound(String var1, Entity var2, float var3, float var4) {
if(this.rendererContext != null) {
Minecraft var5 = this.rendererContext;
if(var5.soundPlayer == null || !var5.options.sound) {
return;
}
AudioInfo var6 = var5.soundManager.getAudioInfo(var1, var3, var4);
if(var6 != null) {
var5.soundPlayer.play(var6, new EntitySoundPos(var2, var5.player));
}
}
}
public void playSound(String var1, float var2, float var3, float var4, float var5, float var6) {
if(this.rendererContext != null) {
Minecraft var7 = this.rendererContext;
if(var7.soundPlayer == null || !var7.options.sound) {
return;
}
AudioInfo var8 = var7.soundManager.getAudioInfo(var1, var5, var6);
if(var8 != null) {
var7.soundPlayer.play(var8, new LevelSoundPos(var2, var3, var4, var7.player));
}
}
}
}

View File

@ -0,0 +1,241 @@
package com.mojang.minecraft.level;
import com.mojang.minecraft.ProgressListener;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
public final class LevelIO {
private ProgressListener a;
public LevelIO(ProgressListener var1) {
this.a = var1;
}
public final boolean save(Level var1, String var2, String var3, String var4, String var5, int var6) {
if(var4 == null) {
var4 = "";
}
if(this.a != null && this.a != null) {
this.a.beginLevelLoading("Saving level");
}
try {
if(this.a != null && this.a != null) {
this.a.levelLoadUpdate("Compressing..");
}
ByteArrayOutputStream var7 = new ByteArrayOutputStream();
save(var1, var7);
var7.close();
byte[] var10 = var7.toByteArray();
if(this.a != null && this.a != null) {
this.a.levelLoadUpdate("Connecting..");
}
URL var12 = new URL("http://" + var2 + "/level/save.html");
HttpURLConnection var13 = (HttpURLConnection)var12.openConnection();
var13.setDoInput(true);
var13.setDoOutput(true);
var13.setRequestMethod("POST");
DataOutputStream var14 = new DataOutputStream(var13.getOutputStream());
var14.writeUTF(var3);
var14.writeUTF(var4);
var14.writeUTF(var5);
var14.writeByte(var6);
var14.writeInt(var10.length);
if(this.a != null) {
this.a.levelLoadUpdate("Saving..");
}
var14.write(var10);
var14.close();
BufferedReader var11 = new BufferedReader(new InputStreamReader(var13.getInputStream()));
var2 = var11.readLine();
if(!var2.equalsIgnoreCase("ok")) {
if(this.a != null) {
this.a.levelLoadUpdate("Failed: " + var11.readLine());
}
var11.close();
Thread.sleep(1000L);
return false;
} else {
var11.close();
return true;
}
} catch (Exception var9) {
var9.printStackTrace();
if(this.a != null) {
this.a.levelLoadUpdate("Failed!");
}
try {
Thread.sleep(1000L);
} catch (InterruptedException var8) {
}
return false;
}
}
public final Level load(String var1, String var2, int var3) {
if(this.a != null) {
this.a.beginLevelLoading("Loading level");
}
try {
if(this.a != null) {
this.a.levelLoadUpdate("Connecting..");
}
URL var6 = new URL("http://" + var1 + "/level/load.html?id=" + var3 + "&user=" + var2);
HttpURLConnection var7 = (HttpURLConnection)var6.openConnection();
var7.setDoInput(true);
if(this.a != null) {
this.a.levelLoadUpdate("Loading..");
}
DataInputStream var8 = new DataInputStream(var7.getInputStream());
var2 = var8.readUTF();
if(var2.equalsIgnoreCase("ok")) {
return this.load(var8);
} else {
if(this.a != null) {
this.a.levelLoadUpdate("Failed: " + var8.readUTF());
}
var8.close();
Thread.sleep(1000L);
return null;
}
} catch (Exception var5) {
var5.printStackTrace();
if(this.a != null) {
this.a.levelLoadUpdate("Failed!");
}
try {
Thread.sleep(3000L);
} catch (InterruptedException var4) {
}
return null;
}
}
public final Level load(InputStream var1) {
if(this.a != null) {
this.a.beginLevelLoading("Loading level");
}
if(this.a != null) {
this.a.levelLoadUpdate("Reading..");
}
try {
DataInputStream var10 = new DataInputStream(new GZIPInputStream(var1));
int var12 = var10.readInt();
if(var12 != 656127880) {
return null;
} else {
byte var13 = var10.readByte();
if(var13 > 2) {
return null;
} else if(var13 <= 1) {
System.out.println("Version is 1!");
String var15 = var10.readUTF();
String var16 = var10.readUTF();
long var7 = var10.readLong();
short var3 = var10.readShort();
short var4 = var10.readShort();
short var5 = var10.readShort();
byte[] var6 = new byte[var3 * var4 * var5];
var10.readFully(var6);
var10.close();
Level var11 = new Level();
var11.setData(var3, var5, var4, var6);
var11.name = var15;
var11.creator = var16;
var11.createTime = var7;
return var11;
} else {
ObjectInputStream var14 = new ObjectInputStream(var10);
Level var2 = (Level)var14.readObject();
var2.initTransient();
var14.close();
return var2;
}
}
} catch (Exception var9) {
var9.printStackTrace();
(new StringBuilder()).append("Failed to load level: ").append(var9.toString()).toString();
return null;
}
}
public final Level loadLegacy(InputStream var1) {
if(this.a != null) {
this.a.beginLevelLoading("Loading level");
}
if(this.a != null) {
this.a.levelLoadUpdate("Reading..");
}
try {
DataInputStream var5 = new DataInputStream(new GZIPInputStream(var1));
String var7 = "--";
String var2 = "unknown";
byte[] var3 = new byte[256 << 8 << 6];
var5.readFully(var3);
var5.close();
Level var6 = new Level();
var6.setData(256, 64, 256, var3);
var6.name = var7;
var6.creator = var2;
var6.createTime = 0L;
return var6;
} catch (Exception var4) {
var4.printStackTrace();
(new StringBuilder()).append("Failed to load level: ").append(var4.toString()).toString();
return null;
}
}
public static void save(Level var0, OutputStream var1) {
try {
DataOutputStream var3 = new DataOutputStream(new GZIPOutputStream(var1));
var3.writeInt(656127880);
var3.writeByte(2);
ObjectOutputStream var4 = new ObjectOutputStream(var3);
var4.writeObject(var0);
var4.close();
} catch (Exception var2) {
var2.printStackTrace();
}
}
public static byte[] loadBlocks(InputStream var0) {
try {
DataInputStream var3 = new DataInputStream(new GZIPInputStream(var0));
byte[] var1 = new byte[var3.readInt()];
var3.readFully(var1);
var3.close();
return var1;
} catch (Exception var2) {
throw new RuntimeException(var2);
}
}
}

View File

@ -0,0 +1,531 @@
package com.mojang.minecraft.level.levelgen;
import com.mojang.minecraft.ProgressListener;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.levelgen.synth.Distort;
import com.mojang.minecraft.level.levelgen.synth.PerlinNoise;
import com.mojang.minecraft.level.tile.Tile;
import java.util.ArrayList;
import java.util.Random;
public final class LevelGen {
private ProgressListener a;
private int width;
private int height;
private int depth;
private Random random = new Random();
private byte[] blocks;
private int[] coords = new int[1048576];
public LevelGen(ProgressListener var1) {
this.a = var1;
}
public final Level generateLevel(String var1, int var2, int var3, int var4) {
this.a.beginLevelLoading("Generating level");
this.width = var2;
this.height = var3;
this.depth = 64;
this.blocks = new byte[var2 * var3 << 6];
this.a.levelLoadUpdate("Raising..");
LevelGen var5 = this;
Distort var8 = new Distort(new PerlinNoise(this.random, 8), new PerlinNoise(this.random, 8));
Distort var9 = new Distort(new PerlinNoise(this.random, 8), new PerlinNoise(this.random, 8));
PerlinNoise var10 = new PerlinNoise(this.random, 8);
int[] var11 = new int[this.width * this.height];
float var6 = 1.3F;
int var13;
int var14;
for(var13 = 0; var13 < var5.width; ++var13) {
var5.setNextPhase(var13 * 100 / (var5.width - 1));
for(var14 = 0; var14 < var5.height; ++var14) {
double var15 = var8.getValue((double)((float)var13 * var6), (double)((float)var14 * var6)) / 8.0D - 8.0D;
double var17 = var9.getValue((double)((float)var13 * var6), (double)((float)var14 * var6)) / 6.0D + 6.0D;
double var19 = var10.getValue((double)var13, (double)var14) / 8.0D;
if(var19 > 0.0D) {
var17 = var15;
}
double var21 = Math.max(var15, var17) / 2.0D;
if(var21 < 0.0D) {
var21 *= 0.8D;
}
var11[var13 + var14 * var5.width] = (int)var21;
}
}
this.a.levelLoadUpdate("Eroding..");
int[] var34 = var11;
var5 = this;
var9 = new Distort(new PerlinNoise(this.random, 8), new PerlinNoise(this.random, 8));
Distort var40 = new Distort(new PerlinNoise(this.random, 8), new PerlinNoise(this.random, 8));
int var16;
int var32;
int var43;
int var46;
for(var43 = 0; var43 < var5.width; ++var43) {
var5.setNextPhase(var43 * 100 / (var5.width - 1));
for(var32 = 0; var32 < var5.height; ++var32) {
double var45 = var9.getValue((double)(var43 << 1), (double)(var32 << 1)) / 8.0D;
var46 = var40.getValue((double)(var43 << 1), (double)(var32 << 1)) > 0.0D ? 1 : 0;
if(var45 > 2.0D) {
var16 = var34[var43 + var32 * var5.width];
var16 = ((var16 - var46) / 2 << 1) + var46;
var34[var43 + var32 * var5.width] = var16;
}
}
}
this.a.levelLoadUpdate("Soiling..");
var34 = var11;
var5 = this;
int var37 = this.width;
int var42 = this.height;
var43 = this.depth;
PerlinNoise var33 = new PerlinNoise(this.random, 8);
int var18;
int var50;
for(var13 = 0; var13 < var37; ++var13) {
var5.setNextPhase(var13 * 100 / (var5.width - 1));
for(var14 = 0; var14 < var42; ++var14) {
var46 = (int)(var33.getValue((double)var13, (double)var14) / 24.0D) - 4;
var16 = var34[var13 + var14 * var37] + var43 / 2;
var50 = var16 + var46;
var34[var13 + var14 * var37] = Math.max(var16, var50);
for(var18 = 0; var18 < var43; ++var18) {
int var52 = (var18 * var5.height + var14) * var5.width + var13;
int var20 = 0;
if(var18 <= var16) {
var20 = Tile.dirt.id;
}
if(var18 <= var50) {
var20 = Tile.rock.id;
}
var5.blocks[var52] = (byte)var20;
}
}
}
this.a.levelLoadUpdate("Carving..");
boolean var39 = true;
boolean var35 = false;
var5 = this;
var42 = this.width;
var43 = this.height;
var32 = this.depth;
var13 = var42 * var43 * var32 / 256 / 64;
for(var14 = 0; var14 < var13; ++var14) {
var5.setNextPhase(var14 * 100 / (var13 - 1) / 4);
float var47 = var5.random.nextFloat() * (float)var42;
float var48 = var5.random.nextFloat() * (float)var32;
float var51 = var5.random.nextFloat() * (float)var43;
var18 = (int)((var5.random.nextFloat() + var5.random.nextFloat()) * 75.0F);
float var53 = (float)((double)var5.random.nextFloat() * Math.PI * 2.0D);
float var54 = 0.0F;
float var55 = (float)((double)var5.random.nextFloat() * Math.PI * 2.0D);
float var22 = 0.0F;
for(int var7 = 0; var7 < var18; ++var7) {
var47 = (float)((double)var47 + Math.sin((double)var53) * Math.cos((double)var55));
var51 = (float)((double)var51 + Math.cos((double)var53) * Math.cos((double)var55));
var48 = (float)((double)var48 + Math.sin((double)var55));
var53 += var54 * 0.2F;
var54 *= 0.9F;
var54 += var5.random.nextFloat() - var5.random.nextFloat();
var55 += var22 * 0.5F;
var55 *= 0.5F;
var22 *= 0.9F;
var22 += var5.random.nextFloat() - var5.random.nextFloat();
if(var5.random.nextFloat() >= 0.3F) {
float var36 = var47 + var5.random.nextFloat() * 4.0F - 2.0F;
float var41 = var48 + var5.random.nextFloat() * 4.0F - 2.0F;
float var12 = var51 + var5.random.nextFloat() * 4.0F - 2.0F;
float var23 = (float)(Math.sin((double)var7 * Math.PI / (double)var18) * 2.5D + 1.0D);
for(int var24 = (int)(var36 - var23); var24 <= (int)(var36 + var23); ++var24) {
for(int var25 = (int)(var41 - var23); var25 <= (int)(var41 + var23); ++var25) {
for(int var26 = (int)(var12 - var23); var26 <= (int)(var12 + var23); ++var26) {
float var27 = (float)var24 - var36;
float var28 = (float)var25 - var41;
float var29 = (float)var26 - var12;
var27 = var27 * var27 + var28 * var28 * 2.0F + var29 * var29;
if(var27 < var23 * var23 && var24 >= 1 && var25 >= 1 && var26 >= 1 && var24 < var5.width - 1 && var25 < var5.depth - 1 && var26 < var5.height - 1) {
int var56 = (var25 * var5.height + var26) * var5.width + var24;
if(var5.blocks[var56] == Tile.rock.id) {
var5.blocks[var56] = 0;
}
}
}
}
}
}
}
}
this.carveTunnels(Tile.oreCoal.id, 90, 1, 4);
this.carveTunnels(Tile.oreIron.id, 70, 2, 4);
this.carveTunnels(Tile.oreGold.id, 50, 3, 4);
this.a.levelLoadUpdate("Watering..");
var5 = this;
long var38 = System.nanoTime();
long var44 = 0L;
var13 = Tile.calmWater.id;
this.setNextPhase(0);
for(var14 = 0; var14 < var5.width; ++var14) {
var44 += var5.floodFillLiquid(var14, var5.depth / 2 - 1, 0, 0, var13);
var44 += var5.floodFillLiquid(var14, var5.depth / 2 - 1, var5.height - 1, 0, var13);
}
for(var14 = 0; var14 < var5.height; ++var14) {
var44 += var5.floodFillLiquid(0, var5.depth / 2 - 1, var14, 0, var13);
var44 += var5.floodFillLiquid(var5.width - 1, var5.depth / 2 - 1, var14, 0, var13);
}
var14 = var5.width * var5.height / 200;
for(var46 = 0; var46 < var14; ++var46) {
if(var46 % 100 == 0) {
var5.setNextPhase(var46 * 100 / (var14 - 1));
}
var16 = var5.random.nextInt(var5.width);
var50 = var5.depth / 2 - 1 - var5.random.nextInt(3);
var18 = var5.random.nextInt(var5.height);
if(var5.blocks[(var50 * var5.height + var18) * var5.width + var16] == 0) {
var44 += var5.floodFillLiquid(var16, var50, var18, 0, var13);
}
}
var5.setNextPhase(100);
long var49 = System.nanoTime();
System.out.println("Flood filled " + var44 + " tiles in " + (double)(var49 - var38) / 1000000.0D + " ms");
this.a.levelLoadUpdate("Melting..");
this.addLava();
this.a.levelLoadUpdate("Growing..");
this.addBeaches(var11);
this.a.levelLoadUpdate("Planting..");
this.plantTrees(var11);
Level var31 = new Level();
var31.setData(var2, 64, var3, this.blocks);
var31.createTime = System.currentTimeMillis();
var31.creator = var1;
var31.name = "A Nice World";
return var31;
}
private void addBeaches(int[] var1) {
int var2 = this.width;
int var3 = this.height;
int var4 = this.depth;
PerlinNoise var5 = new PerlinNoise(this.random, 8);
PerlinNoise var6 = new PerlinNoise(this.random, 8);
for(int var7 = 0; var7 < var2; ++var7) {
this.setNextPhase(var7 * 100 / (this.width - 1));
for(int var8 = 0; var8 < var3; ++var8) {
boolean var9 = var5.getValue((double)var7, (double)var8) > 8.0D;
boolean var10 = var6.getValue((double)var7, (double)var8) > 12.0D;
int var11 = var1[var7 + var8 * var2];
int var12 = (var11 * this.height + var8) * this.width + var7;
int var13 = this.blocks[((var11 + 1) * this.height + var8) * this.width + var7] & 255;
if((var13 == Tile.water.id || var13 == Tile.calmWater.id) && var11 <= var4 / 2 - 1 && var10) {
this.blocks[var12] = (byte)Tile.gravel.id;
}
if(var13 == 0) {
int var14 = Tile.grass.id;
if(var11 <= var4 / 2 - 1 && var9) {
var14 = Tile.sand.id;
}
this.blocks[var12] = (byte)var14;
}
}
}
}
private void plantTrees(int[] var1) {
int var2 = this.width;
int var3 = this.width * this.height / 4000;
for(int var4 = 0; var4 < var3; ++var4) {
this.setNextPhase(var4 * 100 / (var3 - 1));
int var5 = this.random.nextInt(this.width);
int var6 = this.random.nextInt(this.height);
for(int var7 = 0; var7 < 20; ++var7) {
int var8 = var5;
int var9 = var6;
for(int var10 = 0; var10 < 20; ++var10) {
var8 += this.random.nextInt(6) - this.random.nextInt(6);
var9 += this.random.nextInt(6) - this.random.nextInt(6);
if(var8 >= 0 && var9 >= 0 && var8 < this.width && var9 < this.height) {
int var11 = var1[var8 + var9 * var2] + 1;
int var12 = this.random.nextInt(3) + 4;
boolean var13 = true;
int var14;
int var16;
int var17;
int var18;
for(var14 = var11; var14 <= var11 + 1 + var12; ++var14) {
byte var15 = 1;
if(var14 >= var11 + 1 + var12 - 2) {
var15 = 2;
}
for(var16 = var8 - var15; var16 <= var8 + var15 && var13; ++var16) {
for(var17 = var9 - var15; var17 <= var9 + var15 && var13; ++var17) {
if(var16 >= 0 && var14 >= 0 && var17 >= 0 && var16 < this.width && var14 < this.depth && var17 < this.height) {
var18 = this.blocks[(var14 * this.height + var17) * this.width + var16] & 255;
if(var18 != 0) {
var13 = false;
}
} else {
var13 = false;
}
}
}
}
if(var13) {
var14 = (var11 * this.height + var9) * this.width + var8;
int var22 = this.blocks[((var11 - 1) * this.height + var9) * this.width + var8] & 255;
if(var22 == Tile.grass.id && var11 < this.depth - var12 - 1) {
this.blocks[var14 - 1 * this.width * this.height] = (byte)Tile.dirt.id;
for(var16 = var11 - 3 + var12; var16 <= var11 + var12; ++var16) {
var17 = var16 - (var11 + var12);
var18 = 1 - var17 / 2;
for(int var21 = var8 - var18; var21 <= var8 + var18; ++var21) {
var22 = var21 - var8;
for(int var19 = var9 - var18; var19 <= var9 + var18; ++var19) {
int var20 = var19 - var9;
if(Math.abs(var22) != var18 || Math.abs(var20) != var18 || this.random.nextInt(2) != 0 && var17 != 0) {
this.blocks[(var16 * this.height + var19) * this.width + var21] = (byte)Tile.leaf.id;
}
}
}
}
for(var16 = 0; var16 < var12; ++var16) {
this.blocks[var14 + var16 * this.width * this.height] = (byte)Tile.log.id;
}
}
}
}
}
}
}
}
private void carveTunnels(int var1, int var2, int var3, int var4) {
byte var25 = (byte)var1;
var4 = this.width;
int var5 = this.height;
int var6 = this.depth;
int var7 = var4 * var5 * var6 / 256 / 64 * var2 / 100;
for(int var8 = 0; var8 < var7; ++var8) {
this.setNextPhase(var8 * 100 / (var7 - 1) / 4 + var3 * 100 / 4);
float var9 = this.random.nextFloat() * (float)var4;
float var10 = this.random.nextFloat() * (float)var6;
float var11 = this.random.nextFloat() * (float)var5;
int var12 = (int)((this.random.nextFloat() + this.random.nextFloat()) * 75.0F * (float)var2 / 100.0F);
float var13 = (float)((double)this.random.nextFloat() * Math.PI * 2.0D);
float var14 = 0.0F;
float var15 = (float)((double)this.random.nextFloat() * Math.PI * 2.0D);
float var16 = 0.0F;
for(int var17 = 0; var17 < var12; ++var17) {
var9 = (float)((double)var9 + Math.sin((double)var13) * Math.cos((double)var15));
var11 = (float)((double)var11 + Math.cos((double)var13) * Math.cos((double)var15));
var10 = (float)((double)var10 + Math.sin((double)var15));
var13 += var14 * 0.2F;
var14 *= 0.9F;
var14 += this.random.nextFloat() - this.random.nextFloat();
var15 += var16 * 0.5F;
var15 *= 0.5F;
var16 *= 0.9F;
var16 += this.random.nextFloat() - this.random.nextFloat();
float var18 = (float)(Math.sin((double)var17 * Math.PI / (double)var12) * (double)var2 / 100.0D + 1.0D);
for(int var19 = (int)(var9 - var18); var19 <= (int)(var9 + var18); ++var19) {
for(int var20 = (int)(var10 - var18); var20 <= (int)(var10 + var18); ++var20) {
for(int var21 = (int)(var11 - var18); var21 <= (int)(var11 + var18); ++var21) {
float var22 = (float)var19 - var9;
float var23 = (float)var20 - var10;
float var24 = (float)var21 - var11;
var22 = var22 * var22 + var23 * var23 * 2.0F + var24 * var24;
if(var22 < var18 * var18 && var19 >= 1 && var20 >= 1 && var21 >= 1 && var19 < this.width - 1 && var20 < this.depth - 1 && var21 < this.height - 1) {
int var26 = (var20 * this.height + var21) * this.width + var19;
if(this.blocks[var26] == Tile.rock.id) {
this.blocks[var26] = var25;
}
}
}
}
}
}
}
}
private void setNextPhase(int var1) {
this.a.setLoadingProgress(var1);
}
private void addLava() {
int var1 = 0;
int var2 = this.width * this.height * this.depth / 10000;
for(int var3 = 0; var3 < var2; ++var3) {
if(var3 % 100 == 0) {
this.setNextPhase(var3 * 100 / (var2 - 1));
}
int var4 = this.random.nextInt(this.width);
int var5 = this.random.nextInt(this.depth / 2 - 4);
int var6 = this.random.nextInt(this.height);
if(this.blocks[(var5 * this.height + var6) * this.width + var4] == 0) {
++var1;
this.floodFillLiquid(var4, var5, var6, 0, Tile.calmLava.id);
}
}
this.setNextPhase(100);
System.out.println("LavaCount: " + var1);
}
private long floodFillLiquid(int var1, int var2, int var3, int var4, int var5) {
byte var20 = (byte)var5;
ArrayList var21 = new ArrayList();
byte var6 = 0;
int var7 = 1;
int var8;
for(var8 = 1; 1 << var7 < this.width; ++var7) {
}
while(1 << var8 < this.height) {
++var8;
}
int var9 = this.height - 1;
int var10 = this.width - 1;
int var22 = var6 + 1;
this.coords[0] = ((var2 << var8) + var3 << var7) + var1;
long var13 = 0L;
var1 = this.width * this.height;
while(var22 > 0) {
--var22;
var2 = this.coords[var22];
if(var22 == 0 && var21.size() > 0) {
System.out.println("IT HAPPENED!");
this.coords = (int[])var21.remove(var21.size() - 1);
var22 = this.coords.length;
}
var3 = var2 >> var7 & var9;
int var11 = var2 >> var7 + var8;
int var12 = var2 & var10;
int var15;
for(var15 = var12; var12 > 0 && this.blocks[var2 - 1] == 0; --var2) {
--var12;
}
while(var15 < this.width && this.blocks[var2 + var15 - var12] == 0) {
++var15;
}
int var16 = var2 >> var7 & var9;
int var17 = var2 >> var7 + var8;
if(var16 != var3 || var17 != var11) {
System.out.println("hoooly fuck");
}
boolean var23 = false;
boolean var24 = false;
boolean var18 = false;
var13 += (long)(var15 - var12);
for(var12 = var12; var12 < var15; ++var12) {
this.blocks[var2] = var20;
boolean var19;
if(var3 > 0) {
var19 = this.blocks[var2 - this.width] == 0;
if(var19 && !var23) {
if(var22 == this.coords.length) {
var21.add(this.coords);
this.coords = new int[1048576];
var22 = 0;
}
this.coords[var22++] = var2 - this.width;
}
var23 = var19;
}
if(var3 < this.height - 1) {
var19 = this.blocks[var2 + this.width] == 0;
if(var19 && !var24) {
if(var22 == this.coords.length) {
var21.add(this.coords);
this.coords = new int[1048576];
var22 = 0;
}
this.coords[var22++] = var2 + this.width;
}
var24 = var19;
}
if(var11 > 0) {
byte var25 = this.blocks[var2 - var1];
if((var20 == Tile.lava.id || var20 == Tile.calmLava.id) && (var25 == Tile.water.id || var25 == Tile.calmWater.id)) {
this.blocks[var2 - var1] = (byte)Tile.rock.id;
}
var19 = var25 == 0;
if(var19 && !var18) {
if(var22 == this.coords.length) {
var21.add(this.coords);
this.coords = new int[1048576];
var22 = 0;
}
this.coords[var22++] = var2 - var1;
}
var18 = var19;
}
++var2;
}
}
return var13;
}
}

View File

@ -0,0 +1,15 @@
package com.mojang.minecraft.level.levelgen.synth;
public final class Distort extends Synth {
private Synth source;
private Synth distort;
public Distort(Synth var1, Synth var2) {
this.source = var1;
this.distort = var2;
}
public final double getValue(double var1, double var3) {
return this.source.getValue(var1 + this.distort.getValue(var1, var3), var3);
}
}

View File

@ -0,0 +1,65 @@
package com.mojang.minecraft.level.levelgen.synth;
import java.util.Random;
public final class ImprovedNoise extends Synth {
private int[] p;
public ImprovedNoise() {
this(new Random());
}
public ImprovedNoise(Random var1) {
this.p = new int[512];
int var2;
for(var2 = 0; var2 < 256; this.p[var2] = var2++) {
}
for(var2 = 0; var2 < 256; ++var2) {
int var3 = var1.nextInt(256 - var2) + var2;
int var4 = this.p[var2];
this.p[var2] = this.p[var3];
this.p[var3] = var4;
this.p[var2 + 256] = this.p[var2];
}
}
private static double fade(double var0) {
return var0 * var0 * var0 * (var0 * (var0 * 6.0D - 15.0D) + 10.0D);
}
private static double lerp(double var0, double var2, double var4) {
return var2 + var0 * (var4 - var2);
}
private static double grad(int var0, double var1, double var3, double var5) {
var0 &= 15;
double var8 = var0 < 8 ? var1 : var3;
double var10 = var0 < 4 ? var3 : (var0 != 12 && var0 != 14 ? var5 : var1);
return ((var0 & 1) == 0 ? var8 : -var8) + ((var0 & 2) == 0 ? var10 : -var10);
}
public final double getValue(double var1, double var3) {
double var10 = 0.0D;
double var8 = var3;
double var6 = var1;
int var21 = (int)Math.floor(var1) & 255;
int var2 = (int)Math.floor(var3) & 255;
int var22 = (int)Math.floor(0.0D) & 255;
var6 -= Math.floor(var6);
var8 -= Math.floor(var8);
var10 = 0.0D - Math.floor(0.0D);
double var15 = fade(var6);
double var17 = fade(var8);
double var19 = fade(var10);
int var4 = this.p[var21] + var2;
int var5 = this.p[var4] + var22;
var4 = this.p[var4 + 1] + var22;
var21 = this.p[var21 + 1] + var2;
var2 = this.p[var21] + var22;
var21 = this.p[var21 + 1] + var22;
return lerp(var19, lerp(var17, lerp(var15, grad(this.p[var5], var6, var8, var10), grad(this.p[var2], var6 - 1.0D, var8, var10)), lerp(var15, grad(this.p[var4], var6, var8 - 1.0D, var10), grad(this.p[var21], var6 - 1.0D, var8 - 1.0D, var10))), lerp(var17, lerp(var15, grad(this.p[var5 + 1], var6, var8, var10 - 1.0D), grad(this.p[var2 + 1], var6 - 1.0D, var8, var10 - 1.0D)), lerp(var15, grad(this.p[var4 + 1], var6, var8 - 1.0D, var10 - 1.0D), grad(this.p[var21 + 1], var6 - 1.0D, var8 - 1.0D, var10 - 1.0D))));
}
}

View File

@ -0,0 +1,27 @@
package com.mojang.minecraft.level.levelgen.synth;
import java.util.Random;
public final class PerlinNoise extends Synth {
private ImprovedNoise[] noiseLevels = new ImprovedNoise[8];
private int levels = 8;
public PerlinNoise(Random var1, int var2) {
for(var2 = 0; var2 < 8; ++var2) {
this.noiseLevels[var2] = new ImprovedNoise(var1);
}
}
public final double getValue(double var1, double var3) {
double var5 = 0.0D;
double var7 = 1.0D;
for(int var9 = 0; var9 < this.levels; ++var9) {
var5 += this.noiseLevels[var9].getValue(var1 / var7, var3 / var7) * var7;
var7 *= 2.0D;
}
return var5;
}
}

View File

@ -0,0 +1,5 @@
package com.mojang.minecraft.level.levelgen.synth;
public abstract class Synth {
public abstract double getValue(double var1, double var3);
}

View File

@ -0,0 +1,12 @@
package com.mojang.minecraft.level.liquid;
public final class Liquid {
private static Liquid[] liquids = new Liquid[4];
public static final Liquid none = new Liquid(0);
public static final Liquid water = new Liquid(1);
public static final Liquid lava = new Liquid(2);
private Liquid(int var1) {
liquids[var1] = this;
}
}

View File

@ -0,0 +1,68 @@
package com.mojang.minecraft.level.tile;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.renderer.Tesselator;
import java.util.Random;
public final class Bush extends Tile {
protected Bush(int var1, int var2) {
super(var1);
this.tex = var2;
this.setTicking(true);
}
public final void tick(Level var1, int var2, int var3, int var4, Random var5) {
int var6 = var1.getTile(var2, var3 - 1, var4);
if(!var1.isLit(var2, var3, var4) || var6 != Tile.dirt.id && var6 != Tile.grass.id) {
var1.setTile(var2, var3, var4, 0);
}
}
public final boolean render(Tesselator var1, Level var2, int var3, int var4, int var5, int var6) {
if(var2.isLit(var4, var5, var6) ^ var3 != 1) {
return false;
} else {
int var15 = this.getTexture(15);
float var17 = (float)(var15 % 16) / 16.0F;
float var18 = var17 + 0.999F / 16.0F;
float var16 = (float)(var15 / 16) / 16.0F;
float var7 = var16 + 0.999F / 16.0F;
var1.color(255, 255, 255);
for(int var8 = 0; var8 < 2; ++var8) {
float var9 = (float)(Math.sin((double)var8 * Math.PI / (double)2 + Math.PI * 0.25D) * 0.5D);
float var10 = (float)(Math.cos((double)var8 * Math.PI / (double)2 + Math.PI * 0.25D) * 0.5D);
float var11 = (float)var4 + 0.5F - var9;
var9 += (float)var4 + 0.5F;
float var12 = (float)var5;
float var13 = (float)var5 + 1.0F;
float var14 = (float)var6 + 0.5F - var10;
var10 += (float)var6 + 0.5F;
var1.vertexUV(var11, var13, var14, var18, var16);
var1.vertexUV(var9, var13, var10, var17, var16);
var1.vertexUV(var9, var12, var10, var17, var7);
var1.vertexUV(var11, var12, var14, var18, var7);
var1.vertexUV(var9, var13, var10, var18, var16);
var1.vertexUV(var11, var13, var14, var17, var16);
var1.vertexUV(var11, var12, var14, var17, var7);
var1.vertexUV(var9, var12, var10, var18, var7);
}
return true;
}
}
public final AABB getTileAABB(int var1, int var2, int var3) {
return null;
}
public final boolean blocksLight() {
return false;
}
public final boolean isSolid() {
return false;
}
}

View File

@ -0,0 +1,54 @@
package com.mojang.minecraft.level.tile;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.liquid.Liquid;
import java.util.Random;
public final class CalmLiquidTile extends LiquidTile {
protected CalmLiquidTile(int var1, Liquid var2) {
super(var1, var2);
this.tileId = var1 - 1;
this.calmTileId = var1;
this.setTicking(false);
}
public final void tick(Level var1, int var2, int var3, int var4, Random var5) {
}
public final void neighborChanged(Level var1, int var2, int var3, int var4, int var5) {
boolean var6 = false;
if(var1.getTile(var2 - 1, var3, var4) == 0) {
var6 = true;
}
if(var1.getTile(var2 + 1, var3, var4) == 0) {
var6 = true;
}
if(var1.getTile(var2, var3, var4 - 1) == 0) {
var6 = true;
}
if(var1.getTile(var2, var3, var4 + 1) == 0) {
var6 = true;
}
if(var1.getTile(var2, var3 - 1, var4) == 0) {
var6 = true;
}
if(var5 != 0) {
Liquid var7 = Tile.tiles[var5].getLiquidType();
if(this.liquid == Liquid.water && var7 == Liquid.lava || var7 == Liquid.water && this.liquid == Liquid.lava) {
var1.setTile(var2, var3, var4, Tile.rock.id);
return;
}
}
if(var6) {
var1.setTileNoUpdate(var2, var3, var4, this.tileId);
var1.addToTickNextTick(var2, var3, var4, this.tileId);
}
}
}

View File

@ -0,0 +1,7 @@
package com.mojang.minecraft.level.tile;
public final class DirtTile extends Tile {
protected DirtTile(int var1, int var2) {
super(3, 2);
}
}

View File

@ -0,0 +1,46 @@
package com.mojang.minecraft.level.tile;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.liquid.Liquid;
public final class FallingTile extends Tile {
public FallingTile(int var1, int var2) {
super(var1, var2);
}
public final void onBlockAdded(Level var1, int var2, int var3, int var4) {
this.tryToFall(var1, var2, var3, var4);
}
public final void neighborChanged(Level var1, int var2, int var3, int var4, int var5) {
this.tryToFall(var1, var2, var3, var4);
}
private void tryToFall(Level var1, int var2, int var3, int var4) {
int var11 = var2;
int var5 = var3;
int var6 = var4;
while(true) {
int var9 = var5 - 1;
int var7 = var1.getTile(var11, var9, var6);
boolean var10000;
if(var7 == 0) {
var10000 = true;
} else {
Liquid var12 = Tile.tiles[var7].getLiquidType();
var10000 = var12 == Liquid.water ? true : var12 == Liquid.lava;
}
if(!var10000 || var5 <= 0) {
if(var5 != var3) {
var1.swap(var2, var3, var4, var11, var5, var6);
}
return;
}
--var5;
}
}
}

View File

@ -0,0 +1,24 @@
package com.mojang.minecraft.level.tile;
import com.mojang.minecraft.level.Level;
public final class GlassTile extends Tile {
private boolean renderAdjacentFaces = false;
protected GlassTile(int var1, int var2, boolean var3) {
super(20, 49);
}
public final boolean isSolid() {
return false;
}
protected final boolean shouldRenderFace(Level var1, int var2, int var3, int var4, int var5, int var6) {
int var7 = var1.getTile(var2, var3, var4);
return !this.renderAdjacentFaces && var7 == this.id ? false : super.shouldRenderFace(var1, var2, var3, var4, var5, var6);
}
public final boolean blocksLight() {
return false;
}
}

View File

@ -0,0 +1,34 @@
package com.mojang.minecraft.level.tile;
import com.mojang.minecraft.level.Level;
import java.util.Random;
public final class GrassTile extends Tile {
protected GrassTile(int var1) {
super(2);
this.tex = 3;
this.setTicking(true);
}
protected final int getTexture(int var1) {
return var1 == 1 ? 0 : (var1 == 0 ? 2 : 3);
}
public final void tick(Level var1, int var2, int var3, int var4, Random var5) {
if(var5.nextInt(4) == 0) {
if(!var1.isLit(var2, var3 + 1, var4)) {
var1.setTile(var2, var3, var4, Tile.dirt.id);
} else {
for(int var9 = 0; var9 < 4; ++var9) {
int var6 = var2 + var5.nextInt(3) - 1;
int var7 = var3 + var5.nextInt(5) - 3;
int var8 = var4 + var5.nextInt(3) - 1;
if(var1.getTile(var6, var7, var8) == Tile.dirt.id && var1.isLit(var6, var7 + 1, var8)) {
var1.setTile(var6, var7, var8, Tile.grass.id);
}
}
}
}
}
}

View File

@ -0,0 +1,24 @@
package com.mojang.minecraft.level.tile;
import com.mojang.minecraft.level.Level;
public final class LeafTile extends Tile {
private boolean renderAdjacentFaces = true;
protected LeafTile(int var1, int var2, boolean var3) {
super(18, 22);
}
public final boolean isSolid() {
return false;
}
protected final boolean shouldRenderFace(Level var1, int var2, int var3, int var4, int var5, int var6) {
int var7 = var1.getTile(var2, var3, var4);
return !this.renderAdjacentFaces && var7 == this.id ? false : super.shouldRenderFace(var1, var2, var3, var4, var5, var6);
}
public final boolean blocksLight() {
return false;
}
}

View File

@ -0,0 +1,161 @@
package com.mojang.minecraft.level.tile;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.liquid.Liquid;
import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.renderer.Tesselator;
import java.util.Random;
public class LiquidTile extends Tile {
protected Liquid liquid;
protected int calmTileId;
protected int tileId;
protected LiquidTile(int var1, Liquid var2) {
super(var1);
this.liquid = var2;
this.tex = 14;
if(var2 == Liquid.lava) {
this.tex = 30;
}
this.tileId = var1;
this.calmTileId = var1 + 1;
float var4 = 0.01F;
float var3 = 0.1F;
this.setShape(var4 + 0.0F, 0.0F - var3 + var4, var4 + 0.0F, var4 + 1.0F, 1.0F - var3 + var4, var4 + 1.0F);
this.setTicking(true);
if(var2 == Liquid.lava) {
this.setTickSpeed(16);
}
}
public final void onBlockAdded(Level var1, int var2, int var3, int var4) {
var1.addToTickNextTick(var2, var3, var4, this.tileId);
}
public void tick(Level var1, int var2, int var3, int var4, Random var5) {
boolean var7 = false;
var4 = var4;
var3 = var3;
var2 = var2;
var1 = var1;
LiquidTile var8 = this;
boolean var9 = false;
boolean var6;
do {
--var3;
if(var1.getTile(var2, var3, var4) != 0 || !var8.checkSponge(var1, var2, var3, var4)) {
break;
}
var6 = var1.setTile(var2, var3, var4, var8.tileId);
if(var6) {
var9 = true;
}
} while(var6 && var8.liquid != Liquid.lava);
++var3;
if(var8.liquid == Liquid.water || !var9) {
var9 |= var8.checkWater(var1, var2 - 1, var3, var4);
var9 |= var8.checkWater(var1, var2 + 1, var3, var4);
var9 |= var8.checkWater(var1, var2, var3, var4 - 1);
var9 |= var8.checkWater(var1, var2, var3, var4 + 1);
}
if(!var9) {
var1.setTileNoUpdate(var2, var3, var4, var8.calmTileId);
} else {
var1.addToTickNextTick(var2, var3, var4, var8.tileId);
}
}
private boolean checkSponge(Level var1, int var2, int var3, int var4) {
if(this.liquid == Liquid.water) {
for(int var7 = var2 - 2; var7 <= var2 + 2; ++var7) {
for(int var5 = var3 - 2; var5 <= var3 + 2; ++var5) {
for(int var6 = var4 - 2; var6 <= var4 + 2; ++var6) {
if(var1.getTile(var7, var5, var6) == Tile.sponge.id) {
return false;
}
}
}
}
}
return true;
}
private boolean checkWater(Level var1, int var2, int var3, int var4) {
int var5 = var1.getTile(var2, var3, var4);
if(var5 == 0) {
if(!this.checkSponge(var1, var2, var3, var4)) {
return false;
}
boolean var6 = var1.setTile(var2, var3, var4, this.tileId);
if(var6) {
var1.addToTickNextTick(var2, var3, var4, this.tileId);
}
}
return false;
}
protected final float getBrightness(Level var1, int var2, int var3, int var4) {
return this.liquid == Liquid.lava ? 100.0F : var1.getBrightness(var2, var3, var4);
}
protected final boolean shouldRenderFace(Level var1, int var2, int var3, int var4, int var5, int var6) {
if(var2 >= 0 && var3 >= 0 && var4 >= 0 && var2 < var1.width && var4 < var1.height) {
if(var5 != 1 && this.liquid == Liquid.water) {
return false;
} else {
var5 = var1.getTile(var2, var3, var4);
return var5 != this.tileId && var5 != this.calmTileId ? (var6 != 1 || var1.getTile(var2 - 1, var3, var4) != 0 && var1.getTile(var2 + 1, var3, var4) != 0 && var1.getTile(var2, var3, var4 - 1) != 0 && var1.getTile(var2, var3, var4 + 1) != 0 ? super.shouldRenderFace(var1, var2, var3, var4, -1, var6) : true) : false;
}
} else {
return false;
}
}
public final void renderFace(Tesselator var1, int var2, int var3, int var4, int var5) {
super.renderFace(var1, var2, var3, var4, var5);
super.renderBackFace(var1, var2, var3, var4, var5);
}
public final AABB getTileAABB(int var1, int var2, int var3) {
return null;
}
public final boolean blocksLight() {
return true;
}
public final boolean isSolid() {
return false;
}
public final Liquid getLiquidType() {
return this.liquid;
}
public void neighborChanged(Level var1, int var2, int var3, int var4, int var5) {
if(var5 != 0) {
Liquid var6 = Tile.tiles[var5].getLiquidType();
if(this.liquid == Liquid.water && var6 == Liquid.lava || var6 == Liquid.water && this.liquid == Liquid.lava) {
var1.setTile(var2, var3, var4, Tile.rock.id);
return;
}
}
var1.addToTickNextTick(var2, var3, var4, var5);
}
public final int getTickDelay() {
return this.liquid == Liquid.lava ? 5 : 0;
}
}

View File

@ -0,0 +1,12 @@
package com.mojang.minecraft.level.tile;
public final class LogTile extends Tile {
protected LogTile(int var1) {
super(17);
this.tex = 20;
}
protected final int getTexture(int var1) {
return var1 == 1 ? 21 : (var1 == 0 ? 21 : 20);
}
}

View File

@ -0,0 +1,34 @@
package com.mojang.minecraft.level.tile;
import com.mojang.minecraft.level.Level;
public final class SpongeTile extends Tile {
protected SpongeTile(int var1) {
super(19);
this.tex = 48;
}
public final void onTileAdded(Level var1, int var2, int var3, int var4) {
for(int var7 = var2 - 2; var7 <= var2 + 2; ++var7) {
for(int var5 = var3 - 2; var5 <= var3 + 2; ++var5) {
for(int var6 = var4 - 2; var6 <= var4 + 2; ++var6) {
if(var1.isWater(var7, var5, var6)) {
var1.setTileNoNeighborChange(var7, var5, var6, 0);
}
}
}
}
}
public final void onTileRemoved(Level var1, int var2, int var3, int var4) {
for(int var7 = var2 - 2; var7 <= var2 + 2; ++var7) {
for(int var5 = var3 - 2; var5 <= var3 + 2; ++var5) {
for(int var6 = var4 - 2; var6 <= var4 + 2; ++var6) {
var1.updateNeighborsAt(var7, var5, var6, var1.getTile(var7, var5, var6));
}
}
}
}
}

View File

@ -0,0 +1,397 @@
package com.mojang.minecraft.level.tile;
import com.mojang.minecraft.Entity;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.liquid.Liquid;
import com.mojang.minecraft.particle.Particle;
import com.mojang.minecraft.particle.ParticleEngine;
import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.renderer.Tesselator;
import java.util.Random;
public class Tile {
protected static Random random = new Random();
public static final Tile[] tiles = new Tile[256];
public static final boolean[] shouldTick = new boolean[256];
private static int[] tickSpeed = new int[256];
public static final Tile rock = (new Tile(1, 1)).setSoundAndGravity(Tile.SoundType.stone, 1.0F, 1.0F);
public static final Tile grass = (new GrassTile(2)).setSoundAndGravity(Tile.SoundType.grass, 0.9F, 1.0F);
public static final Tile dirt = (new DirtTile(3, 2)).setSoundAndGravity(Tile.SoundType.grass, 0.8F, 1.0F);
public static final Tile wood = (new Tile(4, 16)).setSoundAndGravity(Tile.SoundType.stone, 1.0F, 1.0F);
public static final Tile stoneBrick = (new Tile(5, 4)).setSoundAndGravity(Tile.SoundType.wood, 1.0F, 1.0F);
public static final Tile bush = (new Bush(6, 15)).setSoundAndGravity(Tile.SoundType.none, 0.7F, 1.0F);
public static final Tile unbreakable = (new Tile(7, 17)).setSoundAndGravity(Tile.SoundType.stone, 1.0F, 1.0F);
public static final Tile water = (new LiquidTile(8, Liquid.water)).setSoundAndGravity(Tile.SoundType.none, 1.0F, 1.0F);
public static final Tile calmWater = (new CalmLiquidTile(9, Liquid.water)).setSoundAndGravity(Tile.SoundType.none, 1.0F, 1.0F);
public static final Tile lava = (new LiquidTile(10, Liquid.lava)).setSoundAndGravity(Tile.SoundType.none, 1.0F, 1.0F);
public static final Tile calmLava = (new CalmLiquidTile(11, Liquid.lava)).setSoundAndGravity(Tile.SoundType.none, 1.0F, 1.0F);
public static final Tile sand = (new FallingTile(12, 18)).setSoundAndGravity(Tile.SoundType.gravel, 0.8F, 1.0F);
public static final Tile gravel = (new FallingTile(13, 19)).setSoundAndGravity(Tile.SoundType.gravel, 0.8F, 1.0F);
public static final Tile oreGold = (new Tile(14, 32)).setSoundAndGravity(Tile.SoundType.stone, 1.0F, 1.0F);
public static final Tile oreIron = (new Tile(15, 33)).setSoundAndGravity(Tile.SoundType.stone, 1.0F, 1.0F);
public static final Tile oreCoal = (new Tile(16, 34)).setSoundAndGravity(Tile.SoundType.stone, 1.0F, 1.0F);
public static final Tile log = (new LogTile(17)).setSoundAndGravity(Tile.SoundType.wood, 1.0F, 1.0F);
public static final Tile leaf = (new LeafTile(18, 22, true)).setSoundAndGravity(Tile.SoundType.grass, 1.0F, 0.4F);
public static final Tile sponge = (new SpongeTile(19)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 0.9F);
public static final Tile glass = (new GlassTile(20, 49, false)).setSoundAndGravity(Tile.SoundType.metal, 1.0F, 1.0F);
public static final Tile clothRed = (new Tile(21, 64)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile clothOrange = (new Tile(22, 65)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile clothYellow = (new Tile(23, 66)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile clothChartreuse = (new Tile(24, 67)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile clothGreen = (new Tile(25, 68)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile clothSpringGreen = (new Tile(26, 69)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile clothCyan = (new Tile(27, 70)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile clothCapri = (new Tile(28, 71)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile clothUltramarine = (new Tile(29, 72)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile clothViolet = (new Tile(30, 73)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile clothPurple = (new Tile(31, 74)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile clothMagenta = (new Tile(32, 75)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile clothRose = (new Tile(33, 76)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile clothDarkGray = (new Tile(34, 77)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile clothGray = (new Tile(35, 78)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile clothWhite = (new Tile(36, 79)).setSoundAndGravity(Tile.SoundType.cloth, 1.0F, 1.0F);
public static final Tile plantYellow = (new Bush(37, 13)).setSoundAndGravity(Tile.SoundType.none, 0.7F, 1.0F);
public static final Tile plantRed = (new Bush(38, 12)).setSoundAndGravity(Tile.SoundType.none, 0.7F, 1.0F);
public static final Tile mushroomBrown = (new Bush(39, 29)).setSoundAndGravity(Tile.SoundType.none, 0.7F, 1.0F);
public static final Tile mushroomRed = (new Bush(40, 28)).setSoundAndGravity(Tile.SoundType.none, 0.7F, 1.0F);
public static final Tile blockGold = (new Tile(41, 40)).setSoundAndGravity(Tile.SoundType.metal, 0.7F, 1.0F);
public int tex;
public final int id;
public Tile.SoundType soundType;
private float xx0;
private float yy0;
private float zz0;
private float xx1;
private float yy1;
private float zz1;
public float particleGravity;
protected Tile(int var1) {
tiles[var1] = this;
this.id = var1;
this.setShape(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
protected final Tile setSoundAndGravity(Tile.SoundType var1, float var2, float var3) {
this.particleGravity = var3;
this.soundType = var1;
return this;
}
protected final void setTicking(boolean var1) {
shouldTick[this.id] = var1;
}
protected final void setShape(float var1, float var2, float var3, float var4, float var5, float var6) {
this.xx0 = var1;
this.yy0 = var2;
this.zz0 = var3;
this.xx1 = var4;
this.yy1 = var5;
this.zz1 = var6;
}
protected Tile(int var1, int var2) {
this(var1);
this.tex = var2;
}
public final void setTickSpeed(int var1) {
tickSpeed[this.id] = 16;
}
public boolean render(Tesselator var1, Level var2, int var3, int var4, int var5, int var6) {
boolean var7 = false;
float var8 = 0.5F;
float var9 = 0.8F;
float var10 = 0.6F;
float var11;
if(this.shouldRenderFace(var2, var4, var5 - 1, var6, var3, 0)) {
var11 = this.getBrightness(var2, var4, var5 - 1, var6);
var1.color(var8 * var11, var8 * var11, var8 * var11);
this.renderFace(var1, var4, var5, var6, 0);
var7 = true;
}
if(this.shouldRenderFace(var2, var4, var5 + 1, var6, var3, 1)) {
var11 = this.getBrightness(var2, var4, var5 + 1, var6);
var1.color(var11 * 1.0F, var11 * 1.0F, var11 * 1.0F);
this.renderFace(var1, var4, var5, var6, 1);
var7 = true;
}
if(this.shouldRenderFace(var2, var4, var5, var6 - 1, var3, 2)) {
var11 = this.getBrightness(var2, var4, var5, var6 - 1);
var1.color(var9 * var11, var9 * var11, var9 * var11);
this.renderFace(var1, var4, var5, var6, 2);
var7 = true;
}
if(this.shouldRenderFace(var2, var4, var5, var6 + 1, var3, 3)) {
var11 = this.getBrightness(var2, var4, var5, var6 + 1);
var1.color(var9 * var11, var9 * var11, var9 * var11);
this.renderFace(var1, var4, var5, var6, 3);
var7 = true;
}
if(this.shouldRenderFace(var2, var4 - 1, var5, var6, var3, 4)) {
var11 = this.getBrightness(var2, var4 - 1, var5, var6);
var1.color(var10 * var11, var10 * var11, var10 * var11);
this.renderFace(var1, var4, var5, var6, 4);
var7 = true;
}
if(this.shouldRenderFace(var2, var4 + 1, var5, var6, var3, 5)) {
var11 = this.getBrightness(var2, var4 + 1, var5, var6);
var1.color(var10 * var11, var10 * var11, var10 * var11);
this.renderFace(var1, var4, var5, var6, 5);
var7 = true;
}
return var7;
}
protected float getBrightness(Level var1, int var2, int var3, int var4) {
return var1.getBrightness(var2, var3, var4);
}
protected boolean shouldRenderFace(Level var1, int var2, int var3, int var4, int var5, int var6) {
return var5 == 1 ? false : !var1.isSolidTile(var2, var3, var4);
}
protected int getTexture(int var1) {
return this.tex;
}
public void renderFace(Tesselator var1, int var2, int var3, int var4, int var5) {
int var6 = this.getTexture(var5);
int var7 = var6 % 16 << 4;
var6 = var6 / 16 << 4;
float var8 = (float)var7 / 256.0F;
float var17 = ((float)var7 + 15.99F) / 256.0F;
float var9 = (float)var6 / 256.0F;
float var16 = ((float)var6 + 15.99F) / 256.0F;
float var10 = (float)var2 + this.xx0;
float var14 = (float)var2 + this.xx1;
float var11 = (float)var3 + this.yy0;
float var15 = (float)var3 + this.yy1;
float var12 = (float)var4 + this.zz0;
float var13 = (float)var4 + this.zz1;
if(var5 == 0) {
var1.vertexUV(var10, var11, var13, var8, var16);
var1.vertexUV(var10, var11, var12, var8, var9);
var1.vertexUV(var14, var11, var12, var17, var9);
var1.vertexUV(var14, var11, var13, var17, var16);
} else if(var5 == 1) {
var1.vertexUV(var14, var15, var13, var17, var16);
var1.vertexUV(var14, var15, var12, var17, var9);
var1.vertexUV(var10, var15, var12, var8, var9);
var1.vertexUV(var10, var15, var13, var8, var16);
} else if(var5 == 2) {
var1.vertexUV(var10, var15, var12, var17, var9);
var1.vertexUV(var14, var15, var12, var8, var9);
var1.vertexUV(var14, var11, var12, var8, var16);
var1.vertexUV(var10, var11, var12, var17, var16);
} else if(var5 == 3) {
var1.vertexUV(var10, var15, var13, var8, var9);
var1.vertexUV(var10, var11, var13, var8, var16);
var1.vertexUV(var14, var11, var13, var17, var16);
var1.vertexUV(var14, var15, var13, var17, var9);
} else if(var5 == 4) {
var1.vertexUV(var10, var15, var13, var17, var9);
var1.vertexUV(var10, var15, var12, var8, var9);
var1.vertexUV(var10, var11, var12, var8, var16);
var1.vertexUV(var10, var11, var13, var17, var16);
} else if(var5 == 5) {
var1.vertexUV(var14, var11, var13, var8, var16);
var1.vertexUV(var14, var11, var12, var17, var16);
var1.vertexUV(var14, var15, var12, var17, var9);
var1.vertexUV(var14, var15, var13, var8, var9);
}
}
public final void renderBackFace(Tesselator var1, int var2, int var3, int var4, int var5) {
int var6 = this.getTexture(var5);
float var7 = (float)(var6 % 16) / 16.0F;
float var8 = var7 + 0.999F / 16.0F;
float var16 = (float)(var6 / 16) / 16.0F;
float var9 = var16 + 0.999F / 16.0F;
float var10 = (float)var2 + this.xx0;
float var14 = (float)var2 + this.xx1;
float var11 = (float)var3 + this.yy0;
float var15 = (float)var3 + this.yy1;
float var12 = (float)var4 + this.zz0;
float var13 = (float)var4 + this.zz1;
if(var5 == 0) {
var1.vertexUV(var14, var11, var13, var8, var9);
var1.vertexUV(var14, var11, var12, var8, var16);
var1.vertexUV(var10, var11, var12, var7, var16);
var1.vertexUV(var10, var11, var13, var7, var9);
}
if(var5 == 1) {
var1.vertexUV(var10, var15, var13, var7, var9);
var1.vertexUV(var10, var15, var12, var7, var16);
var1.vertexUV(var14, var15, var12, var8, var16);
var1.vertexUV(var14, var15, var13, var8, var9);
}
if(var5 == 2) {
var1.vertexUV(var10, var11, var12, var8, var9);
var1.vertexUV(var14, var11, var12, var7, var9);
var1.vertexUV(var14, var15, var12, var7, var16);
var1.vertexUV(var10, var15, var12, var8, var16);
}
if(var5 == 3) {
var1.vertexUV(var14, var15, var13, var8, var16);
var1.vertexUV(var14, var11, var13, var8, var9);
var1.vertexUV(var10, var11, var13, var7, var9);
var1.vertexUV(var10, var15, var13, var7, var16);
}
if(var5 == 4) {
var1.vertexUV(var10, var11, var13, var8, var9);
var1.vertexUV(var10, var11, var12, var7, var9);
var1.vertexUV(var10, var15, var12, var7, var16);
var1.vertexUV(var10, var15, var13, var8, var16);
}
if(var5 == 5) {
var1.vertexUV(var14, var15, var13, var7, var16);
var1.vertexUV(var14, var15, var12, var8, var16);
var1.vertexUV(var14, var11, var12, var8, var9);
var1.vertexUV(var14, var11, var13, var7, var9);
}
}
public static void renderFaceNoTexture(Entity var0, Tesselator var1, int var2, int var3, int var4, int var5) {
float var6 = (float)var2;
float var7 = (float)var2 + 1.0F;
float var8 = (float)var3;
float var9 = (float)var3 + 1.0F;
float var10 = (float)var4;
float var11 = (float)var4 + 1.0F;
if(var5 == 0 && (float)var3 > var0.y) {
var1.vertex(var6, var8, var11);
var1.vertex(var6, var8, var10);
var1.vertex(var7, var8, var10);
var1.vertex(var7, var8, var11);
}
if(var5 == 1 && (float)var3 < var0.y) {
var1.vertex(var7, var9, var11);
var1.vertex(var7, var9, var10);
var1.vertex(var6, var9, var10);
var1.vertex(var6, var9, var11);
}
if(var5 == 2 && (float)var4 > var0.z) {
var1.vertex(var6, var9, var10);
var1.vertex(var7, var9, var10);
var1.vertex(var7, var8, var10);
var1.vertex(var6, var8, var10);
}
if(var5 == 3 && (float)var4 < var0.z) {
var1.vertex(var6, var9, var11);
var1.vertex(var6, var8, var11);
var1.vertex(var7, var8, var11);
var1.vertex(var7, var9, var11);
}
if(var5 == 4 && (float)var2 > var0.x) {
var1.vertex(var6, var9, var11);
var1.vertex(var6, var9, var10);
var1.vertex(var6, var8, var10);
var1.vertex(var6, var8, var11);
}
if(var5 == 5 && (float)var2 < var0.x) {
var1.vertex(var7, var8, var11);
var1.vertex(var7, var8, var10);
var1.vertex(var7, var9, var10);
var1.vertex(var7, var9, var11);
}
}
public AABB getTileAABB(int var1, int var2, int var3) {
return new AABB((float)var1, (float)var2, (float)var3, (float)(var1 + 1), (float)(var2 + 1), (float)(var3 + 1));
}
public boolean blocksLight() {
return true;
}
public boolean isSolid() {
return true;
}
public void tick(Level var1, int var2, int var3, int var4, Random var5) {
}
public final void destroy(Level var1, int var2, int var3, int var4, ParticleEngine var5) {
for(int var6 = 0; var6 < 4; ++var6) {
for(int var7 = 0; var7 < 4; ++var7) {
for(int var8 = 0; var8 < 4; ++var8) {
float var9 = (float)var2 + ((float)var6 + 0.5F) / (float)4;
float var10 = (float)var3 + ((float)var7 + 0.5F) / (float)4;
float var11 = (float)var4 + ((float)var8 + 0.5F) / (float)4;
Particle var12 = new Particle(var1, var9, var10, var11, var9 - (float)var2 - 0.5F, var10 - (float)var3 - 0.5F, var11 - (float)var4 - 0.5F, this);
var5.particles.add(var12);
}
}
}
}
public Liquid getLiquidType() {
return Liquid.none;
}
public void neighborChanged(Level var1, int var2, int var3, int var4, int var5) {
}
public void onBlockAdded(Level var1, int var2, int var3, int var4) {
}
public int getTickDelay() {
return 0;
}
public void onTileAdded(Level var1, int var2, int var3, int var4) {
}
public void onTileRemoved(Level var1, int var2, int var3, int var4) {
}
public static enum SoundType {
none("-", 0.0F, 0.0F),
grass("grass", 0.6F, 1.0F),
cloth("grass", 0.7F, 1.2F),
gravel("gravel", 1.0F, 1.0F),
stone("stone", 1.0F, 1.0F),
metal("stone", 1.0F, 2.0F),
wood("wood", 1.0F, 1.0F);
public final String name;
private final float volume;
private final float pitch;
private SoundType(String var3, float var4, float var5) {
this.name = var3;
this.volume = var4;
this.pitch = var5;
}
public final float getVolume() {
return this.volume / (Tile.random.nextFloat() * 0.4F + 1.0F) * 0.5F;
}
public final float getPitch() {
return this.pitch / (Tile.random.nextFloat() * 0.2F + 0.9F);
}
}
}

View File

@ -0,0 +1,43 @@
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

@ -0,0 +1,51 @@
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

@ -0,0 +1,320 @@
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

@ -0,0 +1,38 @@
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

@ -0,0 +1,71 @@
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

@ -0,0 +1,36 @@
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

@ -0,0 +1,77 @@
package com.mojang.minecraft.particle;
import com.mojang.minecraft.Entity;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.tile.Tile;
import com.mojang.minecraft.renderer.Tesselator;
public class Particle extends Entity {
private float xd;
private float yd;
private float zd;
public int tex;
private float uo;
private float vo;
private int age = 0;
private int lifetime = 0;
private float size;
private float gravity;
public Particle(Level var1, float var2, float var3, float var4, float var5, float var6, float var7, Tile var8) {
super(var1);
this.tex = var8.tex;
this.gravity = var8.particleGravity;
this.setSize(0.2F, 0.2F);
this.heightOffset = this.bbHeight / 2.0F;
this.setPos(var2, var3, var4);
this.xd = var5 + (float)(Math.random() * 2.0D - 1.0D) * 0.4F;
this.yd = var6 + (float)(Math.random() * 2.0D - 1.0D) * 0.4F;
this.zd = var7 + (float)(Math.random() * 2.0D - 1.0D) * 0.4F;
float var9 = (float)(Math.random() + Math.random() + 1.0D) * 0.15F;
var2 = (float)Math.sqrt((double)(this.xd * this.xd + this.yd * this.yd + this.zd * this.zd));
this.xd = this.xd / var2 * var9 * 0.4F;
this.yd = this.yd / var2 * var9 * 0.4F + 0.1F;
this.zd = this.zd / var2 * var9 * 0.4F;
this.uo = (float)Math.random() * 3.0F;
this.vo = (float)Math.random() * 3.0F;
this.size = (float)(Math.random() * 0.5D + 0.5D);
this.lifetime = (int)(4.0D / (Math.random() * 0.9D + 0.1D));
this.age = 0;
this.makeStepSound = false;
}
public void tick() {
this.xo = this.x;
this.yo = this.y;
this.zo = this.z;
if(this.age++ >= this.lifetime) {
this.remove();
}
this.yd = (float)((double)this.yd - 0.04D * (double)this.gravity);
this.move(this.xd, this.yd, this.zd);
this.xd *= 0.98F;
this.yd *= 0.98F;
this.zd *= 0.98F;
if(this.onGround) {
this.xd *= 0.7F;
this.zd *= 0.7F;
}
}
public void render(Tesselator var1, float var2, float var3, float var4, float var5, float var6, float var7) {
float var8 = ((float)(this.tex % 16) + this.uo / 4.0F) / 16.0F;
float var9 = var8 + 0.999F / 64.0F;
float var10 = ((float)(this.tex / 16) + this.vo / 4.0F) / 16.0F;
float var11 = var10 + 0.999F / 64.0F;
float var12 = 0.1F * this.size;
float var13 = this.xo + (this.x - this.xo) * var2;
float var14 = this.yo + (this.y - this.yo) * var2;
float var15 = this.zo + (this.z - this.zo) * var2;
var1.vertexUV(var13 - var3 * var12 - var6 * var12, var14 - var4 * var12, var15 - var5 * var12 - var7 * var12, var8, var11);
var1.vertexUV(var13 - var3 * var12 + var6 * var12, var14 + var4 * var12, var15 - var5 * var12 + var7 * var12, var8, var10);
var1.vertexUV(var13 + var3 * var12 + var6 * var12, var14 + var4 * var12, var15 + var5 * var12 + var7 * var12, var9, var10);
var1.vertexUV(var13 + var3 * var12 - var6 * var12, var14 - var4 * var12, var15 + var5 * var12 - var7 * var12, var9, var11);
}
}

View File

@ -0,0 +1,54 @@
package com.mojang.minecraft.particle;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.player.Player;
import com.mojang.minecraft.renderer.Tesselator;
import com.mojang.minecraft.renderer.Textures;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
public final class ParticleEngine {
public List particles = new ArrayList();
private Textures textures;
public ParticleEngine(Level var1, Textures var2) {
this.textures = var2;
}
public final void tick() {
for(int var1 = 0; var1 < this.particles.size(); ++var1) {
Particle var2 = (Particle)this.particles.get(var1);
var2.tick();
if(var2.removed) {
this.particles.remove(var1--);
}
}
}
public final void render(Player var1, float var2) {
if(this.particles.size() != 0) {
GL11.glEnable(GL11.GL_TEXTURE_2D);
int var3 = this.textures.getTextureId("/terrain.png");
GL11.glBindTexture(GL11.GL_TEXTURE_2D, var3);
float var12 = -((float)Math.cos((double)var1.yRot * Math.PI / 180.0D));
float var4 = -((float)Math.sin((double)var1.yRot * Math.PI / 180.0D));
float var5 = -var4 * (float)Math.sin((double)var1.xRot * Math.PI / 180.0D);
float var6 = var12 * (float)Math.sin((double)var1.xRot * Math.PI / 180.0D);
float var11 = (float)Math.cos((double)var1.xRot * Math.PI / 180.0D);
Tesselator var7 = Tesselator.instance;
var7.begin();
for(int var8 = 0; var8 < this.particles.size(); ++var8) {
Particle var9 = (Particle)this.particles.get(var8);
float var10 = 0.8F * var9.getBrightness();
var7.color(var10, var10, var10);
var9.render(var7, var2, var12, var11, var4, var5, var6);
}
var7.end();
GL11.glDisable(GL11.GL_TEXTURE_2D);
}
}
}

View File

@ -0,0 +1,165 @@
package com.mojang.minecraft.phys;
import java.io.Serializable;
public class AABB implements Serializable {
public static final long serialVersionUID = 0L;
private float epsilon = 0.0F;
public float x0;
public float y0;
public float z0;
public float x1;
public float y1;
public float z1;
public AABB(float var1, float var2, float var3, float var4, float var5, float var6) {
this.x0 = var1;
this.y0 = var2;
this.z0 = var3;
this.x1 = var4;
this.y1 = var5;
this.z1 = var6;
}
public AABB expand(float var1, float var2, float var3) {
float var4 = this.x0;
float var5 = this.y0;
float var6 = this.z0;
float var7 = this.x1;
float var8 = this.y1;
float var9 = this.z1;
if(var1 < 0.0F) {
var4 += var1;
}
if(var1 > 0.0F) {
var7 += var1;
}
if(var2 < 0.0F) {
var5 += var2;
}
if(var2 > 0.0F) {
var8 += var2;
}
if(var3 < 0.0F) {
var6 += var3;
}
if(var3 > 0.0F) {
var9 += var3;
}
return new AABB(var4, var5, var6, var7, var8, var9);
}
public AABB grow(float var1, float var2, float var3) {
float var4 = this.x0 - var1;
float var5 = this.y0 - var2;
float var6 = this.z0 - var3;
var1 += this.x1;
var2 += this.y1;
float var7 = this.z1 + var3;
return new AABB(var4, var5, var6, var1, var2, var7);
}
public AABB cloneMove(float var1, float var2, float var3) {
return new AABB(this.x0 + var3, this.y0 + var2, this.z0 + var3, this.x1 + var1, this.y1 + var2, this.z1 + var3);
}
public float clipXCollide(AABB var1, float var2) {
if(var1.y1 > this.y0 && var1.y0 < this.y1) {
if(var1.z1 > this.z0 && var1.z0 < this.z1) {
float var3;
if(var2 > 0.0F && var1.x1 <= this.x0) {
var3 = this.x0 - var1.x1 - this.epsilon;
if(var3 < var2) {
var2 = var3;
}
}
if(var2 < 0.0F && var1.x0 >= this.x1) {
var3 = this.x1 - var1.x0 + this.epsilon;
if(var3 > var2) {
var2 = var3;
}
}
return var2;
} else {
return var2;
}
} else {
return var2;
}
}
public float clipYCollide(AABB var1, float var2) {
if(var1.x1 > this.x0 && var1.x0 < this.x1) {
if(var1.z1 > this.z0 && var1.z0 < this.z1) {
float var3;
if(var2 > 0.0F && var1.y1 <= this.y0) {
var3 = this.y0 - var1.y1 - this.epsilon;
if(var3 < var2) {
var2 = var3;
}
}
if(var2 < 0.0F && var1.y0 >= this.y1) {
var3 = this.y1 - var1.y0 + this.epsilon;
if(var3 > var2) {
var2 = var3;
}
}
return var2;
} else {
return var2;
}
} else {
return var2;
}
}
public float clipZCollide(AABB var1, float var2) {
if(var1.x1 > this.x0 && var1.x0 < this.x1) {
if(var1.y1 > this.y0 && var1.y0 < this.y1) {
float var3;
if(var2 > 0.0F && var1.z1 <= this.z0) {
var3 = this.z0 - var1.z1 - this.epsilon;
if(var3 < var2) {
var2 = var3;
}
}
if(var2 < 0.0F && var1.z0 >= this.z1) {
var3 = this.z1 - var1.z0 + this.epsilon;
if(var3 > var2) {
var2 = var3;
}
}
return var2;
} else {
return var2;
}
} else {
return var2;
}
}
public boolean intersects(AABB var1) {
return var1.x1 > this.x0 && var1.x0 < this.x1 ? (var1.y1 > this.y0 && var1.y0 < this.y1 ? var1.z1 > this.z0 && var1.z0 < this.z1 : false) : false;
}
public void move(float var1, float var2, float var3) {
this.x0 += var1;
this.y0 += var2;
this.z0 += var3;
this.x1 += var1;
this.y1 += var2;
this.z1 += var3;
}
}

View File

@ -0,0 +1,60 @@
package com.mojang.minecraft.player;
import com.mojang.minecraft.User;
import com.mojang.minecraft.level.tile.Tile;
public final class Inventory {
public int[] slots = new int[9];
public int selectedSlot = 0;
public Inventory() {
for(int var1 = 0; var1 < 9; ++var1) {
this.slots[var1] = ((Tile)User.creativeTiles.get(var1)).id;
}
}
public final int getSelected() {
return this.slots[this.selectedSlot];
}
public int containsTileAt(int var1) {
for(int var2 = 0; var2 < this.slots.length; ++var2) {
if(var1 == this.slots[var2]) {
return var2;
}
}
return -1;
}
public final void scrollHotbar(int var1) {
if(var1 > 0) {
var1 = 1;
}
if(var1 < 0) {
var1 = -1;
}
for(this.selectedSlot -= var1; this.selectedSlot < 0; this.selectedSlot += this.slots.length) {
}
while(this.selectedSlot >= this.slots.length) {
this.selectedSlot -= this.slots.length;
}
}
public final void setTile(Tile var1) {
if(var1 != null) {
int var2 = this.containsTileAt(var1.id);
if(var2 >= 0) {
this.slots[var2] = this.slots[this.selectedSlot];
}
this.slots[this.selectedSlot] = var1.id;
}
}
}

View File

@ -0,0 +1,17 @@
package com.mojang.minecraft.player;
public class MovementInput {
public float moveStrafe = 0.0F;
public float moveForward = 0.0F;
public boolean jump = false;
public boolean jumpHeld = false;
public void updatePlayerMoveState() {
}
public void releaseAllKeys() {
}
public void setKey(int var1, boolean var2) {
}
}

View File

@ -0,0 +1,69 @@
package com.mojang.minecraft.player;
import com.mojang.minecraft.Options;
public final class MovementInputFromOptions extends MovementInput {
private boolean[] keys = new boolean[10];
private Options f;
public MovementInputFromOptions(Options var1) {
this.f = var1;
}
public final void setKey(int var1, boolean var2) {
byte var3 = -1;
if(var1 == this.f.forward.key) {
var3 = 0;
}
if(var1 == this.f.back.key) {
var3 = 1;
}
if(var1 == this.f.left.key) {
var3 = 2;
}
if(var1 == this.f.right.key) {
var3 = 3;
}
if(var1 == this.f.jump.key) {
var3 = 4;
}
if(var3 >= 0) {
this.keys[var3] = var2;
}
}
public final void releaseAllKeys() {
for(int var1 = 0; var1 < 10; ++var1) {
this.keys[var1] = false;
}
}
public final void updatePlayerMoveState() {
this.moveStrafe = 0.0F;
this.moveForward = 0.0F;
if(this.keys[0]) {
--this.moveForward;
}
if(this.keys[1]) {
++this.moveForward;
}
if(this.keys[2]) {
--this.moveStrafe;
}
if(this.keys[3]) {
++this.moveStrafe;
}
this.jumpHeld = this.keys[4];
}
}

View File

@ -0,0 +1,83 @@
package com.mojang.minecraft.player;
import com.mojang.minecraft.Entity;
import com.mojang.minecraft.level.Level;
public class Player extends Entity {
private MovementInput input;
public Inventory inventory = new Inventory();
public byte userType = 0;
public Player(Level var1, MovementInput var2) {
super(var1);
this.heightOffset = 1.62F;
this.input = var2;
}
public void tick() {
super.tick();
boolean var1 = this.isInWater();
boolean var2 = this.isInLava();
this.input.updatePlayerMoveState();
if(this.input.jumpHeld) {
if(var1) {
this.yd += 0.04F;
} else if(var2) {
this.yd += 0.04F;
} else if(this.onGround && !this.input.jump) {
this.yd = 0.42F;
this.input.jump = true;
}
} else {
this.input.jump = false;
}
float var3;
if(var1) {
var3 = this.y;
this.moveRelative(this.input.moveStrafe, this.input.moveForward, 0.02F);
this.move(this.xd, this.yd, this.zd);
this.xd *= 0.8F;
this.yd *= 0.8F;
this.zd *= 0.8F;
this.yd = (float)((double)this.yd - 0.02D);
if(this.horizontalCollision && this.isFree(this.xd, this.yd + 0.6F - this.y + var3, this.zd)) {
this.yd = 0.3F;
}
} else if(var2) {
var3 = this.y;
this.moveRelative(this.input.moveStrafe, this.input.moveForward, 0.02F);
this.move(this.xd, this.yd, this.zd);
this.xd *= 0.5F;
this.yd *= 0.5F;
this.zd *= 0.5F;
this.yd = (float)((double)this.yd - 0.02D);
if(this.horizontalCollision && this.isFree(this.xd, this.yd + 0.6F - this.y + var3, this.zd)) {
this.yd = 0.3F;
}
} else {
this.moveRelative(this.input.moveStrafe, this.input.moveForward, this.onGround ? 0.1F : 0.02F);
this.move(this.xd, this.yd, this.zd);
this.xd *= 0.91F;
this.yd *= 0.98F;
this.zd *= 0.91F;
this.yd = (float)((double)this.yd - 0.08D);
if(this.onGround) {
var3 = 0.6F;
this.xd *= var3;
this.zd *= var3;
}
}
}
public void releaseAllKeys() {
this.input.releaseAllKeys();
}
public void setKey(int var1, boolean var2) {
this.input.setKey(var1, var2);
}
}

View File

@ -0,0 +1,99 @@
package com.mojang.minecraft.renderer;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.tile.Tile;
import com.mojang.minecraft.player.Player;
import java.nio.IntBuffer;
import org.lwjgl.opengl.GL11;
public final class Chunk {
private Level level;
private int lists = -1;
private static Tesselator t = Tesselator.instance;
public static int updates = 0;
private int x0;
private int y0;
private int z0;
private int x1;
private int y1;
private int z1;
private boolean[] skipRenderPass = new boolean[2];
public boolean isInFrustum = false;
public Chunk(Level var1, int var2, int var3, int var4, int var5, int var6) {
this.level = var1;
this.x0 = var2;
this.y0 = var3;
this.z0 = var4;
this.x1 = this.y1 = this.z1 = 16;
Math.sqrt((double)(this.x1 * this.x1 + this.y1 * this.y1 + this.z1 * this.z1));
this.lists = var6;
this.reset();
}
public final float a(Player var1) {
float var2 = var1.x - (float)this.x0;
float var3 = var1.y - (float)this.y0;
float var4 = var1.z - (float)this.z0;
return var2 * var2 + var3 * var3 + var4 * var4;
}
private void reset() {
for(int var1 = 0; var1 < 2; ++var1) {
GL11.glNewList(this.lists + var1, GL11.GL_COMPILE);
GL11.glEndList();
}
}
public final void clear() {
this.reset();
this.level = null;
}
public final void rebuild() {
++updates;
for(int var1 = 0; var1 < 2; ++var1) {
int var3 = var1;
Chunk var2 = this;
int var4 = this.x0;
int var5 = this.y0;
int var6 = this.z0;
int var7 = this.x0 + this.x1;
int var8 = this.y0 + this.y1;
int var9 = this.z0 + this.z1;
GL11.glNewList(this.lists + var1, GL11.GL_COMPILE);
t.begin();
boolean var10 = false;
for(var4 = var4; var4 < var7; ++var4) {
for(int var11 = var5; var11 < var8; ++var11) {
for(int var12 = var6; var12 < var9; ++var12) {
int var13 = var2.level.getTile(var4, var11, var12);
if(var13 > 0) {
var10 |= Tile.tiles[var13].render(t, var2.level, var3, var4, var11, var12);
}
}
}
}
t.end();
GL11.glEndList();
if(var2.skipRenderPass[var3] != !var10) {
var2.skipRenderPass[var3] = !var10;
}
}
}
public final void render(IntBuffer var1, int var2) {
if(this.isInFrustum && !this.skipRenderPass[var2]) {
var1.put(this.lists + var2);
}
}
public final void isInFrustum(Frustum var1) {
this.isInFrustum = var1.cubeInFrustum((float)this.x0, (float)this.y0, (float)this.z0, (float)(this.x0 + this.x1), (float)(this.y0 + this.y1), (float)(this.z0 + this.z1));
}
}

View File

@ -0,0 +1,21 @@
package com.mojang.minecraft.renderer;
import com.mojang.minecraft.player.Player;
import java.util.Comparator;
public final class DirtyChunkSorter implements Comparator {
private Player player;
public DirtyChunkSorter(Player var1) {
this.player = var1;
}
public final int compare(Object var1, Object var2) {
Chunk var10001 = (Chunk)var1;
Chunk var6 = (Chunk)var2;
Chunk var5 = var10001;
boolean var3 = var5.isInFrustum;
boolean var4 = var6.isInFrustum;
return var3 && !var4 ? -1 : ((!var4 || var3) && var5.a(this.player) < var6.a(this.player) ? -1 : 1);
}
}

View File

@ -0,0 +1,19 @@
package com.mojang.minecraft.renderer;
import com.mojang.minecraft.player.Player;
import java.util.Comparator;
public final class DistanceSorter implements Comparator {
private Player player;
public DistanceSorter(Player var1) {
this.player = var1;
}
public final int compare(Object var1, Object var2) {
Chunk var10001 = (Chunk)var1;
Chunk var4 = (Chunk)var2;
Chunk var3 = var10001;
return var3.a(this.player) < var4.a(this.player) ? -1 : 1;
}
}

View File

@ -0,0 +1,99 @@
package com.mojang.minecraft.renderer;
import com.mojang.minecraft.phys.AABB;
import java.nio.FloatBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
public final class Frustum {
private float[][] m_Frustum = new float[6][4];
private static Frustum frustum = new Frustum();
private FloatBuffer _proj = BufferUtils.createFloatBuffer(16);
private FloatBuffer _modl = BufferUtils.createFloatBuffer(16);
private FloatBuffer _clip = BufferUtils.createFloatBuffer(16);
private float[] proj = new float[16];
private float[] modl = new float[16];
private float[] clip = new float[16];
public static Frustum getFrustum() {
Frustum var0 = frustum;
var0._proj.clear();
var0._modl.clear();
var0._clip.clear();
GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, var0._proj);
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, var0._modl);
var0._proj.flip().limit(16);
var0._proj.get(var0.proj);
var0._modl.flip().limit(16);
var0._modl.get(var0.modl);
var0.clip[0] = var0.modl[0] * var0.proj[0] + var0.modl[1] * var0.proj[4] + var0.modl[2] * var0.proj[8] + var0.modl[3] * var0.proj[12];
var0.clip[1] = var0.modl[0] * var0.proj[1] + var0.modl[1] * var0.proj[5] + var0.modl[2] * var0.proj[9] + var0.modl[3] * var0.proj[13];
var0.clip[2] = var0.modl[0] * var0.proj[2] + var0.modl[1] * var0.proj[6] + var0.modl[2] * var0.proj[10] + var0.modl[3] * var0.proj[14];
var0.clip[3] = var0.modl[0] * var0.proj[3] + var0.modl[1] * var0.proj[7] + var0.modl[2] * var0.proj[11] + var0.modl[3] * var0.proj[15];
var0.clip[4] = var0.modl[4] * var0.proj[0] + var0.modl[5] * var0.proj[4] + var0.modl[6] * var0.proj[8] + var0.modl[7] * var0.proj[12];
var0.clip[5] = var0.modl[4] * var0.proj[1] + var0.modl[5] * var0.proj[5] + var0.modl[6] * var0.proj[9] + var0.modl[7] * var0.proj[13];
var0.clip[6] = var0.modl[4] * var0.proj[2] + var0.modl[5] * var0.proj[6] + var0.modl[6] * var0.proj[10] + var0.modl[7] * var0.proj[14];
var0.clip[7] = var0.modl[4] * var0.proj[3] + var0.modl[5] * var0.proj[7] + var0.modl[6] * var0.proj[11] + var0.modl[7] * var0.proj[15];
var0.clip[8] = var0.modl[8] * var0.proj[0] + var0.modl[9] * var0.proj[4] + var0.modl[10] * var0.proj[8] + var0.modl[11] * var0.proj[12];
var0.clip[9] = var0.modl[8] * var0.proj[1] + var0.modl[9] * var0.proj[5] + var0.modl[10] * var0.proj[9] + var0.modl[11] * var0.proj[13];
var0.clip[10] = var0.modl[8] * var0.proj[2] + var0.modl[9] * var0.proj[6] + var0.modl[10] * var0.proj[10] + var0.modl[11] * var0.proj[14];
var0.clip[11] = var0.modl[8] * var0.proj[3] + var0.modl[9] * var0.proj[7] + var0.modl[10] * var0.proj[11] + var0.modl[11] * var0.proj[15];
var0.clip[12] = var0.modl[12] * var0.proj[0] + var0.modl[13] * var0.proj[4] + var0.modl[14] * var0.proj[8] + var0.modl[15] * var0.proj[12];
var0.clip[13] = var0.modl[12] * var0.proj[1] + var0.modl[13] * var0.proj[5] + var0.modl[14] * var0.proj[9] + var0.modl[15] * var0.proj[13];
var0.clip[14] = var0.modl[12] * var0.proj[2] + var0.modl[13] * var0.proj[6] + var0.modl[14] * var0.proj[10] + var0.modl[15] * var0.proj[14];
var0.clip[15] = var0.modl[12] * var0.proj[3] + var0.modl[13] * var0.proj[7] + var0.modl[14] * var0.proj[11] + var0.modl[15] * var0.proj[15];
var0.m_Frustum[0][0] = var0.clip[3] - var0.clip[0];
var0.m_Frustum[0][1] = var0.clip[7] - var0.clip[4];
var0.m_Frustum[0][2] = var0.clip[11] - var0.clip[8];
var0.m_Frustum[0][3] = var0.clip[15] - var0.clip[12];
normalizePlane(var0.m_Frustum, 0);
var0.m_Frustum[1][0] = var0.clip[3] + var0.clip[0];
var0.m_Frustum[1][1] = var0.clip[7] + var0.clip[4];
var0.m_Frustum[1][2] = var0.clip[11] + var0.clip[8];
var0.m_Frustum[1][3] = var0.clip[15] + var0.clip[12];
normalizePlane(var0.m_Frustum, 1);
var0.m_Frustum[2][0] = var0.clip[3] + var0.clip[1];
var0.m_Frustum[2][1] = var0.clip[7] + var0.clip[5];
var0.m_Frustum[2][2] = var0.clip[11] + var0.clip[9];
var0.m_Frustum[2][3] = var0.clip[15] + var0.clip[13];
normalizePlane(var0.m_Frustum, 2);
var0.m_Frustum[3][0] = var0.clip[3] - var0.clip[1];
var0.m_Frustum[3][1] = var0.clip[7] - var0.clip[5];
var0.m_Frustum[3][2] = var0.clip[11] - var0.clip[9];
var0.m_Frustum[3][3] = var0.clip[15] - var0.clip[13];
normalizePlane(var0.m_Frustum, 3);
var0.m_Frustum[4][0] = var0.clip[3] - var0.clip[2];
var0.m_Frustum[4][1] = var0.clip[7] - var0.clip[6];
var0.m_Frustum[4][2] = var0.clip[11] - var0.clip[10];
var0.m_Frustum[4][3] = var0.clip[15] - var0.clip[14];
normalizePlane(var0.m_Frustum, 4);
var0.m_Frustum[5][0] = var0.clip[3] + var0.clip[2];
var0.m_Frustum[5][1] = var0.clip[7] + var0.clip[6];
var0.m_Frustum[5][2] = var0.clip[11] + var0.clip[10];
var0.m_Frustum[5][3] = var0.clip[15] + var0.clip[14];
normalizePlane(var0.m_Frustum, 5);
return frustum;
}
private static void normalizePlane(float[][] var0, int var1) {
float var2 = (float)Math.sqrt((double)(var0[var1][0] * var0[var1][0] + var0[var1][1] * var0[var1][1] + var0[var1][2] * var0[var1][2]));
var0[var1][0] /= var2;
var0[var1][1] /= var2;
var0[var1][2] /= var2;
var0[var1][3] /= var2;
}
public final boolean cubeInFrustum(float var1, float var2, float var3, float var4, float var5, float var6) {
for(int var7 = 0; var7 < 6; ++var7) {
if(this.m_Frustum[var7][0] * var1 + this.m_Frustum[var7][1] * var2 + this.m_Frustum[var7][2] * var3 + this.m_Frustum[var7][3] <= 0.0F && this.m_Frustum[var7][0] * var4 + this.m_Frustum[var7][1] * var2 + this.m_Frustum[var7][2] * var3 + this.m_Frustum[var7][3] <= 0.0F && this.m_Frustum[var7][0] * var1 + this.m_Frustum[var7][1] * var5 + this.m_Frustum[var7][2] * var3 + this.m_Frustum[var7][3] <= 0.0F && this.m_Frustum[var7][0] * var4 + this.m_Frustum[var7][1] * var5 + this.m_Frustum[var7][2] * var3 + this.m_Frustum[var7][3] <= 0.0F && this.m_Frustum[var7][0] * var1 + this.m_Frustum[var7][1] * var2 + this.m_Frustum[var7][2] * var6 + this.m_Frustum[var7][3] <= 0.0F && this.m_Frustum[var7][0] * var4 + this.m_Frustum[var7][1] * var2 + this.m_Frustum[var7][2] * var6 + this.m_Frustum[var7][3] <= 0.0F && this.m_Frustum[var7][0] * var1 + this.m_Frustum[var7][1] * var5 + this.m_Frustum[var7][2] * var6 + this.m_Frustum[var7][3] <= 0.0F && this.m_Frustum[var7][0] * var4 + this.m_Frustum[var7][1] * var5 + this.m_Frustum[var7][2] * var6 + this.m_Frustum[var7][3] <= 0.0F) {
return false;
}
}
return true;
}
public final boolean isVisible(AABB var1) {
return this.cubeInFrustum(var1.x0, var1.y0, var1.z0, var1.x1, var1.y1, var1.z1);
}
}

View File

@ -0,0 +1,448 @@
package com.mojang.minecraft.renderer;
import com.mojang.minecraft.Entity;
import com.mojang.minecraft.HitResult;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.tile.Tile;
import com.mojang.minecraft.player.Player;
import java.nio.IntBuffer;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
public final class LevelRenderer {
public Level level;
public Textures textures;
public int surroundLists;
public IntBuffer d = BufferUtils.createIntBuffer(65536);
public Set e = new HashSet();
private Chunk[] h;
public Chunk[] f;
private int i;
private int xChunks;
private int yChunks;
private int zChunks;
public int cloudTickCounter = 0;
private float m = -9999.0F;
private float lX = -9999.0F;
private float lY = -9999.0F;
public LevelRenderer(Textures var1) {
this.textures = var1;
this.surroundLists = GL11.glGenLists(2);
this.zChunks = GL11.glGenLists(4096 << 6 << 1);
}
public final void compileSurroundingGround() {
int var1;
if(this.f != null) {
for(var1 = 0; var1 < this.f.length; ++var1) {
this.f[var1].clear();
}
}
this.i = this.level.width / 16;
this.xChunks = this.level.depth / 16;
this.yChunks = this.level.height / 16;
this.f = new Chunk[this.i * this.xChunks * this.yChunks];
this.h = new Chunk[this.i * this.xChunks * this.yChunks];
var1 = 0;
int var4;
for(int var2 = 0; var2 < this.i; ++var2) {
for(int var3 = 0; var3 < this.xChunks; ++var3) {
for(var4 = 0; var4 < this.yChunks; ++var4) {
this.f[(var4 * this.xChunks + var3) * this.i + var2] = new Chunk(this.level, var2 << 4, var3 << 4, var4 << 4, 16, this.zChunks + var1);
this.h[(var4 * this.xChunks + var3) * this.i + var2] = this.f[(var4 * this.xChunks + var3) * this.i + var2];
var1 += 2;
}
}
}
this.e.clear();
GL11.glNewList(this.surroundLists, GL11.GL_COMPILE);
LevelRenderer var9 = this;
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.textures.getTextureId("/rock.png"));
float var10 = 0.5F;
GL11.glColor4f(var10, var10, var10, 1.0F);
Tesselator var11 = Tesselator.instance;
float var12 = this.level.getGroundLevel();
int var5 = 128;
if(128 > this.level.width) {
var5 = this.level.width;
}
if(var5 > this.level.height) {
var5 = this.level.height;
}
int var6 = 2048 / var5;
var11.begin();
int var7;
for(var7 = -var5 * var6; var7 < var9.level.width + var5 * var6; var7 += var5) {
for(int var8 = -var5 * var6; var8 < var9.level.height + var5 * var6; var8 += var5) {
var10 = var12;
if(var7 >= 0 && var8 >= 0 && var7 < var9.level.width && var8 < var9.level.height) {
var10 = 0.0F;
}
var11.vertexUV((float)var7, var10, (float)(var8 + var5), 0.0F, (float)var5);
var11.vertexUV((float)(var7 + var5), var10, (float)(var8 + var5), (float)var5, (float)var5);
var11.vertexUV((float)(var7 + var5), var10, (float)var8, (float)var5, 0.0F);
var11.vertexUV((float)var7, var10, (float)var8, 0.0F, 0.0F);
}
}
var11.end();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, var9.textures.getTextureId("/rock.png"));
GL11.glColor3f(0.8F, 0.8F, 0.8F);
var11.begin();
for(var7 = 0; var7 < var9.level.width; var7 += var5) {
var11.vertexUV((float)var7, 0.0F, 0.0F, 0.0F, 0.0F);
var11.vertexUV((float)(var7 + var5), 0.0F, 0.0F, (float)var5, 0.0F);
var11.vertexUV((float)(var7 + var5), var12, 0.0F, (float)var5, var12);
var11.vertexUV((float)var7, var12, 0.0F, 0.0F, var12);
var11.vertexUV((float)var7, var12, (float)var9.level.height, 0.0F, var12);
var11.vertexUV((float)(var7 + var5), var12, (float)var9.level.height, (float)var5, var12);
var11.vertexUV((float)(var7 + var5), 0.0F, (float)var9.level.height, (float)var5, 0.0F);
var11.vertexUV((float)var7, 0.0F, (float)var9.level.height, 0.0F, 0.0F);
}
GL11.glColor3f(0.6F, 0.6F, 0.6F);
for(var7 = 0; var7 < var9.level.height; var7 += var5) {
var11.vertexUV(0.0F, var12, (float)var7, 0.0F, 0.0F);
var11.vertexUV(0.0F, var12, (float)(var7 + var5), (float)var5, 0.0F);
var11.vertexUV(0.0F, 0.0F, (float)(var7 + var5), (float)var5, var12);
var11.vertexUV(0.0F, 0.0F, (float)var7, 0.0F, var12);
var11.vertexUV((float)var9.level.width, 0.0F, (float)var7, 0.0F, var12);
var11.vertexUV((float)var9.level.width, 0.0F, (float)(var7 + var5), (float)var5, var12);
var11.vertexUV((float)var9.level.width, var12, (float)(var7 + var5), (float)var5, 0.0F);
var11.vertexUV((float)var9.level.width, var12, (float)var7, 0.0F, 0.0F);
}
var11.end();
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEndList();
GL11.glNewList(this.surroundLists + 1, GL11.GL_COMPILE);
var9 = this;
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glColor3f(1.0F, 1.0F, 1.0F);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.textures.getTextureId("/water.png"));
var10 = this.level.getWaterLevel();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
var11 = Tesselator.instance;
var4 = 128;
if(128 > this.level.width) {
var4 = this.level.width;
}
if(var4 > this.level.height) {
var4 = this.level.height;
}
var5 = 2048 / var4;
var11.begin();
for(var6 = -var4 * var5; var6 < var9.level.width + var4 * var5; var6 += var4) {
for(var7 = -var4 * var5; var7 < var9.level.height + var4 * var5; var7 += var4) {
float var13 = var10 - 0.1F;
if(var6 < 0 || var7 < 0 || var6 >= var9.level.width || var7 >= var9.level.height) {
var11.vertexUV((float)var6, var13, (float)(var7 + var4), 0.0F, (float)var4);
var11.vertexUV((float)(var6 + var4), var13, (float)(var7 + var4), (float)var4, (float)var4);
var11.vertexUV((float)(var6 + var4), var13, (float)var7, (float)var4, 0.0F);
var11.vertexUV((float)var6, var13, (float)var7, 0.0F, 0.0F);
var11.vertexUV((float)var6, var13, (float)var7, 0.0F, 0.0F);
var11.vertexUV((float)(var6 + var4), var13, (float)var7, (float)var4, 0.0F);
var11.vertexUV((float)(var6 + var4), var13, (float)(var7 + var4), (float)var4, (float)var4);
var11.vertexUV((float)var6, var13, (float)(var7 + var4), 0.0F, (float)var4);
}
}
}
var11.end();
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEndList();
this.setDirty(0, 0, 0, this.level.width, this.level.depth, this.level.height);
}
public final void renderEntities(Frustum var1, float var2) {
for(int var3 = 0; var3 < this.level.entities.size(); ++var3) {
Entity var4 = (Entity)this.level.entities.get(var3);
if(var1.isVisible(var4.bb)) {
((Entity)this.level.entities.get(var3)).render(this.textures, var2);
}
}
}
public final int render(Player var1, int var2) {
float var3 = var1.x - this.m;
float var4 = var1.y - this.lX;
float var5 = var1.z - this.lY;
if(var3 * var3 + var4 * var4 + var5 * var5 > 64.0F) {
this.m = var1.x;
this.lX = var1.y;
this.lY = var1.z;
Arrays.sort(this.h, new DistanceSorter(var1));
}
this.d.clear();
for(int var6 = 0; var6 < this.h.length; ++var6) {
this.h[var6].render(this.d, var2);
}
this.d.flip();
if(this.d.remaining() > 0) {
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.textures.getTextureId("/terrain.png"));
GL11.glCallLists(this.d);
GL11.glDisable(GL11.GL_TEXTURE_2D);
}
return this.d.remaining();
}
public final void renderClouds(float var1) {
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.textures.getTextureId("/clouds.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Tesselator var2 = Tesselator.instance;
float var3 = 0.0F;
float var4 = 0.5F / 1024.0F;
var3 = (float)(this.level.depth + 2);
var1 = ((float)this.cloudTickCounter + var1) * var4 * 0.03F;
float var5 = 0.0F;
var2.begin();
int var8;
for(var8 = -2048; var8 < this.level.width + 2048; var8 += 512) {
for(int var6 = -2048; var6 < this.level.height + 2048; var6 += 512) {
var2.vertexUV((float)var8, var3, (float)(var6 + 512), (float)var8 * var4 + var1, (float)(var6 + 512) * var4);
var2.vertexUV((float)(var8 + 512), var3, (float)(var6 + 512), (float)(var8 + 512) * var4 + var1, (float)(var6 + 512) * var4);
var2.vertexUV((float)(var8 + 512), var3, (float)var6, (float)(var8 + 512) * var4 + var1, (float)var6 * var4);
var2.vertexUV((float)var8, var3, (float)var6, (float)var8 * var4 + var1, (float)var6 * var4);
var2.vertexUV((float)var8, var3, (float)var6, (float)var8 * var4 + var1, (float)var6 * var4);
var2.vertexUV((float)(var8 + 512), var3, (float)var6, (float)(var8 + 512) * var4 + var1, (float)var6 * var4);
var2.vertexUV((float)(var8 + 512), var3, (float)(var6 + 512), (float)(var8 + 512) * var4 + var1, (float)(var6 + 512) * var4);
var2.vertexUV((float)var8, var3, (float)(var6 + 512), (float)var8 * var4 + var1, (float)(var6 + 512) * var4);
}
}
var2.end();
GL11.glDisable(GL11.GL_TEXTURE_2D);
var2.begin();
var2.color(0.5F, 0.8F, 1.0F);
var3 = (float)(this.level.depth + 10);
for(int var7 = -2048; var7 < this.level.width + 2048; var7 += 512) {
for(var8 = -2048; var8 < this.level.height + 2048; var8 += 512) {
var2.vertex((float)var7, var3, (float)var8);
var2.vertex((float)(var7 + 512), var3, (float)var8);
var2.vertex((float)(var7 + 512), var3, (float)(var8 + 512));
var2.vertex((float)var7, var3, (float)(var8 + 512));
}
}
var2.end();
}
public final void render(int var1, int var2, int var3) {
int var6 = this.level.getTile(var1, var2, var3);
if(var6 != 0 && Tile.tiles[var6].isSolid()) {
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glColor4f(0.2F, 0.2F, 0.2F, 1.0F);
GL11.glDepthFunc(GL11.GL_LESS);
Tesselator var4 = Tesselator.instance;
var4.begin();
int var5;
for(var5 = 0; var5 < 6; ++var5) {
Tile.tiles[var6].renderFace(var4, var1, var2, var3, var5);
}
var4.end();
GL11.glCullFace(GL11.GL_FRONT);
var4.begin();
for(var5 = 0; var5 < 6; ++var5) {
Tile.tiles[var6].renderFace(var4, var1, var2, var3, var5);
}
var4.end();
GL11.glCullFace(GL11.GL_BACK);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDepthFunc(GL11.GL_LEQUAL);
}
}
public final void renderHit(Player var1, HitResult var2, int var3, int var4) {
Tesselator var5 = Tesselator.instance;
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glColor4f(1.0F, 1.0F, 1.0F, ((float)Math.sin((double)System.currentTimeMillis() / 100.0D) * 0.2F + 0.4F) * 0.5F);
if(var3 == 0) {
var5.begin();
for(var3 = 0; var3 < 6; ++var3) {
Tile.renderFaceNoTexture(var1, var5, var2.x, var2.y, var2.z, var3);
}
var5.end();
} else {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
float var8 = (float)Math.sin((double)System.currentTimeMillis() / 100.0D) * 0.2F + 0.8F;
GL11.glColor4f(var8, var8, var8, (float)Math.sin((double)System.currentTimeMillis() / 200.0D) * 0.2F + 0.5F);
GL11.glEnable(GL11.GL_TEXTURE_2D);
int var7 = this.textures.getTextureId("/terrain.png");
GL11.glBindTexture(GL11.GL_TEXTURE_2D, var7);
var7 = var2.x;
var3 = var2.y;
int var6 = var2.z;
if(var2.f == 0) {
--var3;
}
if(var2.f == 1) {
++var3;
}
if(var2.f == 2) {
--var6;
}
if(var2.f == 3) {
++var6;
}
if(var2.f == 4) {
--var7;
}
if(var2.f == 5) {
++var7;
}
var5.begin();
var5.noColor();
Tile.tiles[var4].render(var5, this.level, 0, var7, var3, var6);
Tile.tiles[var4].render(var5, this.level, 1, var7, var3, var6);
var5.end();
GL11.glDisable(GL11.GL_TEXTURE_2D);
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
}
public static void renderHitOutline(HitResult var0, int var1) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F);
float var2 = (float)var0.x;
float var3 = (float)var0.y;
float var4 = (float)var0.z;
if(var1 == 1) {
if(var0.f == 0) {
--var3;
}
if(var0.f == 1) {
++var3;
}
if(var0.f == 2) {
--var4;
}
if(var0.f == 3) {
++var4;
}
if(var0.f == 4) {
--var2;
}
if(var0.f == 5) {
++var2;
}
}
GL11.glBegin(GL11.GL_LINE_STRIP);
GL11.glVertex3f(var2, var3, var4);
GL11.glVertex3f(var2 + 1.0F, var3, var4);
GL11.glVertex3f(var2 + 1.0F, var3, var4 + 1.0F);
GL11.glVertex3f(var2, var3, var4 + 1.0F);
GL11.glVertex3f(var2, var3, var4);
GL11.glEnd();
GL11.glBegin(GL11.GL_LINE_STRIP);
GL11.glVertex3f(var2, var3 + 1.0F, var4);
GL11.glVertex3f(var2 + 1.0F, var3 + 1.0F, var4);
GL11.glVertex3f(var2 + 1.0F, var3 + 1.0F, var4 + 1.0F);
GL11.glVertex3f(var2, var3 + 1.0F, var4 + 1.0F);
GL11.glVertex3f(var2, var3 + 1.0F, var4);
GL11.glEnd();
GL11.glBegin(GL11.GL_LINES);
GL11.glVertex3f(var2, var3, var4);
GL11.glVertex3f(var2, var3 + 1.0F, var4);
GL11.glVertex3f(var2 + 1.0F, var3, var4);
GL11.glVertex3f(var2 + 1.0F, var3 + 1.0F, var4);
GL11.glVertex3f(var2 + 1.0F, var3, var4 + 1.0F);
GL11.glVertex3f(var2 + 1.0F, var3 + 1.0F, var4 + 1.0F);
GL11.glVertex3f(var2, var3, var4 + 1.0F);
GL11.glVertex3f(var2, var3 + 1.0F, var4 + 1.0F);
GL11.glEnd();
GL11.glDisable(GL11.GL_BLEND);
}
public final void setDirty(int var1, int var2, int var3, int var4, int var5, int var6) {
var1 /= 16;
var2 /= 16;
var3 /= 16;
var4 /= 16;
var5 /= 16;
var6 /= 16;
if(var1 < 0) {
var1 = 0;
}
if(var2 < 0) {
var2 = 0;
}
if(var3 < 0) {
var3 = 0;
}
if(var4 > this.i - 1) {
var4 = this.i - 1;
}
if(var5 > this.xChunks - 1) {
var5 = this.xChunks - 1;
}
if(var6 > this.yChunks - 1) {
var6 = this.yChunks - 1;
}
for(var1 = var1; var1 <= var4; ++var1) {
for(int var7 = var2; var7 <= var5; ++var7) {
for(int var8 = var3; var8 <= var6; ++var8) {
this.e.add(this.f[(var8 * this.xChunks + var7) * this.i + var1]);
}
}
}
}
}

View File

@ -0,0 +1,95 @@
package com.mojang.minecraft.renderer;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.character.Vec3;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.liquid.Liquid;
import com.mojang.minecraft.level.tile.Tile;
import com.mojang.minecraft.player.Player;
import java.nio.FloatBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
public final class RenderHelper {
public Minecraft a;
public float fogColorMultiplier = 1.0F;
public boolean displayActive = false;
public float fogColorRed = 0.5F;
public float fogColorGreen = 0.8F;
public float fogColorBlue = 1.0F;
public float renderDistance = 0.0F;
private volatile int unusedInt1 = 0;
private volatile int unusedInt2 = 0;
private FloatBuffer lb = BufferUtils.createFloatBuffer(16);
public RenderHelper(Minecraft var1) {
this.a = var1;
}
public void toggleLight(boolean var1) {
if(!var1) {
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_LIGHT0);
} else {
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_LIGHT0);
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
GL11.glColorMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_AMBIENT_AND_DIFFUSE);
float var4 = 0.7F;
float var2 = 0.3F;
Vec3 var3 = (new Vec3(0.0F, -1.0F, 0.5F)).normalize();
GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, this.getBuffer(var3.x, var3.y, var3.z, 0.0F));
GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, this.getBuffer(var2, var2, var2, 1.0F));
GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, this.getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, this.getBuffer(var4, var4, var4, 1.0F));
}
}
public final void initGui() {
int var1 = this.a.width * 240 / this.a.height;
int var2 = this.a.height * 240 / this.a.height;
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0.0D, (double)var1, (double)var2, 0.0D, 100.0D, 300.0D);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glTranslatef(0.0F, 0.0F, -200.0F);
}
public void setupFog() {
Level var1 = this.a.level;
Player var2 = this.a.player;
GL11.glFog(GL11.GL_FOG_COLOR, this.getBuffer(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 1.0F));
GL11.glNormal3f(0.0F, -1.0F, 0.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Tile var3 = Tile.tiles[var1.getTile((int)var2.x, (int)(var2.y + 0.12F), (int)var2.z)];
if(var3 != null && var3.getLiquidType() != Liquid.none) {
Liquid var4 = var3.getLiquidType();
GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP);
if(var4 == Liquid.water) {
GL11.glFogf(GL11.GL_FOG_DENSITY, 0.1F);
GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, this.getBuffer(0.4F, 0.4F, 0.9F, 1.0F));
} else if(var4 == Liquid.lava) {
GL11.glFogf(GL11.GL_FOG_DENSITY, 2.0F);
GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, this.getBuffer(0.4F, 0.3F, 0.3F, 1.0F));
}
} else {
GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR);
GL11.glFogf(GL11.GL_FOG_START, 0.0F);
GL11.glFogf(GL11.GL_FOG_END, this.renderDistance);
GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, this.getBuffer(1.0F, 1.0F, 1.0F, 1.0F));
}
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
GL11.glColorMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT);
GL11.glEnable(GL11.GL_LIGHTING);
}
private FloatBuffer getBuffer(float var1, float var2, float var3, float var4) {
this.lb.clear();
this.lb.put(var1).put(var2).put(var3).put(var4);
this.lb.flip();
return this.lb;
}
}

View File

@ -0,0 +1,149 @@
package com.mojang.minecraft.renderer;
import java.nio.FloatBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
public final class Tesselator {
private FloatBuffer buffer = BufferUtils.createFloatBuffer(524288);
private float[] array = new float[524288];
private int vertices = 0;
private float u;
private float v;
private float r;
private float g;
private float b;
private boolean hasColor = 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() {
if(this.vertices > 0) {
this.buffer.clear();
this.buffer.put(this.array, 0, this.p);
this.buffer.flip();
if(this.hasTexture && this.hasColor) {
GL11.glInterleavedArrays(GL11.GL_T2F_C3F_V3F, 0, (FloatBuffer)this.buffer);
} else if(this.hasTexture) {
GL11.glInterleavedArrays(GL11.GL_T2F_V3F, 0, (FloatBuffer)this.buffer);
} else if(this.hasColor) {
GL11.glInterleavedArrays(GL11.GL_C3F_V3F, 0, (FloatBuffer)this.buffer);
} else {
GL11.glInterleavedArrays(GL11.GL_V3F, 0, (FloatBuffer)this.buffer);
}
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
if(this.hasTexture) {
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
}
if(this.hasColor) {
GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
}
GL11.glDrawArrays(GL11.GL_QUADS, GL11.GL_POINTS, this.vertices);
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
if(this.hasTexture) {
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
}
if(this.hasColor) {
GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
}
}
this.clear();
}
private void clear() {
this.vertices = 0;
this.buffer.clear();
this.p = 0;
}
public final void begin() {
this.clear();
this.hasColor = false;
this.hasTexture = false;
this.noColor = false;
}
public final void color(float var1, float var2, float var3) {
if(!this.noColor) {
if(!this.hasColor) {
this.len += 3;
}
this.hasColor = true;
this.r = var1;
this.g = var2;
this.b = var3;
}
}
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;
}
this.hasTexture = true;
this.u = var4;
this.v = var5;
this.vertex(var1, var2, var3);
}
public final void vertex(float var1, float var2, float var3) {
if(this.hasTexture) {
this.array[this.p++] = this.u;
this.array[this.p++] = this.v;
}
if(this.hasColor) {
this.array[this.p++] = this.r;
this.array[this.p++] = this.g;
this.array[this.p++] = this.b;
}
this.array[this.p++] = var1;
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();
}
}
public final void color(int var1) {
int var2 = var1 >> 16 & 255;
int var3 = var1 >> 8 & 255;
var1 &= 255;
this.color(var2, var3, var1);
}
public final void noColor() {
this.noColor = true;
}
}

View File

@ -0,0 +1,70 @@
package com.mojang.minecraft.renderer;
import com.mojang.minecraft.renderer.texture.TextureFX;
import java.awt.image.BufferedImage;
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 Textures {
private HashMap idMap = new HashMap();
public IntBuffer idBuffer = BufferUtils.createIntBuffer(1);
public ByteBuffer textureBuffer = BufferUtils.createByteBuffer(262144);
public List textureList = new ArrayList();
public final int getTextureId(String var1) {
try {
if(this.idMap.containsKey(var1)) {
return ((Integer)this.idMap.get(var1)).intValue();
} else {
int var2 = this.addTexture(ImageIO.read(Textures.class.getResourceAsStream(var1)));
this.idMap.put(var1, Integer.valueOf(var2));
return var2;
}
} catch (IOException var3) {
throw new RuntimeException("!!");
}
}
public final int addTexture(BufferedImage var1) {
this.idBuffer.clear();
GL11.glGenTextures(this.idBuffer);
int var2 = this.idBuffer.get(0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
int var3 = var1.getWidth();
int var4 = var1.getHeight();
int[] var5 = new int[var3 * var4];
byte[] var6 = new byte[var3 * var4 << 2];
var1.getRGB(0, 0, var3, var4, var5, 0, var3);
for(int var11 = 0; var11 < var5.length; ++var11) {
int var7 = var5[var11] >>> 24;
int var8 = var5[var11] >> 16 & 255;
int var9 = var5[var11] >> 8 & 255;
int var10 = var5[var11] & 255;
var6[var11 << 2] = (byte)var8;
var6[(var11 << 2) + 1] = (byte)var9;
var6[(var11 << 2) + 2] = (byte)var10;
var6[(var11 << 2) + 3] = (byte)var7;
}
this.textureBuffer.clear();
this.textureBuffer.put(var6);
this.textureBuffer.position(0).limit(var6.length);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, var3, var4, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)this.textureBuffer);
return var2;
}
public final void registerTextureFX(TextureFX var1) {
this.textureList.add(var1);
var1.onTick();
}
}

View File

@ -1,11 +1,8 @@
package net.minecraft.src; package com.mojang.minecraft.renderer.texture;
public class TextureFX { public class TextureFX {
public byte[] imageData = new byte[1024]; public byte[] imageData = new byte[1024];
public int iconIndex; public int iconIndex;
public boolean anaglyphEnabled = false;
public int textureId = 0;
public int tileSize = 1;
public TextureFX(int var1) { public TextureFX(int var1) {
this.iconIndex = var1; this.iconIndex = var1;

View File

@ -0,0 +1,72 @@
package com.mojang.minecraft.renderer.texture;
import com.mojang.minecraft.level.tile.Tile;
public final class TextureLavaFX extends TextureFX {
private float[] red = new float[256];
private float[] green = new float[256];
private float[] blue = new float[256];
private float[] alpha = new float[256];
public TextureLavaFX() {
super(Tile.lava.tex);
}
public final void onTick() {
int var2;
float var3;
int var5;
int var6;
int var7;
for(int var1 = 0; var1 < 16; ++var1) {
for(var2 = 0; var2 < 16; ++var2) {
var3 = 0.0F;
int var4 = (int)(Math.sin((double)var2 * Math.PI * 2.0D / 16.0D) * (double)1.2F);
var5 = (int)(Math.sin((double)var1 * Math.PI * 2.0D / 16.0D) * (double)1.2F);
for(var6 = var1 - 1; var6 <= var1 + 1; ++var6) {
for(var7 = var2 - 1; var7 <= var2 + 1; ++var7) {
int var8 = var6 + var4 & 15;
int var9 = var7 + var5 & 15;
var3 += this.red[var8 + (var9 << 4)];
}
}
this.green[var1 + (var2 << 4)] = var3 / 10.0F + (this.blue[(var1 & 15) + ((var2 & 15) << 4)] + this.blue[(var1 + 1 & 15) + ((var2 & 15) << 4)] + this.blue[(var1 + 1 & 15) + ((var2 + 1 & 15) << 4)] + this.blue[(var1 & 15) + ((var2 + 1 & 15) << 4)]) / 4.0F * 0.8F;
this.blue[var1 + (var2 << 4)] += this.alpha[var1 + (var2 << 4)] * 0.01F;
if(this.blue[var1 + (var2 << 4)] < 0.0F) {
this.blue[var1 + (var2 << 4)] = 0.0F;
}
this.alpha[var1 + (var2 << 4)] -= 0.06F;
if(Math.random() < 0.005D) {
this.alpha[var1 + (var2 << 4)] = 1.5F;
}
}
}
float[] var10 = this.green;
this.green = this.red;
this.red = var10;
for(var2 = 0; var2 < 256; ++var2) {
var3 = this.red[var2] * 2.0F;
if(var3 > 1.0F) {
var3 = 1.0F;
}
if(var3 < 0.0F) {
var3 = 0.0F;
}
var5 = (int)(var3 * 100.0F + 155.0F);
var6 = (int)(var3 * var3 * 255.0F);
var7 = (int)(var3 * var3 * var3 * var3 * 128.0F);
this.imageData[var2 << 2] = (byte)var5;
this.imageData[(var2 << 2) + 1] = (byte)var6;
this.imageData[(var2 << 2) + 2] = (byte)var7;
this.imageData[(var2 << 2) + 3] = -1;
}
}
}

View File

@ -0,0 +1,72 @@
package com.mojang.minecraft.renderer.texture;
import com.mojang.minecraft.level.tile.Tile;
public final class TextureWaterFX extends TextureFX {
private float[] red = new float[256];
private float[] green = new float[256];
private float[] blue = new float[256];
private float[] alpha = new float[256];
private int tickCounter = 0;
public TextureWaterFX() {
super(Tile.water.tex);
}
public final void onTick() {
++this.tickCounter;
int var1;
int var2;
float var3;
for(var1 = 0; var1 < 16; ++var1) {
for(var2 = 0; var2 < 16; ++var2) {
var3 = 0.0F;
for(int var4 = var1 - 1; var4 <= var1 + 1; ++var4) {
int var5 = var4 & 15;
int var6 = var2 & 15;
var3 += this.red[var5 + (var6 << 4)];
}
this.green[var1 + (var2 << 4)] = var3 / 3.3F + this.blue[var1 + (var2 << 4)] * 0.8F;
}
}
for(var1 = 0; var1 < 16; ++var1) {
for(var2 = 0; var2 < 16; ++var2) {
this.blue[var1 + (var2 << 4)] += this.alpha[var1 + (var2 << 4)] * 0.05F;
if(this.blue[var1 + (var2 << 4)] < 0.0F) {
this.blue[var1 + (var2 << 4)] = 0.0F;
}
this.alpha[var1 + (var2 << 4)] -= 0.1F;
if(Math.random() < 0.05D) {
this.alpha[var1 + (var2 << 4)] = 0.5F;
}
}
}
float[] var7 = this.green;
this.green = this.red;
this.red = var7;
for(var2 = 0; var2 < 256; ++var2) {
var3 = this.red[var2];
if(var3 > 1.0F) {
var3 = 1.0F;
}
if(var3 < 0.0F) {
var3 = 0.0F;
}
float var8 = var3 * var3;
this.imageData[var2 << 2] = (byte)((int)(32.0F + var8 * 32.0F));
this.imageData[(var2 << 2) + 1] = (byte)((int)(50.0F + var8 * 64.0F));
this.imageData[(var2 << 2) + 2] = -1;
this.imageData[(var2 << 2) + 3] = (byte)((int)(146.0F + var8 * 50.0F));
}
}
}

View File

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

View File

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

View File

@ -0,0 +1,40 @@
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

@ -0,0 +1,20 @@
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

@ -0,0 +1,24 @@
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

@ -0,0 +1,66 @@
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;
}
}
}

Some files were not shown because too many files have changed in this diff Show More