Initial commit
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Flick/workspace/mc94/lib/jars/lwjgl.jar">
|
||||
<attributes>
|
||||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="C:/Users/Flick/workspace/mc94/lib/native-win"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="C:/Users/Flick/workspace/mc94/lib/jars/lwjgl_util.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Flick/workspace/mc94/lib/jars/slick-util.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1,2 @@
|
|||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
|
@ -0,0 +1,23 @@
|
|||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>mc94</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,11 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
After Width: | Height: | Size: 1.8 KiB |
|
@ -0,0 +1,7 @@
|
|||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=Cp1252"/>
|
||||
<body>
|
||||
<applet code=com.mojang.minecraft.MinecraftApplet.class width="200" height="200" >
|
||||
</applet>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,406 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft;
|
||||
|
||||
import com.mojang.minecraft.level.Tesselator;
|
||||
import com.mojang.minecraft.level.tile.Tile;
|
||||
import com.mojang.minecraft.level.Frustum;
|
||||
import org.lwjgl.util.glu.GLU;
|
||||
import com.mojang.minecraft.level.Chunk;
|
||||
import java.awt.Component;
|
||||
import javax.swing.JOptionPane;
|
||||
import java.io.IOException;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.DisplayMode;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import java.nio.IntBuffer;
|
||||
import com.mojang.minecraft.character.Zombie;
|
||||
import java.util.ArrayList;
|
||||
import com.mojang.minecraft.particle.ParticleEngine;
|
||||
import com.mojang.minecraft.level.LevelRenderer;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
public class RubyDung implements Runnable
|
||||
{
|
||||
private static final boolean FULLSCREEN_MODE = false;
|
||||
private int width;
|
||||
private int height;
|
||||
private FloatBuffer fogColor0;
|
||||
private FloatBuffer fogColor1;
|
||||
private Timer timer;
|
||||
private Level level;
|
||||
private LevelRenderer levelRenderer;
|
||||
private Player player;
|
||||
private int paintTexture;
|
||||
private ParticleEngine particleEngine;
|
||||
private ArrayList<Zombie> zombies;
|
||||
private IntBuffer viewportBuffer;
|
||||
private IntBuffer selectBuffer;
|
||||
private HitResult hitResult;
|
||||
FloatBuffer lb;
|
||||
|
||||
public RubyDung() {
|
||||
this.fogColor0 = BufferUtils.createFloatBuffer(4);
|
||||
this.fogColor1 = BufferUtils.createFloatBuffer(4);
|
||||
this.timer = new Timer(20.0f);
|
||||
this.paintTexture = 1;
|
||||
this.zombies = new ArrayList<Zombie>();
|
||||
this.viewportBuffer = BufferUtils.createIntBuffer(16);
|
||||
this.selectBuffer = BufferUtils.createIntBuffer(2000);
|
||||
this.hitResult = null;
|
||||
this.lb = BufferUtils.createFloatBuffer(16);
|
||||
}
|
||||
|
||||
public void init() throws LWJGLException, IOException {
|
||||
final int col0 = 16710650;
|
||||
final int col2 = 920330;
|
||||
final float fr = 0.5f;
|
||||
final float fg = 0.8f;
|
||||
final float fb = 1.0f;
|
||||
this.fogColor0.put(new float[] { (col0 >> 16 & 0xFF) / 255.0f, (col0 >> 8 & 0xFF) / 255.0f, (col0 & 0xFF) / 255.0f, 1.0f });
|
||||
this.fogColor0.flip();
|
||||
this.fogColor1.put(new float[] { (col2 >> 16 & 0xFF) / 255.0f, (col2 >> 8 & 0xFF) / 255.0f, (col2 & 0xFF) / 255.0f, 1.0f });
|
||||
this.fogColor1.flip();
|
||||
Display.setDisplayMode(new DisplayMode(1024, 768));
|
||||
Display.create();
|
||||
Keyboard.create();
|
||||
Mouse.create();
|
||||
this.width = Display.getDisplayMode().getWidth();
|
||||
this.height = Display.getDisplayMode().getHeight();
|
||||
GL11.glEnable(3553);
|
||||
GL11.glShadeModel(7425);
|
||||
GL11.glClearColor(fr, fg, fb, 0.0f);
|
||||
GL11.glClearDepth(1.0);
|
||||
GL11.glEnable(2929);
|
||||
GL11.glDepthFunc(515);
|
||||
GL11.glEnable(3008);
|
||||
GL11.glAlphaFunc(516, 0.5f);
|
||||
GL11.glMatrixMode(5889);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glMatrixMode(5888);
|
||||
this.level = new Level(256, 256, 64);
|
||||
this.levelRenderer = new LevelRenderer(this.level);
|
||||
this.player = new Player(this.level);
|
||||
this.particleEngine = new ParticleEngine(this.level);
|
||||
Mouse.setGrabbed(true);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
final Zombie zombie = new Zombie(this.level, 128.0f, 0.0f, 128.0f);
|
||||
zombie.resetPos();
|
||||
this.zombies.add(zombie);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
this.level.save();
|
||||
Mouse.destroy();
|
||||
Keyboard.destroy();
|
||||
Display.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
this.init();
|
||||
}
|
||||
catch (Exception e) {
|
||||
JOptionPane.showMessageDialog(null, e.toString(), "Failed to start RubyDung", 0);
|
||||
System.exit(0);
|
||||
}
|
||||
long lastTime = System.currentTimeMillis();
|
||||
int frames = 0;
|
||||
try {
|
||||
while (!Keyboard.isKeyDown(1)) {
|
||||
if (Display.isCloseRequested()) {
|
||||
break;
|
||||
}
|
||||
this.timer.advanceTime();
|
||||
for (int i = 0; i < this.timer.ticks; ++i) {
|
||||
this.tick();
|
||||
}
|
||||
this.render(this.timer.a);
|
||||
++frames;
|
||||
while (System.currentTimeMillis() >= lastTime + 1000L) {
|
||||
System.out.println(String.valueOf(frames) + " fps, " + Chunk.updates);
|
||||
Chunk.updates = 0;
|
||||
lastTime += 1000L;
|
||||
frames = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
return;
|
||||
}
|
||||
finally {
|
||||
this.destroy();
|
||||
}
|
||||
this.destroy();
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
while (Keyboard.next()) {
|
||||
if (Keyboard.getEventKeyState()) {
|
||||
if (Keyboard.getEventKey() == 28) {
|
||||
this.level.save();
|
||||
}
|
||||
if (Keyboard.getEventKey() == 2) {
|
||||
this.paintTexture = 1;
|
||||
}
|
||||
if (Keyboard.getEventKey() == 3) {
|
||||
this.paintTexture = 3;
|
||||
}
|
||||
if (Keyboard.getEventKey() == 4) {
|
||||
this.paintTexture = 4;
|
||||
}
|
||||
if (Keyboard.getEventKey() == 5) {
|
||||
this.paintTexture = 5;
|
||||
}
|
||||
if (Keyboard.getEventKey() == 7) {
|
||||
this.paintTexture = 6;
|
||||
}
|
||||
if (Keyboard.getEventKey() != 34) {
|
||||
continue;
|
||||
}
|
||||
this.zombies.add(new Zombie(this.level, this.player.x, this.player.y, this.player.z));
|
||||
}
|
||||
}
|
||||
this.level.tick();
|
||||
this.particleEngine.tick();
|
||||
for (int i = 0; i < this.zombies.size(); ++i) {
|
||||
this.zombies.get(i).tick();
|
||||
if (this.zombies.get(i).removed) {
|
||||
this.zombies.remove(i--);
|
||||
}
|
||||
}
|
||||
this.player.tick();
|
||||
}
|
||||
|
||||
private void moveCameraToPlayer(final float a) {
|
||||
GL11.glTranslatef(0.0f, 0.0f, -0.3f);
|
||||
GL11.glRotatef(this.player.xRot, 1.0f, 0.0f, 0.0f);
|
||||
GL11.glRotatef(this.player.yRot, 0.0f, 1.0f, 0.0f);
|
||||
final float x = this.player.xo + (this.player.x - this.player.xo) * a;
|
||||
final float y = this.player.yo + (this.player.y - this.player.yo) * a;
|
||||
final float z = this.player.zo + (this.player.z - this.player.zo) * a;
|
||||
GL11.glTranslatef(-x, -y, -z);
|
||||
}
|
||||
|
||||
private void setupCamera(final float a) {
|
||||
GL11.glMatrixMode(5889);
|
||||
GL11.glLoadIdentity();
|
||||
GLU.gluPerspective(70.0f, this.width / (float)this.height, 0.05f, 1000.0f);
|
||||
GL11.glMatrixMode(5888);
|
||||
GL11.glLoadIdentity();
|
||||
this.moveCameraToPlayer(a);
|
||||
}
|
||||
|
||||
private void setupPickCamera(final float a, final int x, final int y) {
|
||||
GL11.glMatrixMode(5889);
|
||||
GL11.glLoadIdentity();
|
||||
this.viewportBuffer.clear();
|
||||
GL11.glGetInteger(2978, this.viewportBuffer);
|
||||
this.viewportBuffer.flip();
|
||||
this.viewportBuffer.limit(16);
|
||||
GLU.gluPickMatrix((float)x, (float)y, 5.0f, 5.0f, this.viewportBuffer);
|
||||
GLU.gluPerspective(70.0f, this.width / (float)this.height, 0.05f, 1000.0f);
|
||||
GL11.glMatrixMode(5888);
|
||||
GL11.glLoadIdentity();
|
||||
this.moveCameraToPlayer(a);
|
||||
}
|
||||
|
||||
private void pick(final float a) {
|
||||
this.selectBuffer.clear();
|
||||
GL11.glSelectBuffer(this.selectBuffer);
|
||||
GL11.glRenderMode(7170);
|
||||
this.setupPickCamera(a, this.width / 2, this.height / 2);
|
||||
this.levelRenderer.pick(this.player, Frustum.getFrustum());
|
||||
final int hits = GL11.glRenderMode(7168);
|
||||
this.selectBuffer.flip();
|
||||
this.selectBuffer.limit(this.selectBuffer.capacity());
|
||||
long closest = 0L;
|
||||
final int[] names = new int[10];
|
||||
int hitNameCount = 0;
|
||||
for (int i = 0; i < hits; ++i) {
|
||||
final int nameCount = this.selectBuffer.get();
|
||||
final long minZ = this.selectBuffer.get();
|
||||
this.selectBuffer.get();
|
||||
final long dist = minZ;
|
||||
if (dist < closest || i == 0) {
|
||||
closest = dist;
|
||||
hitNameCount = nameCount;
|
||||
for (int j = 0; j < nameCount; ++j) {
|
||||
names[j] = this.selectBuffer.get();
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int j = 0; j < nameCount; ++j) {
|
||||
this.selectBuffer.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hitNameCount > 0) {
|
||||
this.hitResult = new HitResult(names[0], names[1], names[2], names[3], names[4]);
|
||||
}
|
||||
else {
|
||||
this.hitResult = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void render(final float a) {
|
||||
final float xo = (float)Mouse.getDX();
|
||||
final float yo = (float)Mouse.getDY();
|
||||
this.player.turn(xo, yo);
|
||||
this.pick(a);
|
||||
while (Mouse.next()) {
|
||||
if (Mouse.getEventButton() == 1 && Mouse.getEventButtonState() && this.hitResult != null) {
|
||||
final Tile oldTile = Tile.tiles[this.level.getTile(this.hitResult.x, this.hitResult.y, this.hitResult.z)];
|
||||
final boolean changed = this.level.setTile(this.hitResult.x, this.hitResult.y, this.hitResult.z, 0);
|
||||
if (oldTile != null && changed) {
|
||||
oldTile.destroy(this.level, this.hitResult.x, this.hitResult.y, this.hitResult.z, this.particleEngine);
|
||||
}
|
||||
}
|
||||
if (Mouse.getEventButton() == 0 && Mouse.getEventButtonState() && this.hitResult != null) {
|
||||
int x = this.hitResult.x;
|
||||
int y = this.hitResult.y;
|
||||
int z = this.hitResult.z;
|
||||
if (this.hitResult.f == 0) {
|
||||
--y;
|
||||
}
|
||||
if (this.hitResult.f == 1) {
|
||||
++y;
|
||||
}
|
||||
if (this.hitResult.f == 2) {
|
||||
--z;
|
||||
}
|
||||
if (this.hitResult.f == 3) {
|
||||
++z;
|
||||
}
|
||||
if (this.hitResult.f == 4) {
|
||||
--x;
|
||||
}
|
||||
if (this.hitResult.f == 5) {
|
||||
++x;
|
||||
}
|
||||
this.level.setTile(x, y, z, this.paintTexture);
|
||||
}
|
||||
}
|
||||
GL11.glClear(16640);
|
||||
this.setupCamera(a);
|
||||
GL11.glEnable(2884);
|
||||
final Frustum frustum = Frustum.getFrustum();
|
||||
this.levelRenderer.updateDirtyChunks(this.player);
|
||||
this.setupFog(0);
|
||||
GL11.glEnable(2912);
|
||||
this.levelRenderer.render(this.player, 0);
|
||||
for (int i = 0; i < this.zombies.size(); ++i) {
|
||||
final Zombie zombie = this.zombies.get(i);
|
||||
if (zombie.isLit() && frustum.isVisible(zombie.bb)) {
|
||||
this.zombies.get(i).render(a);
|
||||
}
|
||||
}
|
||||
this.particleEngine.render(this.player, a, 0);
|
||||
this.setupFog(1);
|
||||
this.levelRenderer.render(this.player, 1);
|
||||
for (int i = 0; i < this.zombies.size(); ++i) {
|
||||
final Zombie zombie = this.zombies.get(i);
|
||||
if (!zombie.isLit() && frustum.isVisible(zombie.bb)) {
|
||||
this.zombies.get(i).render(a);
|
||||
}
|
||||
}
|
||||
this.particleEngine.render(this.player, a, 1);
|
||||
GL11.glDisable(2896);
|
||||
GL11.glDisable(3553);
|
||||
GL11.glDisable(2912);
|
||||
if (this.hitResult != null) {
|
||||
GL11.glDisable(3008);
|
||||
this.levelRenderer.renderHit(this.hitResult);
|
||||
GL11.glEnable(3008);
|
||||
}
|
||||
this.drawGui(a);
|
||||
Display.update();
|
||||
}
|
||||
|
||||
private void drawGui(final float a) {
|
||||
final int screenWidth = this.width * 240 / this.height;
|
||||
final int screenHeight = this.height * 240 / this.height;
|
||||
GL11.glClear(256);
|
||||
GL11.glMatrixMode(5889);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glOrtho(0.0, (double)screenWidth, (double)screenHeight, 0.0, 100.0, 300.0);
|
||||
GL11.glMatrixMode(5888);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)(screenWidth - 16), 16.0f, 0.0f);
|
||||
final Tesselator t = Tesselator.instance;
|
||||
GL11.glScalef(16.0f, 16.0f, 16.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);
|
||||
final int id = Textures.loadTexture("/terrain.png", 9728);
|
||||
GL11.glBindTexture(3553, id);
|
||||
GL11.glEnable(3553);
|
||||
t.init();
|
||||
Tile.tiles[this.paintTexture].render(t, this.level, 0, -2, 0, 0);
|
||||
t.flush();
|
||||
GL11.glDisable(3553);
|
||||
GL11.glPopMatrix();
|
||||
final int wc = screenWidth / 2;
|
||||
final int hc = screenHeight / 2;
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
t.init();
|
||||
t.vertex((float)(wc + 1), (float)(hc - 4), 0.0f);
|
||||
t.vertex((float)(wc - 0), (float)(hc - 4), 0.0f);
|
||||
t.vertex((float)(wc - 0), (float)(hc + 5), 0.0f);
|
||||
t.vertex((float)(wc + 1), (float)(hc + 5), 0.0f);
|
||||
t.vertex((float)(wc + 5), (float)(hc - 0), 0.0f);
|
||||
t.vertex((float)(wc - 4), (float)(hc - 0), 0.0f);
|
||||
t.vertex((float)(wc - 4), (float)(hc + 1), 0.0f);
|
||||
t.vertex((float)(wc + 5), (float)(hc + 1), 0.0f);
|
||||
t.flush();
|
||||
}
|
||||
|
||||
private void setupFog(final int i) {
|
||||
if (i == 0) {
|
||||
GL11.glFogi(2917, 2048);
|
||||
GL11.glFogf(2914, 0.001f);
|
||||
GL11.glFog(2918, this.fogColor0);
|
||||
GL11.glDisable(2896);
|
||||
}
|
||||
else if (i == 1) {
|
||||
GL11.glFogi(2917, 2048);
|
||||
GL11.glFogf(2914, 0.06f);
|
||||
GL11.glFog(2918, this.fogColor1);
|
||||
GL11.glEnable(2896);
|
||||
GL11.glEnable(2903);
|
||||
final float br = 0.6f;
|
||||
GL11.glLightModel(2899, this.getBuffer(br, br, br, 1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
private FloatBuffer getBuffer(final float a, final float b, final float c, final float d) {
|
||||
this.lb.clear();
|
||||
this.lb.put(a).put(b).put(c).put(d);
|
||||
this.lb.flip();
|
||||
return this.lb;
|
||||
}
|
||||
|
||||
public static void checkError() {
|
||||
final int e = GL11.glGetError();
|
||||
if (e != 0) {
|
||||
throw new IllegalStateException(GLU.gluErrorString(e));
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(final String[] args) throws LWJGLException {
|
||||
new Thread(new RubyDung()).start();
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 1011 B |
After Width: | Height: | Size: 1.2 KiB |
|
@ -0,0 +1,7 @@
|
|||
/* AUTOMATICALLY GENERATED ON Tue Apr 16 17:20:59 EDT 2002*/
|
||||
/* DO NOT EDIT */
|
||||
|
||||
grant {
|
||||
permission java.security.AllPermission;
|
||||
};
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 306 B |
After Width: | Height: | Size: 1.8 KiB |
|
@ -0,0 +1,156 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft;
|
||||
|
||||
import java.util.List;
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
|
||||
public class Entity
|
||||
{
|
||||
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 AABB bb;
|
||||
public boolean onGround;
|
||||
public boolean horizontalCollision;
|
||||
public boolean removed;
|
||||
protected float heightOffset;
|
||||
protected float bbWidth;
|
||||
protected float bbHeight;
|
||||
|
||||
public Entity(final Level level) {
|
||||
this.onGround = false;
|
||||
this.horizontalCollision = false;
|
||||
this.removed = false;
|
||||
this.heightOffset = 0.0f;
|
||||
this.bbWidth = 0.6f;
|
||||
this.bbHeight = 1.8f;
|
||||
this.level = level;
|
||||
this.resetPos();
|
||||
}
|
||||
|
||||
protected void resetPos() {
|
||||
final float x = (float)Math.random() * (this.level.width - 2) + 1.0f;
|
||||
final float y = (float)(this.level.depth + 10);
|
||||
final float z = (float)Math.random() * (this.level.height - 2) + 1.0f;
|
||||
this.setPos(x, y, z);
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
this.removed = true;
|
||||
}
|
||||
|
||||
protected void setSize(final float w, final float h) {
|
||||
this.bbWidth = w;
|
||||
this.bbHeight = h;
|
||||
}
|
||||
|
||||
protected void setPos(final float x, final float y, final float z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
final float w = this.bbWidth / 2.0f;
|
||||
final float h = this.bbHeight / 2.0f;
|
||||
this.bb = new AABB(x - w, y - h, z - w, x + w, y + h, z + w);
|
||||
}
|
||||
|
||||
public void turn(final float xo, final float yo) {
|
||||
this.yRot += (float)(xo * 0.15);
|
||||
this.xRot -= (float)(yo * 0.15);
|
||||
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;
|
||||
}
|
||||
|
||||
public boolean isFree(final float xa, final float ya, final float za) {
|
||||
final AABB box = this.bb.cloneMove(xa, ya, za);
|
||||
final List<AABB> aABBs = this.level.getCubes(box);
|
||||
return aABBs.size() <= 0 && !this.level.containsAnyLiquid(box);
|
||||
}
|
||||
|
||||
public void move(float xa, float ya, float za) {
|
||||
final float xaOrg = xa;
|
||||
final float yaOrg = ya;
|
||||
final float zaOrg = za;
|
||||
final List<AABB> aABBs = this.level.getCubes(this.bb.expand(xa, ya, za));
|
||||
for (int i = 0; i < aABBs.size(); ++i) {
|
||||
ya = aABBs.get(i).clipYCollide(this.bb, ya);
|
||||
}
|
||||
this.bb.move(0.0f, ya, 0.0f);
|
||||
for (int i = 0; i < aABBs.size(); ++i) {
|
||||
xa = aABBs.get(i).clipXCollide(this.bb, xa);
|
||||
}
|
||||
this.bb.move(xa, 0.0f, 0.0f);
|
||||
for (int i = 0; i < aABBs.size(); ++i) {
|
||||
za = aABBs.get(i).clipZCollide(this.bb, za);
|
||||
}
|
||||
this.bb.move(0.0f, 0.0f, za);
|
||||
this.horizontalCollision = (xaOrg != xa || zaOrg != za);
|
||||
this.onGround = (yaOrg != ya && yaOrg < 0.0f);
|
||||
if (xaOrg != xa) {
|
||||
this.xd = 0.0f;
|
||||
}
|
||||
if (yaOrg != ya) {
|
||||
this.yd = 0.0f;
|
||||
}
|
||||
if (zaOrg != za) {
|
||||
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;
|
||||
}
|
||||
|
||||
public boolean isInWater() {
|
||||
return this.level.containsLiquid(this.bb.grow(0.0f, -0.4f, 0.0f), 1);
|
||||
}
|
||||
|
||||
public boolean isInLava() {
|
||||
return this.level.containsLiquid(this.bb, 2);
|
||||
}
|
||||
|
||||
public void moveRelative(float xa, float za, final float speed) {
|
||||
float dist = xa * xa + za * za;
|
||||
if (dist < 0.01f) {
|
||||
return;
|
||||
}
|
||||
dist = speed / (float)Math.sqrt(dist);
|
||||
xa *= dist;
|
||||
za *= dist;
|
||||
final float sin = (float)Math.sin(this.yRot * 3.141592653589793 / 180.0);
|
||||
final float cos = (float)Math.cos(this.yRot * 3.141592653589793 / 180.0);
|
||||
this.xd += xa * cos - za * sin;
|
||||
this.zd += za * cos + xa * sin;
|
||||
}
|
||||
|
||||
public boolean isLit() {
|
||||
final int xTile = (int)this.x;
|
||||
final int yTile = (int)this.y;
|
||||
final int zTile = (int)this.z;
|
||||
return this.level.isLit(xTile, yTile, zTile);
|
||||
}
|
||||
|
||||
public void render(final float a) {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft;
|
||||
|
||||
public class HitResult
|
||||
{
|
||||
public int type;
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
public int f;
|
||||
|
||||
public HitResult(final int type, final int x, final int y, final int z, final int f) {
|
||||
this.type = type;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.f = f;
|
||||
}
|
||||
|
||||
public boolean isCloserThan(final Player player, final HitResult o, final int editMode) {
|
||||
float dist = this.distanceTo(player, 0);
|
||||
float dist2 = o.distanceTo(player, 0);
|
||||
if (dist < dist2) {
|
||||
return true;
|
||||
}
|
||||
dist = this.distanceTo(player, editMode);
|
||||
dist2 = o.distanceTo(player, editMode);
|
||||
return dist < dist2;
|
||||
}
|
||||
|
||||
private float distanceTo(final Player player, final int editMode) {
|
||||
int xx = this.x;
|
||||
int yy = this.y;
|
||||
int zz = this.z;
|
||||
if (editMode == 1) {
|
||||
if (this.f == 0) {
|
||||
--yy;
|
||||
}
|
||||
if (this.f == 1) {
|
||||
++yy;
|
||||
}
|
||||
if (this.f == 2) {
|
||||
--zz;
|
||||
}
|
||||
if (this.f == 3) {
|
||||
++zz;
|
||||
}
|
||||
if (this.f == 4) {
|
||||
--xx;
|
||||
}
|
||||
if (this.f == 5) {
|
||||
++xx;
|
||||
}
|
||||
}
|
||||
final float xd = xx - player.x;
|
||||
final float yd = yy - player.y;
|
||||
final float zd = zz - player.z;
|
||||
return xd * xd + yd * yd + zd * zd;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,748 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft;
|
||||
|
||||
import com.mojang.minecraft.renderer.Tesselator;
|
||||
import com.mojang.minecraft.renderer.Frustum;
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
import com.mojang.minecraft.level.tile.Tile;
|
||||
import com.mojang.minecraft.gui.PauseScreen;
|
||||
import com.mojang.minecraft.level.Chunk;
|
||||
import java.awt.Component;
|
||||
import javax.swing.JOptionPane;
|
||||
import java.io.OutputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import org.lwjgl.util.glu.GLU;
|
||||
import java.io.IOException;
|
||||
import com.mojang.minecraft.character.Zombie;
|
||||
import java.io.InputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.File;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.opengl.DisplayMode;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import java.nio.IntBuffer;
|
||||
import com.mojang.minecraft.level.levelgen.LevelGen;
|
||||
import com.mojang.minecraft.level.LevelIO;
|
||||
import com.mojang.minecraft.gui.Screen;
|
||||
import com.mojang.minecraft.gui.Font;
|
||||
import com.mojang.minecraft.renderer.Textures;
|
||||
import org.lwjgl.input.Cursor;
|
||||
import java.awt.Canvas;
|
||||
import java.util.ArrayList;
|
||||
import com.mojang.minecraft.particle.ParticleEngine;
|
||||
import com.mojang.minecraft.level.LevelRenderer;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import java.nio.FloatBuffer;
|
||||
import com.mojang.minecraft.level.LevelLoaderListener;
|
||||
|
||||
public class Minecraft implements Runnable, LevelLoaderListener
|
||||
{
|
||||
public static final String VERSION_STRING = "grpf.0.0.13a";
|
||||
private boolean fullscreen;
|
||||
public int width;
|
||||
public int height;
|
||||
private FloatBuffer fogColor0;
|
||||
private FloatBuffer fogColor1;
|
||||
private Timer timer;
|
||||
private Level level;
|
||||
private LevelRenderer levelRenderer;
|
||||
private Player player;
|
||||
private int paintTexture;
|
||||
private ParticleEngine particleEngine;
|
||||
public User user;
|
||||
private ArrayList<Entity> entities;
|
||||
private Canvas parent;
|
||||
public boolean appletMode;
|
||||
public volatile boolean pause;
|
||||
private Cursor emptyCursor;
|
||||
private int yMouseAxis;
|
||||
public Textures textures;
|
||||
public Font font;
|
||||
private int editMode;
|
||||
private Screen screen;
|
||||
private LevelIO levelIo;
|
||||
private LevelGen levelGen;
|
||||
private volatile boolean running;
|
||||
private String fpsString;
|
||||
private boolean mouseGrabbed;
|
||||
private IntBuffer viewportBuffer;
|
||||
private IntBuffer selectBuffer;
|
||||
private HitResult hitResult;
|
||||
FloatBuffer lb;
|
||||
private String title;
|
||||
|
||||
public Minecraft(final Canvas parent, final int width, final int height, final boolean fullscreen) {
|
||||
this.fullscreen = false;
|
||||
this.fogColor0 = BufferUtils.createFloatBuffer(4);
|
||||
this.fogColor1 = BufferUtils.createFloatBuffer(4);
|
||||
this.timer = new Timer(20.0f);
|
||||
this.paintTexture = 1;
|
||||
this.user = new User("noname");
|
||||
this.entities = new ArrayList<Entity>();
|
||||
this.appletMode = false;
|
||||
this.pause = false;
|
||||
this.yMouseAxis = 1;
|
||||
this.editMode = 0;
|
||||
this.screen = null;
|
||||
this.levelIo = new LevelIO(this);
|
||||
this.levelGen = new LevelGen(this);
|
||||
this.running = false;
|
||||
this.fpsString = "";
|
||||
this.mouseGrabbed = false;
|
||||
this.viewportBuffer = BufferUtils.createIntBuffer(16);
|
||||
this.selectBuffer = BufferUtils.createIntBuffer(2000);
|
||||
this.hitResult = null;
|
||||
this.lb = BufferUtils.createFloatBuffer(16);
|
||||
this.title = "";
|
||||
this.parent = parent;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.fullscreen = fullscreen;
|
||||
this.textures = new Textures();
|
||||
}
|
||||
|
||||
public void init() throws LWJGLException, IOException {
|
||||
final int col1 = 920330;
|
||||
final float fr = 0.5f;
|
||||
final float fg = 0.8f;
|
||||
final float fb = 1.0f;
|
||||
this.fogColor0.put(new float[] { fr, fg, fb, 1.0f });
|
||||
this.fogColor0.flip();
|
||||
this.fogColor1.put(new float[] { (col1 >> 16 & 0xFF) / 255.0f, (col1 >> 8 & 0xFF) / 255.0f, (col1 & 0xFF) / 255.0f, 1.0f });
|
||||
this.fogColor1.flip();
|
||||
if (this.parent != null) {
|
||||
Display.setParent(this.parent);
|
||||
}
|
||||
else if (this.fullscreen) {
|
||||
Display.setFullscreen(true);
|
||||
this.width = Display.getDisplayMode().getWidth();
|
||||
this.height = Display.getDisplayMode().getHeight();
|
||||
}
|
||||
else {
|
||||
Display.setDisplayMode(new DisplayMode(this.width, this.height));
|
||||
}
|
||||
Display.setTitle("Minecraft grpf.0.0.13a");
|
||||
try {
|
||||
Display.create();
|
||||
}
|
||||
catch (LWJGLException e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
}
|
||||
catch (InterruptedException ex) {}
|
||||
Display.create();
|
||||
}
|
||||
Keyboard.create();
|
||||
Mouse.create();
|
||||
this.checkGlError("Pre startup");
|
||||
GL11.glEnable(3553);
|
||||
GL11.glShadeModel(7425);
|
||||
GL11.glClearColor(fr, fg, fb, 0.0f);
|
||||
GL11.glClearDepth(1.0);
|
||||
GL11.glEnable(2929);
|
||||
GL11.glDepthFunc(515);
|
||||
GL11.glEnable(3008);
|
||||
GL11.glAlphaFunc(516, 0.0f);
|
||||
GL11.glCullFace(1029);
|
||||
GL11.glMatrixMode(5889);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glMatrixMode(5888);
|
||||
this.checkGlError("Startup");
|
||||
this.font = new Font("/default.gif", this.textures);
|
||||
final IntBuffer imgData = BufferUtils.createIntBuffer(256);
|
||||
imgData.clear().limit(256);
|
||||
GL11.glViewport(0, 0, this.width, this.height);
|
||||
this.level = new Level();
|
||||
boolean success = false;
|
||||
try {
|
||||
success = this.levelIo.load(this.level, new FileInputStream(new File("level.dat")));
|
||||
if (!success) {
|
||||
success = this.levelIo.loadLegacy(this.level, new FileInputStream(new File("level.dat")));
|
||||
}
|
||||
}
|
||||
catch (Exception e3) {
|
||||
success = false;
|
||||
}
|
||||
if (!success) {
|
||||
this.levelGen.generateLevel(this.level, this.user.name, 256, 256, 64);
|
||||
}
|
||||
this.levelRenderer = new LevelRenderer(this.level, this.textures);
|
||||
this.player = new Player(this.level);
|
||||
this.particleEngine = new ParticleEngine(this.level, this.textures);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
final Zombie zombie = new Zombie(this.level, this.textures, 128.0f, 0.0f, 128.0f);
|
||||
zombie.resetPos();
|
||||
this.entities.add(zombie);
|
||||
}
|
||||
if (this.appletMode) {
|
||||
try {
|
||||
this.emptyCursor = new Cursor(16, 16, 0, 0, 1, imgData, (IntBuffer)null);
|
||||
}
|
||||
catch (LWJGLException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.checkGlError("Post startup");
|
||||
}
|
||||
|
||||
public void setScreen(final Screen screen) {
|
||||
this.screen = screen;
|
||||
if (screen != null) {
|
||||
final int screenWidth = this.width * 240 / this.height;
|
||||
final int screenHeight = this.height * 240 / this.height;
|
||||
screen.init(this, screenWidth, screenHeight);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkGlError(final String string) {
|
||||
final int errorCode = GL11.glGetError();
|
||||
if (errorCode != 0) {
|
||||
final String errorString = GLU.gluErrorString(errorCode);
|
||||
System.out.println("########## GL ERROR ##########");
|
||||
System.out.println("@ " + string);
|
||||
System.out.println(String.valueOf(errorCode) + ": " + errorString);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
protected void attemptSaveLevel() {
|
||||
try {
|
||||
this.levelIo.save(this.level, new FileOutputStream(new File("level.dat")));
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
this.attemptSaveLevel();
|
||||
Mouse.destroy();
|
||||
Keyboard.destroy();
|
||||
Display.destroy();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
this.running = true;
|
||||
try {
|
||||
this.init();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, e.toString(), "Failed to start Minecraft [GRPF94 Fork]", 0);
|
||||
return;
|
||||
}
|
||||
long lastTime = System.currentTimeMillis();
|
||||
int frames = 0;
|
||||
try {
|
||||
while (this.running) {
|
||||
if (this.pause) {
|
||||
Thread.sleep(100L);
|
||||
}
|
||||
else {
|
||||
if (this.parent == null && Display.isCloseRequested()) {
|
||||
this.stop();
|
||||
}
|
||||
this.timer.advanceTime();
|
||||
for (int i = 0; i < this.timer.ticks; ++i) {
|
||||
this.tick();
|
||||
}
|
||||
this.checkGlError("Pre render");
|
||||
this.render(this.timer.a);
|
||||
this.checkGlError("Post render");
|
||||
++frames;
|
||||
while (System.currentTimeMillis() >= lastTime + 1000L) {
|
||||
this.fpsString = String.valueOf(frames) + " fps, " + Chunk.updates + " chunk updates";
|
||||
Chunk.updates = 0;
|
||||
lastTime += 1000L;
|
||||
frames = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
return;
|
||||
}
|
||||
finally {
|
||||
this.destroy();
|
||||
}
|
||||
this.destroy();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
this.running = false;
|
||||
}
|
||||
|
||||
public void grabMouse() {
|
||||
if (this.mouseGrabbed) {
|
||||
return;
|
||||
}
|
||||
this.mouseGrabbed = true;
|
||||
if (this.appletMode) {
|
||||
try {
|
||||
Mouse.setNativeCursor(this.emptyCursor);
|
||||
Mouse.setCursorPosition(this.width / 2, this.height / 2);
|
||||
}
|
||||
catch (LWJGLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
Mouse.setGrabbed(true);
|
||||
}
|
||||
this.setScreen(null);
|
||||
}
|
||||
|
||||
public void releaseMouse() {
|
||||
if (!this.mouseGrabbed) {
|
||||
return;
|
||||
}
|
||||
this.player.releaseAllKeys();
|
||||
this.mouseGrabbed = false;
|
||||
if (this.appletMode) {
|
||||
try {
|
||||
Mouse.setNativeCursor((Cursor)null);
|
||||
}
|
||||
catch (LWJGLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
Mouse.setGrabbed(false);
|
||||
}
|
||||
this.setScreen(new PauseScreen());
|
||||
}
|
||||
|
||||
private void handleMouseClick() {
|
||||
if (this.editMode == 0) {
|
||||
if (this.hitResult != null) {
|
||||
final Tile oldTile = Tile.tiles[this.level.getTile(this.hitResult.x, this.hitResult.y, this.hitResult.z)];
|
||||
final boolean changed = this.level.setTile(this.hitResult.x, this.hitResult.y, this.hitResult.z, 0);
|
||||
if (oldTile != null && changed) {
|
||||
oldTile.destroy(this.level, this.hitResult.x, this.hitResult.y, this.hitResult.z, this.particleEngine);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this.hitResult != null) {
|
||||
int x = this.hitResult.x;
|
||||
int y = this.hitResult.y;
|
||||
int z = this.hitResult.z;
|
||||
if (this.hitResult.f == 0) {
|
||||
--y;
|
||||
}
|
||||
if (this.hitResult.f == 1) {
|
||||
++y;
|
||||
}
|
||||
if (this.hitResult.f == 2) {
|
||||
--z;
|
||||
}
|
||||
if (this.hitResult.f == 3) {
|
||||
++z;
|
||||
}
|
||||
if (this.hitResult.f == 4) {
|
||||
--x;
|
||||
}
|
||||
if (this.hitResult.f == 5) {
|
||||
++x;
|
||||
}
|
||||
final AABB aabb = Tile.tiles[this.paintTexture].getAABB(x, y, z);
|
||||
if (aabb == null || this.isFree(aabb)) {
|
||||
this.level.setTile(x, y, z, this.paintTexture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
if (this.screen == null) {
|
||||
while (Mouse.next()) {
|
||||
if (!this.mouseGrabbed && Mouse.getEventButtonState()) {
|
||||
this.grabMouse();
|
||||
}
|
||||
else {
|
||||
if (Mouse.getEventButton() == 0 && Mouse.getEventButtonState()) {
|
||||
this.handleMouseClick();
|
||||
}
|
||||
if (Mouse.getEventButton() != 1 || !Mouse.getEventButtonState()) {
|
||||
continue;
|
||||
}
|
||||
this.editMode = (this.editMode + 1) % 2;
|
||||
}
|
||||
}
|
||||
while (Keyboard.next()) {
|
||||
this.player.setKey(Keyboard.getEventKey(), Keyboard.getEventKeyState());
|
||||
if (Keyboard.getEventKeyState()) {
|
||||
if (Keyboard.getEventKey() == 1) {
|
||||
this.releaseMouse();
|
||||
}
|
||||
if (Keyboard.getEventKey() == 28) {
|
||||
this.attemptSaveLevel();
|
||||
}
|
||||
if (Keyboard.getEventKey() == 19) {
|
||||
this.player.resetPos();
|
||||
}
|
||||
if (Keyboard.getEventKey() == 2) {
|
||||
this.paintTexture = 1;
|
||||
}
|
||||
if (Keyboard.getEventKey() == 3) {
|
||||
this.paintTexture = 3;
|
||||
}
|
||||
if (Keyboard.getEventKey() == 4) {
|
||||
this.paintTexture = 4;
|
||||
}
|
||||
if (Keyboard.getEventKey() == 5) {
|
||||
this.paintTexture = 5;
|
||||
}
|
||||
if (Keyboard.getEventKey() == 7) {
|
||||
this.paintTexture = 6;
|
||||
}
|
||||
if (Keyboard.getEventKey() == 21) {
|
||||
this.yMouseAxis *= -1;
|
||||
}
|
||||
if (Keyboard.getEventKey() == 34) {
|
||||
this.entities.add(new Zombie(this.level, this.textures, this.player.x, this.player.y, this.player.z));
|
||||
}
|
||||
if (Keyboard.getEventKey() != 33) {
|
||||
continue;
|
||||
}
|
||||
this.levelRenderer.toggleDrawDistance();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.screen != null) {
|
||||
this.screen.updateEvents();
|
||||
if (this.screen != null) {
|
||||
this.screen.tick();
|
||||
}
|
||||
}
|
||||
this.level.tick();
|
||||
this.particleEngine.tick();
|
||||
for (int i = 0; i < this.entities.size(); ++i) {
|
||||
this.entities.get(i).tick();
|
||||
if (this.entities.get(i).removed) {
|
||||
this.entities.remove(i--);
|
||||
}
|
||||
}
|
||||
this.player.tick();
|
||||
}
|
||||
|
||||
private boolean isFree(final AABB aabb) {
|
||||
if (this.player.bb.intersects(aabb)) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.entities.size(); ++i) {
|
||||
if (this.entities.get(i).bb.intersects(aabb)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void moveCameraToPlayer(final float a) {
|
||||
GL11.glTranslatef(0.0f, 0.0f, -0.3f);
|
||||
GL11.glRotatef(this.player.xRot, 1.0f, 0.0f, 0.0f);
|
||||
GL11.glRotatef(this.player.yRot, 0.0f, 1.0f, 0.0f);
|
||||
final float x = this.player.xo + (this.player.x - this.player.xo) * a;
|
||||
final float y = this.player.yo + (this.player.y - this.player.yo) * a;
|
||||
final float z = this.player.zo + (this.player.z - this.player.zo) * a;
|
||||
GL11.glTranslatef(-x, -y, -z);
|
||||
}
|
||||
|
||||
private void setupCamera(final float a) {
|
||||
GL11.glMatrixMode(5889);
|
||||
GL11.glLoadIdentity();
|
||||
GLU.gluPerspective(70.0f, this.width / (float)this.height, 0.05f, 1024.0f);
|
||||
GL11.glMatrixMode(5888);
|
||||
GL11.glLoadIdentity();
|
||||
this.moveCameraToPlayer(a);
|
||||
}
|
||||
|
||||
private void setupPickCamera(final float a, final int x, final int y) {
|
||||
GL11.glMatrixMode(5889);
|
||||
GL11.glLoadIdentity();
|
||||
this.viewportBuffer.clear();
|
||||
GL11.glGetInteger(2978, this.viewportBuffer);
|
||||
this.viewportBuffer.flip();
|
||||
this.viewportBuffer.limit(16);
|
||||
GLU.gluPickMatrix((float)x, (float)y, 5.0f, 5.0f, this.viewportBuffer);
|
||||
GLU.gluPerspective(70.0f, this.width / (float)this.height, 0.05f, 1024.0f);
|
||||
GL11.glMatrixMode(5888);
|
||||
GL11.glLoadIdentity();
|
||||
this.moveCameraToPlayer(a);
|
||||
}
|
||||
|
||||
private void pick(final float a) {
|
||||
this.selectBuffer.clear();
|
||||
GL11.glSelectBuffer(this.selectBuffer);
|
||||
GL11.glRenderMode(7170);
|
||||
this.setupPickCamera(a, this.width / 2, this.height / 2);
|
||||
this.levelRenderer.pick(this.player, Frustum.getFrustum());
|
||||
final int hits = GL11.glRenderMode(7168);
|
||||
this.selectBuffer.flip();
|
||||
this.selectBuffer.limit(this.selectBuffer.capacity());
|
||||
final int[] names = new int[10];
|
||||
HitResult bestResult = null;
|
||||
for (int i = 0; i < hits; ++i) {
|
||||
final int nameCount = this.selectBuffer.get();
|
||||
this.selectBuffer.get();
|
||||
this.selectBuffer.get();
|
||||
for (int j = 0; j < nameCount; ++j) {
|
||||
names[j] = this.selectBuffer.get();
|
||||
}
|
||||
this.hitResult = new HitResult(names[0], names[1], names[2], names[3], names[4]);
|
||||
if (bestResult == null || this.hitResult.isCloserThan(this.player, bestResult, this.editMode)) {
|
||||
bestResult = this.hitResult;
|
||||
}
|
||||
}
|
||||
this.hitResult = bestResult;
|
||||
}
|
||||
|
||||
public void render(final float a) {
|
||||
if (!Display.isActive()) {
|
||||
this.releaseMouse();
|
||||
}
|
||||
GL11.glViewport(0, 0, this.width, this.height);
|
||||
if (this.mouseGrabbed) {
|
||||
float xo = 0.0f;
|
||||
float yo = 0.0f;
|
||||
xo = (float)Mouse.getDX();
|
||||
yo = (float)Mouse.getDY();
|
||||
if (this.appletMode) {
|
||||
Display.processMessages();
|
||||
Mouse.poll();
|
||||
xo = (float)(Mouse.getX() - this.width / 2);
|
||||
yo = (float)(Mouse.getY() - this.height / 2);
|
||||
Mouse.setCursorPosition(this.width / 2, this.height / 2);
|
||||
}
|
||||
this.player.turn(xo, yo * this.yMouseAxis);
|
||||
}
|
||||
this.checkGlError("Set viewport");
|
||||
this.pick(a);
|
||||
this.checkGlError("Picked");
|
||||
GL11.glClear(16640);
|
||||
this.setupCamera(a);
|
||||
this.checkGlError("Set up camera");
|
||||
GL11.glEnable(2884);
|
||||
final Frustum frustum = Frustum.getFrustum();
|
||||
this.levelRenderer.cull(frustum);
|
||||
this.levelRenderer.updateDirtyChunks(this.player);
|
||||
this.checkGlError("Update chunks");
|
||||
this.setupFog(0);
|
||||
GL11.glEnable(2912);
|
||||
this.levelRenderer.render(this.player, 0);
|
||||
this.checkGlError("Rendered level");
|
||||
for (int i = 0; i < this.entities.size(); ++i) {
|
||||
final Entity entity = this.entities.get(i);
|
||||
if (entity.isLit() && frustum.isVisible(entity.bb)) {
|
||||
this.entities.get(i).render(a);
|
||||
}
|
||||
}
|
||||
this.checkGlError("Rendered entities");
|
||||
this.particleEngine.render(this.player, a, 0);
|
||||
this.checkGlError("Rendered particles");
|
||||
this.setupFog(1);
|
||||
this.levelRenderer.render(this.player, 1);
|
||||
for (int i = 0; i < this.entities.size(); ++i) {
|
||||
final Entity zombie = this.entities.get(i);
|
||||
if (!zombie.isLit() && frustum.isVisible(zombie.bb)) {
|
||||
this.entities.get(i).render(a);
|
||||
}
|
||||
}
|
||||
this.particleEngine.render(this.player, a, 1);
|
||||
this.levelRenderer.renderSurroundingGround();
|
||||
if (this.hitResult != null) {
|
||||
GL11.glDisable(2896);
|
||||
GL11.glDisable(3008);
|
||||
this.levelRenderer.renderHit(this.player, this.hitResult, this.editMode, this.paintTexture);
|
||||
this.levelRenderer.renderHitOutline(this.player, this.hitResult, this.editMode, this.paintTexture);
|
||||
GL11.glEnable(3008);
|
||||
GL11.glEnable(2896);
|
||||
}
|
||||
GL11.glBlendFunc(770, 771);
|
||||
this.setupFog(0);
|
||||
this.levelRenderer.renderSurroundingWater();
|
||||
GL11.glEnable(3042);
|
||||
GL11.glColorMask(false, false, false, false);
|
||||
this.levelRenderer.render(this.player, 2);
|
||||
GL11.glColorMask(true, true, true, true);
|
||||
this.levelRenderer.render(this.player, 2);
|
||||
GL11.glDisable(3042);
|
||||
GL11.glDisable(2896);
|
||||
GL11.glDisable(3553);
|
||||
GL11.glDisable(2912);
|
||||
if (this.hitResult != null) {
|
||||
GL11.glDepthFunc(513);
|
||||
GL11.glDisable(3008);
|
||||
this.levelRenderer.renderHit(this.player, this.hitResult, this.editMode, this.paintTexture);
|
||||
this.levelRenderer.renderHitOutline(this.player, this.hitResult, this.editMode, this.paintTexture);
|
||||
GL11.glEnable(3008);
|
||||
GL11.glDepthFunc(515);
|
||||
}
|
||||
this.drawGui(a);
|
||||
this.checkGlError("Rendered gui");
|
||||
Display.update();
|
||||
}
|
||||
|
||||
private void drawGui(final float a) {
|
||||
final int screenWidth = this.width * 240 / this.height;
|
||||
final int screenHeight = this.height * 240 / this.height;
|
||||
final int xMouse = Mouse.getX() * screenWidth / this.width;
|
||||
final int yMouse = screenHeight - Mouse.getY() * screenHeight / this.height - 1;
|
||||
GL11.glClear(256);
|
||||
GL11.glMatrixMode(5889);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glOrtho(0.0, (double)screenWidth, (double)screenHeight, 0.0, 100.0, 300.0);
|
||||
GL11.glMatrixMode(5888);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
|
||||
this.checkGlError("GUI: Init");
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)(screenWidth - 16), 16.0f, -50.0f);
|
||||
final Tesselator t = Tesselator.instance;
|
||||
GL11.glScalef(16.0f, 16.0f, 16.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);
|
||||
final int id = this.textures.loadTexture("/terrain.png", 9728);
|
||||
GL11.glBindTexture(3553, id);
|
||||
GL11.glEnable(3553);
|
||||
t.begin();
|
||||
Tile.tiles[this.paintTexture].render(t, this.level, 0, -2, 0, 0);
|
||||
t.end();
|
||||
GL11.glDisable(3553);
|
||||
GL11.glPopMatrix();
|
||||
this.checkGlError("GUI: Draw selected");
|
||||
this.font.drawShadow("Minecraft grpf.0.0.13a", 2, 2, 16777215);
|
||||
this.font.drawShadow(this.fpsString, 2, 12, 16777215);
|
||||
this.checkGlError("GUI: Draw text");
|
||||
final int wc = screenWidth / 2;
|
||||
final int hc = screenHeight / 2;
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
t.begin();
|
||||
t.vertex((float)(wc + 1), (float)(hc - 4), 0.0f);
|
||||
t.vertex((float)(wc - 0), (float)(hc - 4), 0.0f);
|
||||
t.vertex((float)(wc - 0), (float)(hc + 5), 0.0f);
|
||||
t.vertex((float)(wc + 1), (float)(hc + 5), 0.0f);
|
||||
t.vertex((float)(wc + 5), (float)(hc - 0), 0.0f);
|
||||
t.vertex((float)(wc - 4), (float)(hc - 0), 0.0f);
|
||||
t.vertex((float)(wc - 4), (float)(hc + 1), 0.0f);
|
||||
t.vertex((float)(wc + 5), (float)(hc + 1), 0.0f);
|
||||
t.end();
|
||||
this.checkGlError("GUI: Draw crosshair");
|
||||
if (this.screen != null) {
|
||||
this.screen.render(xMouse, yMouse);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupFog(final int i) {
|
||||
final Tile currentTile = Tile.tiles[this.level.getTile((int)this.player.x, (int)(this.player.y + 0.12f), (int)this.player.z)];
|
||||
if (currentTile != null && currentTile.getLiquidType() == 1) {
|
||||
GL11.glFogi(2917, 2048);
|
||||
GL11.glFogf(2914, 0.1f);
|
||||
GL11.glFog(2918, this.getBuffer(0.02f, 0.02f, 0.2f, 1.0f));
|
||||
GL11.glLightModel(2899, this.getBuffer(0.3f, 0.3f, 0.7f, 1.0f));
|
||||
}
|
||||
else if (currentTile != null && currentTile.getLiquidType() == 2) {
|
||||
GL11.glFogi(2917, 2048);
|
||||
GL11.glFogf(2914, 2.0f);
|
||||
GL11.glFog(2918, this.getBuffer(0.6f, 0.1f, 0.0f, 1.0f));
|
||||
GL11.glLightModel(2899, this.getBuffer(0.4f, 0.3f, 0.3f, 1.0f));
|
||||
}
|
||||
else if (i == 0) {
|
||||
GL11.glFogi(2917, 2048);
|
||||
GL11.glFogf(2914, 0.001f);
|
||||
GL11.glFog(2918, this.fogColor0);
|
||||
GL11.glLightModel(2899, this.getBuffer(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
}
|
||||
else if (i == 1) {
|
||||
GL11.glFogi(2917, 2048);
|
||||
GL11.glFogf(2914, 0.01f);
|
||||
GL11.glFog(2918, this.fogColor1);
|
||||
final float br = 0.6f;
|
||||
GL11.glLightModel(2899, this.getBuffer(br, br, br, 1.0f));
|
||||
}
|
||||
GL11.glEnable(2903);
|
||||
GL11.glColorMaterial(1028, 4608);
|
||||
GL11.glEnable(2896);
|
||||
}
|
||||
|
||||
private FloatBuffer getBuffer(final float a, final float b, final float c, final float d) {
|
||||
this.lb.clear();
|
||||
this.lb.put(a).put(b).put(c).put(d);
|
||||
this.lb.flip();
|
||||
return this.lb;
|
||||
}
|
||||
|
||||
public static void checkError() {
|
||||
final int e = GL11.glGetError();
|
||||
if (e != 0) {
|
||||
throw new IllegalStateException(GLU.gluErrorString(e));
|
||||
}
|
||||
}
|
||||
|
||||
public void beginLevelLoading(final String title) {
|
||||
this.title = title;
|
||||
final int screenWidth = this.width * 240 / this.height;
|
||||
final int screenHeight = this.height * 240 / this.height;
|
||||
GL11.glClear(256);
|
||||
GL11.glMatrixMode(5889);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glOrtho(0.0, (double)screenWidth, (double)screenHeight, 0.0, 100.0, 300.0);
|
||||
GL11.glMatrixMode(5888);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
|
||||
}
|
||||
|
||||
public void levelLoadUpdate(final String status) {
|
||||
final int screenWidth = this.width * 240 / this.height;
|
||||
final int screenHeight = this.height * 240 / this.height;
|
||||
GL11.glClear(16640);
|
||||
final Tesselator t = Tesselator.instance;
|
||||
GL11.glEnable(3553);
|
||||
final int id = this.textures.loadTexture("/dirt.png", 9728);
|
||||
GL11.glBindTexture(3553, id);
|
||||
t.begin();
|
||||
t.color(8421504);
|
||||
final float s = 32.0f;
|
||||
t.vertexUV(0.0f, (float)screenHeight, 0.0f, 0.0f, screenHeight / s);
|
||||
t.vertexUV((float)screenWidth, (float)screenHeight, 0.0f, screenWidth / s, screenHeight / s);
|
||||
t.vertexUV((float)screenWidth, 0.0f, 0.0f, screenWidth / s, 0.0f);
|
||||
t.vertexUV(0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
t.end();
|
||||
GL11.glEnable(3553);
|
||||
this.font.drawShadow(this.title, (screenWidth - this.font.width(this.title)) / 2, screenHeight / 2 - 4 - 8, 16777215);
|
||||
this.font.drawShadow(status, (screenWidth - this.font.width(status)) / 2, screenHeight / 2 - 4 + 4, 16777215);
|
||||
Display.update();
|
||||
try {
|
||||
Thread.sleep(200L);
|
||||
}
|
||||
catch (Exception ex) {}
|
||||
}
|
||||
|
||||
public void generateNewLevel() {
|
||||
this.levelGen.generateLevel(this.level, this.user.name, 32, 512, 64);
|
||||
this.player.resetPos();
|
||||
for (int i = 0; i < this.entities.size(); ++i) {
|
||||
this.entities.remove(i--);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(final String[] args) throws LWJGLException {
|
||||
boolean fullScreen = false;
|
||||
for (int i = 0; i < args.length; ++i) {
|
||||
if (args[i].equalsIgnoreCase("-fullscreen")) {
|
||||
fullScreen = true;
|
||||
}
|
||||
}
|
||||
final Minecraft minecraft = new Minecraft(null, 854, 480, fullScreen);
|
||||
new Thread(minecraft).start();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,406 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft;
|
||||
|
||||
import com.mojang.minecraft.level.Tesselator;
|
||||
import com.mojang.minecraft.level.tile.Tile;
|
||||
import com.mojang.minecraft.level.Frustum;
|
||||
import org.lwjgl.util.glu.GLU;
|
||||
import com.mojang.minecraft.level.Chunk;
|
||||
import java.awt.Component;
|
||||
import javax.swing.JOptionPane;
|
||||
import java.io.IOException;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.DisplayMode;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import java.nio.IntBuffer;
|
||||
import com.mojang.minecraft.character.Zombie;
|
||||
import java.util.ArrayList;
|
||||
import com.mojang.minecraft.particle.ParticleEngine;
|
||||
import com.mojang.minecraft.level.LevelRenderer;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
public class RubyDung implements Runnable
|
||||
{
|
||||
private static final boolean FULLSCREEN_MODE = false;
|
||||
private int width;
|
||||
private int height;
|
||||
private FloatBuffer fogColor0;
|
||||
private FloatBuffer fogColor1;
|
||||
private Timer timer;
|
||||
private Level level;
|
||||
private LevelRenderer levelRenderer;
|
||||
private Player player;
|
||||
private int paintTexture;
|
||||
private ParticleEngine particleEngine;
|
||||
private ArrayList<Zombie> zombies;
|
||||
private IntBuffer viewportBuffer;
|
||||
private IntBuffer selectBuffer;
|
||||
private HitResult hitResult;
|
||||
FloatBuffer lb;
|
||||
|
||||
public RubyDung() {
|
||||
this.fogColor0 = BufferUtils.createFloatBuffer(4);
|
||||
this.fogColor1 = BufferUtils.createFloatBuffer(4);
|
||||
this.timer = new Timer(20.0f);
|
||||
this.paintTexture = 1;
|
||||
this.zombies = new ArrayList<Zombie>();
|
||||
this.viewportBuffer = BufferUtils.createIntBuffer(16);
|
||||
this.selectBuffer = BufferUtils.createIntBuffer(2000);
|
||||
this.hitResult = null;
|
||||
this.lb = BufferUtils.createFloatBuffer(16);
|
||||
}
|
||||
|
||||
public void init() throws LWJGLException, IOException {
|
||||
final int col0 = 16710650;
|
||||
final int col2 = 920330;
|
||||
final float fr = 0.5f;
|
||||
final float fg = 0.8f;
|
||||
final float fb = 1.0f;
|
||||
this.fogColor0.put(new float[] { (col0 >> 16 & 0xFF) / 255.0f, (col0 >> 8 & 0xFF) / 255.0f, (col0 & 0xFF) / 255.0f, 1.0f });
|
||||
this.fogColor0.flip();
|
||||
this.fogColor1.put(new float[] { (col2 >> 16 & 0xFF) / 255.0f, (col2 >> 8 & 0xFF) / 255.0f, (col2 & 0xFF) / 255.0f, 1.0f });
|
||||
this.fogColor1.flip();
|
||||
Display.setDisplayMode(new DisplayMode(1024, 768));
|
||||
Display.create();
|
||||
Keyboard.create();
|
||||
Mouse.create();
|
||||
this.width = Display.getDisplayMode().getWidth();
|
||||
this.height = Display.getDisplayMode().getHeight();
|
||||
GL11.glEnable(3553);
|
||||
GL11.glShadeModel(7425);
|
||||
GL11.glClearColor(fr, fg, fb, 0.0f);
|
||||
GL11.glClearDepth(1.0);
|
||||
GL11.glEnable(2929);
|
||||
GL11.glDepthFunc(515);
|
||||
GL11.glEnable(3008);
|
||||
GL11.glAlphaFunc(516, 0.5f);
|
||||
GL11.glMatrixMode(5889);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glMatrixMode(5888);
|
||||
this.level = new Level(256, 256, 64);
|
||||
this.levelRenderer = new LevelRenderer(this.level);
|
||||
this.player = new Player(this.level);
|
||||
this.particleEngine = new ParticleEngine(this.level);
|
||||
Mouse.setGrabbed(true);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
final Zombie zombie = new Zombie(this.level, 128.0f, 0.0f, 128.0f);
|
||||
zombie.resetPos();
|
||||
this.zombies.add(zombie);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
this.level.save();
|
||||
Mouse.destroy();
|
||||
Keyboard.destroy();
|
||||
Display.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
this.init();
|
||||
}
|
||||
catch (Exception e) {
|
||||
JOptionPane.showMessageDialog(null, e.toString(), "Failed to start RubyDung", 0);
|
||||
System.exit(0);
|
||||
}
|
||||
long lastTime = System.currentTimeMillis();
|
||||
int frames = 0;
|
||||
try {
|
||||
while (!Keyboard.isKeyDown(1)) {
|
||||
if (Display.isCloseRequested()) {
|
||||
break;
|
||||
}
|
||||
this.timer.advanceTime();
|
||||
for (int i = 0; i < this.timer.ticks; ++i) {
|
||||
this.tick();
|
||||
}
|
||||
this.render(this.timer.a);
|
||||
++frames;
|
||||
while (System.currentTimeMillis() >= lastTime + 1000L) {
|
||||
System.out.println(String.valueOf(frames) + " fps, " + Chunk.updates);
|
||||
Chunk.updates = 0;
|
||||
lastTime += 1000L;
|
||||
frames = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
return;
|
||||
}
|
||||
finally {
|
||||
this.destroy();
|
||||
}
|
||||
this.destroy();
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
while (Keyboard.next()) {
|
||||
if (Keyboard.getEventKeyState()) {
|
||||
if (Keyboard.getEventKey() == 28) {
|
||||
this.level.save();
|
||||
}
|
||||
if (Keyboard.getEventKey() == 2) {
|
||||
this.paintTexture = 1;
|
||||
}
|
||||
if (Keyboard.getEventKey() == 3) {
|
||||
this.paintTexture = 3;
|
||||
}
|
||||
if (Keyboard.getEventKey() == 4) {
|
||||
this.paintTexture = 4;
|
||||
}
|
||||
if (Keyboard.getEventKey() == 5) {
|
||||
this.paintTexture = 5;
|
||||
}
|
||||
if (Keyboard.getEventKey() == 7) {
|
||||
this.paintTexture = 6;
|
||||
}
|
||||
if (Keyboard.getEventKey() != 34) {
|
||||
continue;
|
||||
}
|
||||
this.zombies.add(new Zombie(this.level, this.player.x, this.player.y, this.player.z));
|
||||
}
|
||||
}
|
||||
this.level.tick();
|
||||
this.particleEngine.tick();
|
||||
for (int i = 0; i < this.zombies.size(); ++i) {
|
||||
this.zombies.get(i).tick();
|
||||
if (this.zombies.get(i).removed) {
|
||||
this.zombies.remove(i--);
|
||||
}
|
||||
}
|
||||
this.player.tick();
|
||||
}
|
||||
|
||||
private void moveCameraToPlayer(final float a) {
|
||||
GL11.glTranslatef(0.0f, 0.0f, -0.3f);
|
||||
GL11.glRotatef(this.player.xRot, 1.0f, 0.0f, 0.0f);
|
||||
GL11.glRotatef(this.player.yRot, 0.0f, 1.0f, 0.0f);
|
||||
final float x = this.player.xo + (this.player.x - this.player.xo) * a;
|
||||
final float y = this.player.yo + (this.player.y - this.player.yo) * a;
|
||||
final float z = this.player.zo + (this.player.z - this.player.zo) * a;
|
||||
GL11.glTranslatef(-x, -y, -z);
|
||||
}
|
||||
|
||||
private void setupCamera(final float a) {
|
||||
GL11.glMatrixMode(5889);
|
||||
GL11.glLoadIdentity();
|
||||
GLU.gluPerspective(70.0f, this.width / (float)this.height, 0.05f, 1000.0f);
|
||||
GL11.glMatrixMode(5888);
|
||||
GL11.glLoadIdentity();
|
||||
this.moveCameraToPlayer(a);
|
||||
}
|
||||
|
||||
private void setupPickCamera(final float a, final int x, final int y) {
|
||||
GL11.glMatrixMode(5889);
|
||||
GL11.glLoadIdentity();
|
||||
this.viewportBuffer.clear();
|
||||
GL11.glGetInteger(2978, this.viewportBuffer);
|
||||
this.viewportBuffer.flip();
|
||||
this.viewportBuffer.limit(16);
|
||||
GLU.gluPickMatrix((float)x, (float)y, 5.0f, 5.0f, this.viewportBuffer);
|
||||
GLU.gluPerspective(70.0f, this.width / (float)this.height, 0.05f, 1000.0f);
|
||||
GL11.glMatrixMode(5888);
|
||||
GL11.glLoadIdentity();
|
||||
this.moveCameraToPlayer(a);
|
||||
}
|
||||
|
||||
private void pick(final float a) {
|
||||
this.selectBuffer.clear();
|
||||
GL11.glSelectBuffer(this.selectBuffer);
|
||||
GL11.glRenderMode(7170);
|
||||
this.setupPickCamera(a, this.width / 2, this.height / 2);
|
||||
this.levelRenderer.pick(this.player, Frustum.getFrustum());
|
||||
final int hits = GL11.glRenderMode(7168);
|
||||
this.selectBuffer.flip();
|
||||
this.selectBuffer.limit(this.selectBuffer.capacity());
|
||||
long closest = 0L;
|
||||
final int[] names = new int[10];
|
||||
int hitNameCount = 0;
|
||||
for (int i = 0; i < hits; ++i) {
|
||||
final int nameCount = this.selectBuffer.get();
|
||||
final long minZ = this.selectBuffer.get();
|
||||
this.selectBuffer.get();
|
||||
final long dist = minZ;
|
||||
if (dist < closest || i == 0) {
|
||||
closest = dist;
|
||||
hitNameCount = nameCount;
|
||||
for (int j = 0; j < nameCount; ++j) {
|
||||
names[j] = this.selectBuffer.get();
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int j = 0; j < nameCount; ++j) {
|
||||
this.selectBuffer.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hitNameCount > 0) {
|
||||
this.hitResult = new HitResult(names[0], names[1], names[2], names[3], names[4]);
|
||||
}
|
||||
else {
|
||||
this.hitResult = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void render(final float a) {
|
||||
final float xo = (float)Mouse.getDX();
|
||||
final float yo = (float)Mouse.getDY();
|
||||
this.player.turn(xo, yo);
|
||||
this.pick(a);
|
||||
while (Mouse.next()) {
|
||||
if (Mouse.getEventButton() == 1 && Mouse.getEventButtonState() && this.hitResult != null) {
|
||||
final Tile oldTile = Tile.tiles[this.level.getTile(this.hitResult.x, this.hitResult.y, this.hitResult.z)];
|
||||
final boolean changed = this.level.setTile(this.hitResult.x, this.hitResult.y, this.hitResult.z, 0);
|
||||
if (oldTile != null && changed) {
|
||||
oldTile.destroy(this.level, this.hitResult.x, this.hitResult.y, this.hitResult.z, this.particleEngine);
|
||||
}
|
||||
}
|
||||
if (Mouse.getEventButton() == 0 && Mouse.getEventButtonState() && this.hitResult != null) {
|
||||
int x = this.hitResult.x;
|
||||
int y = this.hitResult.y;
|
||||
int z = this.hitResult.z;
|
||||
if (this.hitResult.f == 0) {
|
||||
--y;
|
||||
}
|
||||
if (this.hitResult.f == 1) {
|
||||
++y;
|
||||
}
|
||||
if (this.hitResult.f == 2) {
|
||||
--z;
|
||||
}
|
||||
if (this.hitResult.f == 3) {
|
||||
++z;
|
||||
}
|
||||
if (this.hitResult.f == 4) {
|
||||
--x;
|
||||
}
|
||||
if (this.hitResult.f == 5) {
|
||||
++x;
|
||||
}
|
||||
this.level.setTile(x, y, z, this.paintTexture);
|
||||
}
|
||||
}
|
||||
GL11.glClear(16640);
|
||||
this.setupCamera(a);
|
||||
GL11.glEnable(2884);
|
||||
final Frustum frustum = Frustum.getFrustum();
|
||||
this.levelRenderer.updateDirtyChunks(this.player);
|
||||
this.setupFog(0);
|
||||
GL11.glEnable(2912);
|
||||
this.levelRenderer.render(this.player, 0);
|
||||
for (int i = 0; i < this.zombies.size(); ++i) {
|
||||
final Zombie zombie = this.zombies.get(i);
|
||||
if (zombie.isLit() && frustum.isVisible(zombie.bb)) {
|
||||
this.zombies.get(i).render(a);
|
||||
}
|
||||
}
|
||||
this.particleEngine.render(this.player, a, 0);
|
||||
this.setupFog(1);
|
||||
this.levelRenderer.render(this.player, 1);
|
||||
for (int i = 0; i < this.zombies.size(); ++i) {
|
||||
final Zombie zombie = this.zombies.get(i);
|
||||
if (!zombie.isLit() && frustum.isVisible(zombie.bb)) {
|
||||
this.zombies.get(i).render(a);
|
||||
}
|
||||
}
|
||||
this.particleEngine.render(this.player, a, 1);
|
||||
GL11.glDisable(2896);
|
||||
GL11.glDisable(3553);
|
||||
GL11.glDisable(2912);
|
||||
if (this.hitResult != null) {
|
||||
GL11.glDisable(3008);
|
||||
this.levelRenderer.renderHit(this.hitResult);
|
||||
GL11.glEnable(3008);
|
||||
}
|
||||
this.drawGui(a);
|
||||
Display.update();
|
||||
}
|
||||
|
||||
private void drawGui(final float a) {
|
||||
final int screenWidth = this.width * 240 / this.height;
|
||||
final int screenHeight = this.height * 240 / this.height;
|
||||
GL11.glClear(256);
|
||||
GL11.glMatrixMode(5889);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glOrtho(0.0, (double)screenWidth, (double)screenHeight, 0.0, 100.0, 300.0);
|
||||
GL11.glMatrixMode(5888);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)(screenWidth - 16), 16.0f, 0.0f);
|
||||
final Tesselator t = Tesselator.instance;
|
||||
GL11.glScalef(16.0f, 16.0f, 16.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);
|
||||
final int id = Textures.loadTexture("/terrain.png", 9728);
|
||||
GL11.glBindTexture(3553, id);
|
||||
GL11.glEnable(3553);
|
||||
t.init();
|
||||
Tile.tiles[this.paintTexture].render(t, this.level, 0, -2, 0, 0);
|
||||
t.flush();
|
||||
GL11.glDisable(3553);
|
||||
GL11.glPopMatrix();
|
||||
final int wc = screenWidth / 2;
|
||||
final int hc = screenHeight / 2;
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
t.init();
|
||||
t.vertex((float)(wc + 1), (float)(hc - 4), 0.0f);
|
||||
t.vertex((float)(wc - 0), (float)(hc - 4), 0.0f);
|
||||
t.vertex((float)(wc - 0), (float)(hc + 5), 0.0f);
|
||||
t.vertex((float)(wc + 1), (float)(hc + 5), 0.0f);
|
||||
t.vertex((float)(wc + 5), (float)(hc - 0), 0.0f);
|
||||
t.vertex((float)(wc - 4), (float)(hc - 0), 0.0f);
|
||||
t.vertex((float)(wc - 4), (float)(hc + 1), 0.0f);
|
||||
t.vertex((float)(wc + 5), (float)(hc + 1), 0.0f);
|
||||
t.flush();
|
||||
}
|
||||
|
||||
private void setupFog(final int i) {
|
||||
if (i == 0) {
|
||||
GL11.glFogi(2917, 2048);
|
||||
GL11.glFogf(2914, 0.001f);
|
||||
GL11.glFog(2918, this.fogColor0);
|
||||
GL11.glDisable(2896);
|
||||
}
|
||||
else if (i == 1) {
|
||||
GL11.glFogi(2917, 2048);
|
||||
GL11.glFogf(2914, 0.06f);
|
||||
GL11.glFog(2918, this.fogColor1);
|
||||
GL11.glEnable(2896);
|
||||
GL11.glEnable(2903);
|
||||
final float br = 0.6f;
|
||||
GL11.glLightModel(2899, this.getBuffer(br, br, br, 1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
private FloatBuffer getBuffer(final float a, final float b, final float c, final float d) {
|
||||
this.lb.clear();
|
||||
this.lb.put(a).put(b).put(c).put(d);
|
||||
this.lb.flip();
|
||||
return this.lb;
|
||||
}
|
||||
|
||||
public static void checkError() {
|
||||
final int e = GL11.glGetError();
|
||||
if (e != 0) {
|
||||
throw new IllegalStateException(GLU.gluErrorString(e));
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(final String[] args) throws LWJGLException {
|
||||
new Thread(new RubyDung()).start();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.LayoutManager;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Canvas;
|
||||
import java.applet.Applet;
|
||||
|
||||
public class MinecraftApplet extends Applet
|
||||
{
|
||||
private Canvas canvas;
|
||||
private Minecraft minecraft;
|
||||
private Thread thread;
|
||||
|
||||
public MinecraftApplet() {
|
||||
this.thread = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
this.canvas = new Canvas() {
|
||||
@Override
|
||||
public void addNotify() {
|
||||
super.addNotify();
|
||||
MinecraftApplet.this.startGameThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNotify() {
|
||||
MinecraftApplet.this.stopGameThread();
|
||||
super.removeNotify();
|
||||
}
|
||||
};
|
||||
this.minecraft = new Minecraft(this.canvas, this.getWidth(), this.getHeight(), false);
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
(this.thread = new Thread(this.minecraft)).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
this.minecraft.pause = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
this.minecraft.pause = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
this.stopGameThread();
|
||||
}
|
||||
|
||||
public void stopGameThread() {
|
||||
if (this.thread == null) {
|
||||
return;
|
||||
}
|
||||
this.minecraft.stop();
|
||||
try {
|
||||
this.thread.join(5000L);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
try {
|
||||
this.minecraft.destroy();
|
||||
}
|
||||
catch (Exception ee) {
|
||||
ee.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.thread = null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft;
|
||||
|
||||
import com.mojang.minecraft.level.Level;
|
||||
|
||||
public class Player extends Entity
|
||||
{
|
||||
public static final int KEY_UP = 0;
|
||||
public static final int KEY_DOWN = 1;
|
||||
public static final int KEY_LEFT = 2;
|
||||
public static final int KEY_RIGHT = 3;
|
||||
public static final int KEY_JUMP = 4;
|
||||
private boolean[] keys;
|
||||
|
||||
public Player(final Level level) {
|
||||
super(level);
|
||||
this.keys = new boolean[10];
|
||||
this.heightOffset = 1.62f;
|
||||
}
|
||||
|
||||
public void setKey(final int key, final boolean state) {
|
||||
int id = -1;
|
||||
if (key == 200 || key == 17) {
|
||||
id = 0;
|
||||
}
|
||||
if (key == 208 || key == 31) {
|
||||
id = 1;
|
||||
}
|
||||
if (key == 203 || key == 30) {
|
||||
id = 2;
|
||||
}
|
||||
if (key == 205 || key == 32) {
|
||||
id = 3;
|
||||
}
|
||||
if (key == 57 || key == 219) {
|
||||
id = 4;
|
||||
}
|
||||
if (id >= 0) {
|
||||
this.keys[id] = state;
|
||||
}
|
||||
}
|
||||
|
||||
public void releaseAllKeys() {
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
this.keys[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
this.xo = this.x;
|
||||
this.yo = this.y;
|
||||
this.zo = this.z;
|
||||
float xa = 0.0f;
|
||||
float ya = 0.0f;
|
||||
final boolean inWater = this.isInWater();
|
||||
final boolean inLava = this.isInLava();
|
||||
if (this.keys[0]) {
|
||||
--ya;
|
||||
}
|
||||
if (this.keys[1]) {
|
||||
++ya;
|
||||
}
|
||||
if (this.keys[2]) {
|
||||
--xa;
|
||||
}
|
||||
if (this.keys[3]) {
|
||||
++xa;
|
||||
}
|
||||
if (this.keys[4]) {
|
||||
if (inWater) {
|
||||
this.yd += 0.04f;
|
||||
}
|
||||
else if (inLava) {
|
||||
this.yd += 0.04f;
|
||||
}
|
||||
else if (this.onGround) {
|
||||
this.yd = 0.42f;
|
||||
this.keys[4] = false;
|
||||
}
|
||||
}
|
||||
if (inWater) {
|
||||
final float yo = this.y;
|
||||
this.moveRelative(xa, ya, 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)0.02;
|
||||
if (this.horizontalCollision && this.isFree(this.xd, this.yd + 0.6f - this.y + yo, this.zd)) {
|
||||
this.yd = 0.3f;
|
||||
}
|
||||
}
|
||||
else if (inLava) {
|
||||
final float yo = this.y;
|
||||
this.moveRelative(xa, ya, 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)0.02;
|
||||
if (this.horizontalCollision && this.isFree(this.xd, this.yd + 0.6f - this.y + yo, this.zd)) {
|
||||
this.yd = 0.3f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.moveRelative(xa, ya, 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)0.08;
|
||||
if (this.onGround) {
|
||||
this.xd *= 0.6f;
|
||||
this.zd *= 0.6f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.nio.IntBuffer;
|
||||
import java.io.IOException;
|
||||
import org.lwjgl.util.glu.GLU;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Textures
|
||||
{
|
||||
private static HashMap<String, Integer> idMap;
|
||||
|
||||
static {
|
||||
Textures.idMap = new HashMap<String, Integer>();
|
||||
}
|
||||
|
||||
public static int loadTexture(final String resourceName, final int mode) {
|
||||
try {
|
||||
if (Textures.idMap.containsKey(resourceName)) {
|
||||
return Textures.idMap.get(resourceName);
|
||||
}
|
||||
final IntBuffer ib = BufferUtils.createIntBuffer(1);
|
||||
ib.clear();
|
||||
GL11.glGenTextures(ib);
|
||||
final int id = ib.get(0);
|
||||
Textures.idMap.put(resourceName, id);
|
||||
System.out.println(String.valueOf(resourceName) + " -> " + id);
|
||||
GL11.glBindTexture(3553, id);
|
||||
GL11.glTexParameteri(3553, 10241, mode);
|
||||
GL11.glTexParameteri(3553, 10240, mode);
|
||||
final BufferedImage img = ImageIO.read(Textures.class.getResourceAsStream(resourceName));
|
||||
final int w = img.getWidth();
|
||||
final int h = img.getHeight();
|
||||
final ByteBuffer pixels = BufferUtils.createByteBuffer(w * h * 4);
|
||||
final int[] rawPixels = new int[w * h];
|
||||
img.getRGB(0, 0, w, h, rawPixels, 0, w);
|
||||
for (int i = 0; i < rawPixels.length; ++i) {
|
||||
final int a = rawPixels[i] >> 24 & 0xFF;
|
||||
final int r = rawPixels[i] >> 16 & 0xFF;
|
||||
final int g = rawPixels[i] >> 8 & 0xFF;
|
||||
final int b = rawPixels[i] & 0xFF;
|
||||
rawPixels[i] = (a << 24 | b << 16 | g << 8 | r);
|
||||
}
|
||||
pixels.asIntBuffer().put(rawPixels);
|
||||
GLU.gluBuild2DMipmaps(3553, 6408, w, h, 6408, 5121, pixels);
|
||||
return id;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException("!!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft;
|
||||
|
||||
public class Timer
|
||||
{
|
||||
private static final long NS_PER_SECOND = 1000000000L;
|
||||
private static final long MAX_NS_PER_UPDATE = 1000000000L;
|
||||
private static final int MAX_TICKS_PER_UPDATE = 100;
|
||||
private float ticksPerSecond;
|
||||
private long lastTime;
|
||||
public int ticks;
|
||||
public float a;
|
||||
public float timeScale;
|
||||
public float fps;
|
||||
public float passedTime;
|
||||
|
||||
public Timer(final float ticksPerSecond) {
|
||||
this.timeScale = 1.0f;
|
||||
this.fps = 0.0f;
|
||||
this.passedTime = 0.0f;
|
||||
this.ticksPerSecond = ticksPerSecond;
|
||||
this.lastTime = System.nanoTime();
|
||||
}
|
||||
|
||||
public void advanceTime() {
|
||||
final long now = System.nanoTime();
|
||||
long passedNs = now - this.lastTime;
|
||||
this.lastTime = now;
|
||||
if (passedNs < 0L) {
|
||||
passedNs = 0L;
|
||||
}
|
||||
if (passedNs > 1000000000L) {
|
||||
passedNs = 1000000000L;
|
||||
}
|
||||
this.fps = (float)(1000000000L / passedNs);
|
||||
this.passedTime += passedNs * this.timeScale * this.ticksPerSecond / 1.0E9f;
|
||||
this.ticks = (int)this.passedTime;
|
||||
if (this.ticks > 100) {
|
||||
this.ticks = 100;
|
||||
}
|
||||
this.passedTime -= this.ticks;
|
||||
this.a = this.passedTime;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft;
|
||||
|
||||
public class User
|
||||
{
|
||||
public String name;
|
||||
|
||||
public User(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.character;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class Cube
|
||||
{
|
||||
private Vertex[] vertices;
|
||||
private Polygon[] polygons;
|
||||
private int xTexOffs;
|
||||
private int yTexOffs;
|
||||
public float x;
|
||||
public float y;
|
||||
public float z;
|
||||
public float xRot;
|
||||
public float yRot;
|
||||
public float zRot;
|
||||
private boolean compiled;
|
||||
private int list;
|
||||
|
||||
public Cube(final int xTexOffs, final int yTexOffs) {
|
||||
this.compiled = false;
|
||||
this.list = 0;
|
||||
this.xTexOffs = xTexOffs;
|
||||
this.yTexOffs = yTexOffs;
|
||||
}
|
||||
|
||||
public void setTexOffs(final int xTexOffs, final int yTexOffs) {
|
||||
this.xTexOffs = xTexOffs;
|
||||
this.yTexOffs = yTexOffs;
|
||||
}
|
||||
|
||||
public void addBox(final float x0, final float y0, final float z0, final int w, final int h, final int d) {
|
||||
this.vertices = new Vertex[8];
|
||||
this.polygons = new Polygon[6];
|
||||
final float x = x0 + w;
|
||||
final float y = y0 + h;
|
||||
final float z = z0 + d;
|
||||
final Vertex u0 = new Vertex(x0, y0, z0, 0.0f, 0.0f);
|
||||
final Vertex u2 = new Vertex(x, y0, z0, 0.0f, 8.0f);
|
||||
final Vertex u3 = new Vertex(x, y, z0, 8.0f, 8.0f);
|
||||
final Vertex u4 = new Vertex(x0, y, z0, 8.0f, 0.0f);
|
||||
final Vertex l0 = new Vertex(x0, y0, z, 0.0f, 0.0f);
|
||||
final Vertex l2 = new Vertex(x, y0, z, 0.0f, 8.0f);
|
||||
final Vertex l3 = new Vertex(x, y, z, 8.0f, 8.0f);
|
||||
final Vertex l4 = new Vertex(x0, y, z, 8.0f, 0.0f);
|
||||
this.vertices[0] = u0;
|
||||
this.vertices[1] = u2;
|
||||
this.vertices[2] = u3;
|
||||
this.vertices[3] = u4;
|
||||
this.vertices[4] = l0;
|
||||
this.vertices[5] = l2;
|
||||
this.vertices[6] = l3;
|
||||
this.vertices[7] = l4;
|
||||
this.polygons[0] = new Polygon(new Vertex[] { l2, u2, u3, l3 }, this.xTexOffs + d + w, this.yTexOffs + d, this.xTexOffs + d + w + d, this.yTexOffs + d + h);
|
||||
this.polygons[1] = new Polygon(new Vertex[] { u0, l0, l4, u4 }, this.xTexOffs + 0, this.yTexOffs + d, this.xTexOffs + d, this.yTexOffs + d + h);
|
||||
this.polygons[2] = new Polygon(new Vertex[] { l2, l0, u0, u2 }, this.xTexOffs + d, this.yTexOffs + 0, this.xTexOffs + d + w, this.yTexOffs + d);
|
||||
this.polygons[3] = new Polygon(new Vertex[] { u3, u4, l4, l3 }, this.xTexOffs + d + w, this.yTexOffs + 0, this.xTexOffs + d + w + w, this.yTexOffs + d);
|
||||
this.polygons[4] = new Polygon(new Vertex[] { u2, u0, u4, u3 }, this.xTexOffs + d, this.yTexOffs + d, this.xTexOffs + d + w, this.yTexOffs + d + h);
|
||||
this.polygons[5] = new Polygon(new Vertex[] { l0, l2, l3, l4 }, this.xTexOffs + d + w + d, this.yTexOffs + d, this.xTexOffs + d + w + d + w, this.yTexOffs + d + h);
|
||||
}
|
||||
|
||||
public void setPos(final float x, final float y, final float z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void render() {
|
||||
if (!this.compiled) {
|
||||
this.compile();
|
||||
}
|
||||
final float c = 57.29578f;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(this.x, this.y, this.z);
|
||||
GL11.glRotatef(this.zRot * c, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glRotatef(this.yRot * c, 0.0f, 1.0f, 0.0f);
|
||||
GL11.glRotatef(this.xRot * c, 1.0f, 0.0f, 0.0f);
|
||||
GL11.glCallList(this.list);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void compile() {
|
||||
GL11.glNewList(this.list = GL11.glGenLists(1), 4864);
|
||||
GL11.glBegin(7);
|
||||
for (int i = 0; i < this.polygons.length; ++i) {
|
||||
this.polygons[i].render();
|
||||
}
|
||||
GL11.glEnd();
|
||||
GL11.glEndList();
|
||||
this.compiled = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.character;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class Polygon
|
||||
{
|
||||
public Vertex[] vertices;
|
||||
public int vertexCount;
|
||||
|
||||
public Polygon(final Vertex[] vertices) {
|
||||
this.vertexCount = 0;
|
||||
this.vertices = vertices;
|
||||
this.vertexCount = vertices.length;
|
||||
}
|
||||
|
||||
public Polygon(final Vertex[] vertices, final int u0, final int v0, final int u1, final int v1) {
|
||||
this(vertices);
|
||||
vertices[0] = vertices[0].remap((float)u1, (float)v0);
|
||||
vertices[1] = vertices[1].remap((float)u0, (float)v0);
|
||||
vertices[2] = vertices[2].remap((float)u0, (float)v1);
|
||||
vertices[3] = vertices[3].remap((float)u1, (float)v1);
|
||||
}
|
||||
|
||||
public void render() {
|
||||
GL11.glColor3f(1.0f, 1.0f, 1.0f);
|
||||
for (int i = 3; i >= 0; --i) {
|
||||
final Vertex v = this.vertices[i];
|
||||
GL11.glTexCoord2f(v.u / 63.999f, v.v / 31.999f);
|
||||
GL11.glVertex3f(v.pos.x, v.pos.y, v.pos.z);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.character;
|
||||
|
||||
public class Vec3
|
||||
{
|
||||
public float x;
|
||||
public float y;
|
||||
public float z;
|
||||
|
||||
public Vec3(final float x, final float y, final float z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public Vec3 interpolateTo(final Vec3 t, final float p) {
|
||||
final float xt = this.x + (t.x - this.x) * p;
|
||||
final float yt = this.y + (t.y - this.y) * p;
|
||||
final float zt = this.z + (t.z - this.z) * p;
|
||||
return new Vec3(xt, yt, zt);
|
||||
}
|
||||
|
||||
public void set(final float x, final float y, final float z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.character;
|
||||
|
||||
public class Vertex
|
||||
{
|
||||
public Vec3 pos;
|
||||
public float u;
|
||||
public float v;
|
||||
|
||||
public Vertex(final float x, final float y, final float z, final float u, final float v) {
|
||||
this(new Vec3(x, y, z), u, v);
|
||||
}
|
||||
|
||||
public Vertex remap(final float u, final float v) {
|
||||
return new Vertex(this, u, v);
|
||||
}
|
||||
|
||||
public Vertex(final Vertex vertex, final float u, final float v) {
|
||||
this.pos = vertex.pos;
|
||||
this.u = u;
|
||||
this.v = v;
|
||||
}
|
||||
|
||||
public Vertex(final Vec3 pos, final float u, final float v) {
|
||||
this.pos = pos;
|
||||
this.u = u;
|
||||
this.v = v;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.character;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.renderer.Textures;
|
||||
import com.mojang.minecraft.Entity;
|
||||
|
||||
public class Zombie extends Entity
|
||||
{
|
||||
public float rot;
|
||||
public float timeOffs;
|
||||
public float speed;
|
||||
public float rotA;
|
||||
private static ZombieModel zombieModel;
|
||||
private Textures textures;
|
||||
|
||||
static {
|
||||
Zombie.zombieModel = new ZombieModel();
|
||||
}
|
||||
|
||||
public Zombie(final Level level, final Textures textures, final float x, final float y, final float z) {
|
||||
super(level);
|
||||
this.textures = textures;
|
||||
this.rotA = (float)(Math.random() + 1.0) * 0.01f;
|
||||
this.setPos(x, y, z);
|
||||
this.timeOffs = (float)Math.random() * 1239813.0f;
|
||||
this.rot = (float)(Math.random() * 3.141592653589793 * 2.0);
|
||||
this.speed = 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
this.xo = this.x;
|
||||
this.yo = this.y;
|
||||
this.zo = this.z;
|
||||
float xa = 0.0f;
|
||||
float ya = 0.0f;
|
||||
if (this.y < -100.0f) {
|
||||
this.remove();
|
||||
}
|
||||
this.rot += this.rotA;
|
||||
this.rotA *= (float)0.99;
|
||||
this.rotA += (float)((Math.random() - Math.random()) * Math.random() * Math.random() * 0.07999999821186066);
|
||||
xa = (float)Math.sin(this.rot);
|
||||
ya = (float)Math.cos(this.rot);
|
||||
if (this.onGround && Math.random() < 0.08) {
|
||||
this.yd = 0.5f;
|
||||
}
|
||||
this.moveRelative(xa, ya, this.onGround ? 0.1f : 0.02f);
|
||||
this.yd -= (float)0.08;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final float a) {
|
||||
GL11.glEnable(3553);
|
||||
GL11.glBindTexture(3553, this.textures.loadTexture("/char.png", 9728));
|
||||
GL11.glPushMatrix();
|
||||
final double time = System.nanoTime() / 1.0E9 * 10.0 * this.speed + this.timeOffs;
|
||||
final float size = 0.058333334f;
|
||||
final float yy = (float)(-Math.abs(Math.sin(time * 0.6662)) * 5.0 - 23.0);
|
||||
GL11.glTranslatef(this.xo + (this.x - this.xo) * a, this.yo + (this.y - this.yo) * a, this.zo + (this.z - this.zo) * a);
|
||||
GL11.glScalef(1.0f, -1.0f, 1.0f);
|
||||
GL11.glScalef(size, size, size);
|
||||
GL11.glTranslatef(0.0f, yy, 0.0f);
|
||||
final float c = 57.29578f;
|
||||
GL11.glRotatef(this.rot * c + 180.0f, 0.0f, 1.0f, 0.0f);
|
||||
Zombie.zombieModel.render((float)time);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glDisable(3553);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.character;
|
||||
|
||||
public class ZombieModel
|
||||
{
|
||||
public Cube head;
|
||||
public Cube body;
|
||||
public Cube arm0;
|
||||
public Cube arm1;
|
||||
public Cube leg0;
|
||||
public Cube leg1;
|
||||
|
||||
public ZombieModel() {
|
||||
(this.head = new Cube(0, 0)).addBox(-4.0f, -8.0f, -4.0f, 8, 8, 8);
|
||||
(this.body = new Cube(16, 16)).addBox(-4.0f, 0.0f, -2.0f, 8, 12, 4);
|
||||
(this.arm0 = new Cube(40, 16)).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)).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)).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)).addBox(-2.0f, 0.0f, -2.0f, 4, 12, 4);
|
||||
this.leg1.setPos(2.0f, 12.0f, 0.0f);
|
||||
}
|
||||
|
||||
public void render(final float time) {
|
||||
this.head.yRot = (float)Math.sin(time * 0.83) * 1.0f;
|
||||
this.head.xRot = (float)Math.sin(time) * 0.8f;
|
||||
this.arm0.xRot = (float)Math.sin(time * 0.6662 + 3.141592653589793) * 2.0f;
|
||||
this.arm0.zRot = (float)(Math.sin(time * 0.2312) + 1.0) * 1.0f;
|
||||
this.arm1.xRot = (float)Math.sin(time * 0.6662) * 2.0f;
|
||||
this.arm1.zRot = (float)(Math.sin(time * 0.2812) - 1.0) * 1.0f;
|
||||
this.leg0.xRot = (float)Math.sin(time * 0.6662) * 1.4f;
|
||||
this.leg1.xRot = (float)Math.sin(time * 0.6662 + 3.141592653589793) * 1.4f;
|
||||
this.head.render();
|
||||
this.body.render();
|
||||
this.arm0.render();
|
||||
this.arm1.render();
|
||||
this.leg0.render();
|
||||
this.leg1.render();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.comm;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public interface ConnectionListener
|
||||
{
|
||||
void handleException(final Exception p0);
|
||||
|
||||
void command(final byte p0, final int p1, final ByteBuffer p2);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.comm;
|
||||
|
||||
public interface ServerListener
|
||||
{
|
||||
void clientConnected(final SocketConnection p0);
|
||||
|
||||
void clientException(final SocketConnection p0, final Exception p1);
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.comm;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SocketChannel;
|
||||
|
||||
public class SocketConnection
|
||||
{
|
||||
public static final int BUFFER_SIZE = 131068;
|
||||
private boolean connected;
|
||||
private SocketChannel socketChannel;
|
||||
public ByteBuffer readBuffer;
|
||||
public ByteBuffer writeBuffer;
|
||||
protected long lastRead;
|
||||
private ConnectionListener connectionListener;
|
||||
private int bytesRead;
|
||||
private int totalBytesWritten;
|
||||
private Socket socket;
|
||||
private BufferedInputStream in;
|
||||
private BufferedOutputStream out;
|
||||
|
||||
public SocketConnection(final String ip, final int port) throws UnknownHostException, IOException {
|
||||
this.readBuffer = ByteBuffer.allocate(131068);
|
||||
this.writeBuffer = ByteBuffer.allocate(131068);
|
||||
(this.socketChannel = SocketChannel.open()).connect(new InetSocketAddress(ip, port));
|
||||
this.socketChannel.configureBlocking(false);
|
||||
this.lastRead = System.currentTimeMillis();
|
||||
this.connected = true;
|
||||
this.readBuffer.clear();
|
||||
this.writeBuffer.clear();
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return this.socket.getInetAddress().toString();
|
||||
}
|
||||
|
||||
public SocketConnection(final SocketChannel socketChannel) throws IOException {
|
||||
this.readBuffer = ByteBuffer.allocate(131068);
|
||||
this.writeBuffer = ByteBuffer.allocate(131068);
|
||||
(this.socketChannel = socketChannel).configureBlocking(false);
|
||||
this.lastRead = System.currentTimeMillis();
|
||||
this.socket = socketChannel.socket();
|
||||
this.connected = true;
|
||||
this.readBuffer.clear();
|
||||
this.writeBuffer.clear();
|
||||
}
|
||||
|
||||
public ByteBuffer getBuffer() {
|
||||
return this.writeBuffer;
|
||||
}
|
||||
|
||||
public void setConnectionListener(final ConnectionListener connectionListener) {
|
||||
this.connectionListener = connectionListener;
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return this.connected;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
this.connected = false;
|
||||
try {
|
||||
if (this.in != null) {
|
||||
this.in.close();
|
||||
}
|
||||
this.in = null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if (this.out != null) {
|
||||
this.out.close();
|
||||
}
|
||||
this.out = null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if (this.socket != null) {
|
||||
this.socket.close();
|
||||
}
|
||||
this.socket = null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void tick() throws IOException {
|
||||
this.writeBuffer.flip();
|
||||
this.socketChannel.write(this.writeBuffer);
|
||||
this.writeBuffer.compact();
|
||||
this.readBuffer.compact();
|
||||
this.socketChannel.read(this.readBuffer);
|
||||
this.readBuffer.flip();
|
||||
if (this.readBuffer.remaining() > 0) {
|
||||
this.connectionListener.command(this.readBuffer.get(0), this.readBuffer.remaining(), this.readBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
public int getSentBytes() {
|
||||
return this.totalBytesWritten;
|
||||
}
|
||||
|
||||
public int getReadBytes() {
|
||||
return this.bytesRead;
|
||||
}
|
||||
|
||||
public void clearSentBytes() {
|
||||
this.totalBytesWritten = 0;
|
||||
}
|
||||
|
||||
public void clearReadBytes() {
|
||||
this.bytesRead = 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.comm;
|
||||
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.io.IOException;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.InetAddress;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
|
||||
public class SocketServer
|
||||
{
|
||||
private ServerSocketChannel ssc;
|
||||
private ServerListener serverListener;
|
||||
private List<SocketConnection> connections;
|
||||
|
||||
public SocketServer(final byte[] ips, final int port, final ServerListener serverListener) throws IOException {
|
||||
this.connections = new LinkedList<SocketConnection>();
|
||||
this.serverListener = serverListener;
|
||||
final InetAddress hostip = InetAddress.getByAddress(ips);
|
||||
this.ssc = ServerSocketChannel.open();
|
||||
this.ssc.socket().bind(new InetSocketAddress(hostip, port));
|
||||
this.ssc.configureBlocking(false);
|
||||
}
|
||||
|
||||
public void tick() throws IOException {
|
||||
SocketChannel socketChannel;
|
||||
while ((socketChannel = this.ssc.accept()) != null) {
|
||||
try {
|
||||
socketChannel.configureBlocking(false);
|
||||
final SocketConnection socketConnection = new SocketConnection(socketChannel);
|
||||
this.connections.add(socketConnection);
|
||||
this.serverListener.clientConnected(socketConnection);
|
||||
}
|
||||
catch (IOException e) {
|
||||
socketChannel.close();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < this.connections.size(); ++i) {
|
||||
final SocketConnection socketConnection2 = this.connections.get(i);
|
||||
if (!socketConnection2.isConnected()) {
|
||||
socketConnection2.disconnect();
|
||||
this.connections.remove(i--);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
socketConnection2.tick();
|
||||
}
|
||||
catch (Exception e2) {
|
||||
socketConnection2.disconnect();
|
||||
this.serverListener.clientException(socketConnection2, e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.gui;
|
||||
|
||||
public class Button
|
||||
{
|
||||
public int x;
|
||||
public int y;
|
||||
public int w;
|
||||
public int h;
|
||||
public String msg;
|
||||
public int id;
|
||||
|
||||
public Button(final int id, final int x, final int y, final int w, final int h, final String msg) {
|
||||
this.id = id;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.renderer.Tesselator;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import com.mojang.minecraft.renderer.Textures;
|
||||
|
||||
public class Font
|
||||
{
|
||||
private int[] charWidths;
|
||||
private int fontTexture;
|
||||
|
||||
public Font(final String name, final Textures textures) {
|
||||
this.charWidths = new int[256];
|
||||
this.fontTexture = 0;
|
||||
BufferedImage img;
|
||||
try {
|
||||
img = ImageIO.read(Textures.class.getResourceAsStream(name));
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
final int w = img.getWidth();
|
||||
final int h = img.getHeight();
|
||||
final int[] rawPixels = new int[w * h];
|
||||
img.getRGB(0, 0, w, h, rawPixels, 0, w);
|
||||
for (int i = 0; i < 128; ++i) {
|
||||
final int xt = i % 16;
|
||||
final int yt = i / 16;
|
||||
int x = 0;
|
||||
for (boolean emptyColumn = false; x < 8 && !emptyColumn; ++x) {
|
||||
final int xPixel = xt * 8 + x;
|
||||
emptyColumn = true;
|
||||
for (int y = 0; y < 8 && emptyColumn; ++y) {
|
||||
final int yPixel = (yt * 8 + y) * w;
|
||||
final int pixel = rawPixels[xPixel + yPixel] & 0xFF;
|
||||
if (pixel > 128) {
|
||||
emptyColumn = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i == 32) {
|
||||
x = 4;
|
||||
}
|
||||
this.charWidths[i] = x;
|
||||
}
|
||||
this.fontTexture = textures.loadTexture(name, 9728);
|
||||
}
|
||||
|
||||
public void drawShadow(final String str, final int x, final int y, final int color) {
|
||||
this.draw(str, x + 1, y + 1, color, true);
|
||||
this.draw(str, x, y, color);
|
||||
}
|
||||
|
||||
public void draw(final String str, final int x, final int y, final int color) {
|
||||
this.draw(str, x, y, color, false);
|
||||
}
|
||||
|
||||
public void draw(final String str, final int x, final int y, int color, final boolean darken) {
|
||||
final char[] chars = str.toCharArray();
|
||||
if (darken) {
|
||||
color = (color & 0xFCFCFC) >> 2;
|
||||
}
|
||||
GL11.glEnable(3553);
|
||||
GL11.glBindTexture(3553, this.fontTexture);
|
||||
final Tesselator t = Tesselator.instance;
|
||||
t.begin();
|
||||
t.color(color);
|
||||
int xo = 0;
|
||||
for (int i = 0; i < chars.length; ++i) {
|
||||
if (chars[i] == '&') {
|
||||
final int cc = "0123456789abcdef".indexOf(chars[i + 1]);
|
||||
final int br = (cc & 0x8) * 8;
|
||||
final int b = (cc & 0x1) * 191 + br;
|
||||
final int g = ((cc & 0x2) >> 1) * 191 + br;
|
||||
final int r = ((cc & 0x4) >> 2) * 191 + br;
|
||||
color = (r << 16 | g << 8 | b);
|
||||
i += 2;
|
||||
if (darken) {
|
||||
color = (color & 0xFCFCFC) >> 2;
|
||||
}
|
||||
t.color(color);
|
||||
}
|
||||
final int ix = chars[i] % '\u0010' * 8;
|
||||
final int iy = chars[i] / '\u0010' * 8;
|
||||
t.vertexUV((float)(x + xo), (float)(y + 8), 0.0f, ix / 128.0f, (iy + 8) / 128.0f);
|
||||
t.vertexUV((float)(x + xo + 8), (float)(y + 8), 0.0f, (ix + 8) / 128.0f, (iy + 8) / 128.0f);
|
||||
t.vertexUV((float)(x + xo + 8), (float)y, 0.0f, (ix + 8) / 128.0f, iy / 128.0f);
|
||||
t.vertexUV((float)(x + xo), (float)y, 0.0f, ix / 128.0f, iy / 128.0f);
|
||||
xo += this.charWidths[chars[i]];
|
||||
}
|
||||
t.end();
|
||||
GL11.glDisable(3553);
|
||||
}
|
||||
|
||||
public int width(final String str) {
|
||||
final char[] chars = str.toCharArray();
|
||||
int len = 0;
|
||||
for (int i = 0; i < chars.length; ++i) {
|
||||
if (chars[i] == '&') {
|
||||
++i;
|
||||
}
|
||||
else {
|
||||
len += this.charWidths[chars[i]];
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PauseScreen extends Screen
|
||||
{
|
||||
private List<Button> buttons;
|
||||
|
||||
public PauseScreen() {
|
||||
this.buttons = new ArrayList<Button>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
this.buttons.add(new Button(0, this.width / 2 - 100, this.height / 3 + 0, 200, 20, "Generate new level"));
|
||||
this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 3 + 32, 200, 20, "Save level.."));
|
||||
this.buttons.add(new Button(2, this.width / 2 - 100, this.height / 3 + 64, 200, 20, "Load level.."));
|
||||
this.buttons.add(new Button(3, this.width / 2 - 100, this.height / 3 + 96, 200, 20, "Back to game"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyPressed(final char eventCharacter, final int eventKey) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(final int x, final int y, final int buttonNum) {
|
||||
if (buttonNum == 0) {
|
||||
for (int i = 0; i < this.buttons.size(); ++i) {
|
||||
final Button button = this.buttons.get(i);
|
||||
if (x >= button.x && y >= button.y && x < button.x + button.w && y < button.y + button.h) {
|
||||
this.buttonClicked(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonClicked(final Button button) {
|
||||
if (button.id == 0) {
|
||||
this.minecraft.generateNewLevel();
|
||||
this.minecraft.setScreen(null);
|
||||
this.minecraft.grabMouse();
|
||||
}
|
||||
if (button.id == 3) {
|
||||
this.minecraft.setScreen(null);
|
||||
this.minecraft.grabMouse();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final int xm, final int ym) {
|
||||
this.fillGradient(0, 0, this.width, this.height, 537199872, -1607454624);
|
||||
for (int i = 0; i < this.buttons.size(); ++i) {
|
||||
final Button button = this.buttons.get(i);
|
||||
this.fill(button.x - 1, button.y - 1, button.x + button.w + 1, button.y + button.h + 1, -16777216);
|
||||
if (xm >= button.x && ym >= button.y && xm < button.x + button.w && ym < button.y + button.h) {
|
||||
this.fill(button.x - 1, button.y - 1, button.x + button.w + 1, button.y + button.h + 1, -6250336);
|
||||
this.fill(button.x, button.y, button.x + button.w, button.y + button.h, -8355680);
|
||||
this.drawCenteredString(button.msg, button.x + button.w / 2, button.y + (button.h - 8) / 2, 16777120);
|
||||
}
|
||||
else {
|
||||
this.fill(button.x, button.y, button.x + button.w, button.y + button.h, -9408400);
|
||||
this.drawCenteredString(button.msg, button.x + button.w / 2, button.y + (button.h - 8) / 2, 14737632);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.gui;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import com.mojang.minecraft.renderer.Tesselator;
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
|
||||
public class Screen
|
||||
{
|
||||
protected Minecraft minecraft;
|
||||
protected int width;
|
||||
protected int height;
|
||||
|
||||
public void render(final int xMouse, final int yMouse) {
|
||||
}
|
||||
|
||||
public void init(final Minecraft minecraft, final int width, final int height) {
|
||||
this.minecraft = minecraft;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.init();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
}
|
||||
|
||||
protected void fill(final int x0, final int y0, final int x1, final int y1, final int col) {
|
||||
final float a = (col >> 24 & 0xFF) / 255.0f;
|
||||
final float r = (col >> 16 & 0xFF) / 255.0f;
|
||||
final float g = (col >> 8 & 0xFF) / 255.0f;
|
||||
final float b = (col & 0xFF) / 255.0f;
|
||||
final Tesselator t = Tesselator.instance;
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
GL11.glColor4f(r, g, b, a);
|
||||
t.begin();
|
||||
t.vertex((float)x0, (float)y1, 0.0f);
|
||||
t.vertex((float)x1, (float)y1, 0.0f);
|
||||
t.vertex((float)x1, (float)y0, 0.0f);
|
||||
t.vertex((float)x0, (float)y0, 0.0f);
|
||||
t.end();
|
||||
GL11.glDisable(3042);
|
||||
}
|
||||
|
||||
protected void fillGradient(final int x0, final int y0, final int x1, final int y1, final int col1, final int col2) {
|
||||
final float a1 = (col1 >> 24 & 0xFF) / 255.0f;
|
||||
final float r1 = (col1 >> 16 & 0xFF) / 255.0f;
|
||||
final float g1 = (col1 >> 8 & 0xFF) / 255.0f;
|
||||
final float b1 = (col1 & 0xFF) / 255.0f;
|
||||
final float a2 = (col2 >> 24 & 0xFF) / 255.0f;
|
||||
final float r2 = (col2 >> 16 & 0xFF) / 255.0f;
|
||||
final float g2 = (col2 >> 8 & 0xFF) / 255.0f;
|
||||
final float b2 = (col2 & 0xFF) / 255.0f;
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
GL11.glBegin(7);
|
||||
GL11.glColor4f(r1, g1, b1, a1);
|
||||
GL11.glVertex2f((float)x1, (float)y0);
|
||||
GL11.glVertex2f((float)x0, (float)y0);
|
||||
GL11.glColor4f(r2, g2, b2, a2);
|
||||
GL11.glVertex2f((float)x0, (float)y1);
|
||||
GL11.glVertex2f((float)x1, (float)y1);
|
||||
GL11.glEnd();
|
||||
GL11.glDisable(3042);
|
||||
}
|
||||
|
||||
public void drawCenteredString(final String str, final int x, final int y, final int color) {
|
||||
final Font font = this.minecraft.font;
|
||||
font.drawShadow(str, x - font.width(str) / 2, y, color);
|
||||
}
|
||||
|
||||
public void drawString(final String str, final int x, final int y, final int color) {
|
||||
final Font font = this.minecraft.font;
|
||||
font.drawShadow(str, x, y, color);
|
||||
}
|
||||
|
||||
public void updateEvents() {
|
||||
while (Mouse.next()) {
|
||||
if (Mouse.getEventButtonState()) {
|
||||
final int xm = Mouse.getEventX() * this.width / this.minecraft.width;
|
||||
final int ym = this.height - Mouse.getEventY() * this.height / this.minecraft.height - 1;
|
||||
this.mouseClicked(xm, ym, Mouse.getEventButton());
|
||||
}
|
||||
}
|
||||
while (Keyboard.next()) {
|
||||
if (Keyboard.getEventKeyState()) {
|
||||
this.keyPressed(Keyboard.getEventCharacter(), Keyboard.getEventKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void keyPressed(final char eventCharacter, final int eventKey) {
|
||||
}
|
||||
|
||||
protected void mouseClicked(final int x, final int y, final int button) {
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level;
|
||||
|
||||
import com.mojang.minecraft.Player;
|
||||
import com.mojang.minecraft.level.tile.Tile;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import com.mojang.minecraft.renderer.Tesselator;
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
|
||||
public class Chunk
|
||||
{
|
||||
public AABB aabb;
|
||||
public final Level level;
|
||||
public final int x0;
|
||||
public final int y0;
|
||||
public final int z0;
|
||||
public final int x1;
|
||||
public final int y1;
|
||||
public final int z1;
|
||||
public final float x;
|
||||
public final float y;
|
||||
public final float z;
|
||||
private boolean dirty;
|
||||
private int lists;
|
||||
public long dirtiedTime;
|
||||
public boolean visible;
|
||||
private static Tesselator t;
|
||||
public static int updates;
|
||||
private static long totalTime;
|
||||
private static int totalUpdates;
|
||||
|
||||
static {
|
||||
Chunk.t = Tesselator.instance;
|
||||
Chunk.updates = 0;
|
||||
Chunk.totalTime = 0L;
|
||||
Chunk.totalUpdates = 0;
|
||||
}
|
||||
|
||||
public Chunk(final Level level, final int x0, final int y0, final int z0, final int x1, final int y1, final int z1) {
|
||||
this.dirty = true;
|
||||
this.lists = -1;
|
||||
this.dirtiedTime = 0L;
|
||||
this.level = level;
|
||||
this.x0 = x0;
|
||||
this.y0 = y0;
|
||||
this.z0 = z0;
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.z1 = z1;
|
||||
this.x = (x0 + x1) / 2.0f;
|
||||
this.y = (y0 + y1) / 2.0f;
|
||||
this.z = (z0 + z1) / 2.0f;
|
||||
this.aabb = new AABB((float)x0, (float)y0, (float)z0, (float)x1, (float)y1, (float)z1);
|
||||
this.lists = GL11.glGenLists(3);
|
||||
}
|
||||
|
||||
private void rebuild(final int layer) {
|
||||
final long before = System.nanoTime();
|
||||
GL11.glNewList(this.lists + layer, 4864);
|
||||
Chunk.t.begin();
|
||||
int tiles = 0;
|
||||
for (int x = this.x0; x < this.x1; ++x) {
|
||||
for (int y = this.y0; y < this.y1; ++y) {
|
||||
for (int z = this.z0; z < this.z1; ++z) {
|
||||
final int tileId = this.level.getTile(x, y, z);
|
||||
if (tileId > 0) {
|
||||
Tile.tiles[tileId].render(Chunk.t, this.level, layer, x, y, z);
|
||||
++tiles;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Chunk.t.end();
|
||||
GL11.glEndList();
|
||||
final long after = System.nanoTime();
|
||||
if (tiles > 0) {
|
||||
Chunk.totalTime += after - before;
|
||||
++Chunk.totalUpdates;
|
||||
}
|
||||
}
|
||||
|
||||
public void rebuild() {
|
||||
++Chunk.updates;
|
||||
this.rebuild(0);
|
||||
this.rebuild(1);
|
||||
this.rebuild(2);
|
||||
this.dirty = false;
|
||||
}
|
||||
|
||||
public void render(final int layer) {
|
||||
GL11.glCallList(this.lists + layer);
|
||||
}
|
||||
|
||||
public void setDirty() {
|
||||
if (!this.dirty) {
|
||||
this.dirtiedTime = System.currentTimeMillis();
|
||||
}
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
return this.dirty;
|
||||
}
|
||||
|
||||
public float distanceToSqr(final Player player) {
|
||||
final float xd = player.x - this.x;
|
||||
final float yd = player.y - this.y;
|
||||
final float zd = player.z - this.z;
|
||||
return xd * xd + yd * yd + zd * zd;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.dirty = true;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
GL11.glNewList(this.lists + i, 4864);
|
||||
GL11.glEndList();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level;
|
||||
|
||||
public class Coord
|
||||
{
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
|
||||
public Coord(final int x, final int y, final int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level;
|
||||
|
||||
import com.mojang.minecraft.Player;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class DirtyChunkSorter implements Comparator<Chunk>
|
||||
{
|
||||
private Player player;
|
||||
|
||||
public DirtyChunkSorter(final Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public int compare(final Chunk c0, final Chunk c1) {
|
||||
final boolean i0 = c0.visible;
|
||||
final boolean i2 = c1.visible;
|
||||
if (i0 && !i2) {
|
||||
return -1;
|
||||
}
|
||||
if (i2 && !i0) {
|
||||
return 1;
|
||||
}
|
||||
return (c0.distanceToSqr(this.player) < c1.distanceToSqr(this.player)) ? -1 : 1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level;
|
||||
|
||||
import com.mojang.minecraft.Player;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class DistanceSorter implements Comparator<Chunk>
|
||||
{
|
||||
private Player player;
|
||||
|
||||
public DistanceSorter(final Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public int compare(final Chunk c0, final Chunk c1) {
|
||||
return (c0.distanceToSqr(this.player) < c1.distanceToSqr(this.player)) ? -1 : 1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level;
|
||||
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
public class Frustum
|
||||
{
|
||||
public float[][] m_Frustum;
|
||||
public static final int RIGHT = 0;
|
||||
public static final int LEFT = 1;
|
||||
public static final int BOTTOM = 2;
|
||||
public static final int TOP = 3;
|
||||
public static final int BACK = 4;
|
||||
public static final int FRONT = 5;
|
||||
public static final int A = 0;
|
||||
public static final int B = 1;
|
||||
public static final int C = 2;
|
||||
public static final int D = 3;
|
||||
private static Frustum frustum;
|
||||
private FloatBuffer _proj;
|
||||
private FloatBuffer _modl;
|
||||
private FloatBuffer _clip;
|
||||
float[] proj;
|
||||
float[] modl;
|
||||
float[] clip;
|
||||
|
||||
static {
|
||||
Frustum.frustum = new Frustum();
|
||||
}
|
||||
|
||||
private Frustum() {
|
||||
this.m_Frustum = new float[6][4];
|
||||
this._proj = BufferUtils.createFloatBuffer(16);
|
||||
this._modl = BufferUtils.createFloatBuffer(16);
|
||||
this._clip = BufferUtils.createFloatBuffer(16);
|
||||
this.proj = new float[16];
|
||||
this.modl = new float[16];
|
||||
this.clip = new float[16];
|
||||
}
|
||||
|
||||
public static Frustum getFrustum() {
|
||||
Frustum.frustum.calculateFrustum();
|
||||
return Frustum.frustum;
|
||||
}
|
||||
|
||||
private void normalizePlane(final float[][] frustum, final int side) {
|
||||
final float magnitude = (float)Math.sqrt(frustum[side][0] * frustum[side][0] + frustum[side][1] * frustum[side][1] + frustum[side][2] * frustum[side][2]);
|
||||
final float[] array = frustum[side];
|
||||
final int n = 0;
|
||||
array[n] /= magnitude;
|
||||
final float[] array2 = frustum[side];
|
||||
final int n2 = 1;
|
||||
array2[n2] /= magnitude;
|
||||
final float[] array3 = frustum[side];
|
||||
final int n3 = 2;
|
||||
array3[n3] /= magnitude;
|
||||
final float[] array4 = frustum[side];
|
||||
final int n4 = 3;
|
||||
array4[n4] /= magnitude;
|
||||
}
|
||||
|
||||
private void calculateFrustum() {
|
||||
this._proj.clear();
|
||||
this._modl.clear();
|
||||
this._clip.clear();
|
||||
GL11.glGetFloat(2983, this._proj);
|
||||
GL11.glGetFloat(2982, this._modl);
|
||||
this._proj.flip().limit(16);
|
||||
this._proj.get(this.proj);
|
||||
this._modl.flip().limit(16);
|
||||
this._modl.get(this.modl);
|
||||
this.clip[0] = this.modl[0] * this.proj[0] + this.modl[1] * this.proj[4] + this.modl[2] * this.proj[8] + this.modl[3] * this.proj[12];
|
||||
this.clip[1] = this.modl[0] * this.proj[1] + this.modl[1] * this.proj[5] + this.modl[2] * this.proj[9] + this.modl[3] * this.proj[13];
|
||||
this.clip[2] = this.modl[0] * this.proj[2] + this.modl[1] * this.proj[6] + this.modl[2] * this.proj[10] + this.modl[3] * this.proj[14];
|
||||
this.clip[3] = this.modl[0] * this.proj[3] + this.modl[1] * this.proj[7] + this.modl[2] * this.proj[11] + this.modl[3] * this.proj[15];
|
||||
this.clip[4] = this.modl[4] * this.proj[0] + this.modl[5] * this.proj[4] + this.modl[6] * this.proj[8] + this.modl[7] * this.proj[12];
|
||||
this.clip[5] = this.modl[4] * this.proj[1] + this.modl[5] * this.proj[5] + this.modl[6] * this.proj[9] + this.modl[7] * this.proj[13];
|
||||
this.clip[6] = this.modl[4] * this.proj[2] + this.modl[5] * this.proj[6] + this.modl[6] * this.proj[10] + this.modl[7] * this.proj[14];
|
||||
this.clip[7] = this.modl[4] * this.proj[3] + this.modl[5] * this.proj[7] + this.modl[6] * this.proj[11] + this.modl[7] * this.proj[15];
|
||||
this.clip[8] = this.modl[8] * this.proj[0] + this.modl[9] * this.proj[4] + this.modl[10] * this.proj[8] + this.modl[11] * this.proj[12];
|
||||
this.clip[9] = this.modl[8] * this.proj[1] + this.modl[9] * this.proj[5] + this.modl[10] * this.proj[9] + this.modl[11] * this.proj[13];
|
||||
this.clip[10] = this.modl[8] * this.proj[2] + this.modl[9] * this.proj[6] + this.modl[10] * this.proj[10] + this.modl[11] * this.proj[14];
|
||||
this.clip[11] = this.modl[8] * this.proj[3] + this.modl[9] * this.proj[7] + this.modl[10] * this.proj[11] + this.modl[11] * this.proj[15];
|
||||
this.clip[12] = this.modl[12] * this.proj[0] + this.modl[13] * this.proj[4] + this.modl[14] * this.proj[8] + this.modl[15] * this.proj[12];
|
||||
this.clip[13] = this.modl[12] * this.proj[1] + this.modl[13] * this.proj[5] + this.modl[14] * this.proj[9] + this.modl[15] * this.proj[13];
|
||||
this.clip[14] = this.modl[12] * this.proj[2] + this.modl[13] * this.proj[6] + this.modl[14] * this.proj[10] + this.modl[15] * this.proj[14];
|
||||
this.clip[15] = this.modl[12] * this.proj[3] + this.modl[13] * this.proj[7] + this.modl[14] * this.proj[11] + this.modl[15] * this.proj[15];
|
||||
this.m_Frustum[0][0] = this.clip[3] - this.clip[0];
|
||||
this.m_Frustum[0][1] = this.clip[7] - this.clip[4];
|
||||
this.m_Frustum[0][2] = this.clip[11] - this.clip[8];
|
||||
this.m_Frustum[0][3] = this.clip[15] - this.clip[12];
|
||||
this.normalizePlane(this.m_Frustum, 0);
|
||||
this.m_Frustum[1][0] = this.clip[3] + this.clip[0];
|
||||
this.m_Frustum[1][1] = this.clip[7] + this.clip[4];
|
||||
this.m_Frustum[1][2] = this.clip[11] + this.clip[8];
|
||||
this.m_Frustum[1][3] = this.clip[15] + this.clip[12];
|
||||
this.normalizePlane(this.m_Frustum, 1);
|
||||
this.m_Frustum[2][0] = this.clip[3] + this.clip[1];
|
||||
this.m_Frustum[2][1] = this.clip[7] + this.clip[5];
|
||||
this.m_Frustum[2][2] = this.clip[11] + this.clip[9];
|
||||
this.m_Frustum[2][3] = this.clip[15] + this.clip[13];
|
||||
this.normalizePlane(this.m_Frustum, 2);
|
||||
this.m_Frustum[3][0] = this.clip[3] - this.clip[1];
|
||||
this.m_Frustum[3][1] = this.clip[7] - this.clip[5];
|
||||
this.m_Frustum[3][2] = this.clip[11] - this.clip[9];
|
||||
this.m_Frustum[3][3] = this.clip[15] - this.clip[13];
|
||||
this.normalizePlane(this.m_Frustum, 3);
|
||||
this.m_Frustum[4][0] = this.clip[3] - this.clip[2];
|
||||
this.m_Frustum[4][1] = this.clip[7] - this.clip[6];
|
||||
this.m_Frustum[4][2] = this.clip[11] - this.clip[10];
|
||||
this.m_Frustum[4][3] = this.clip[15] - this.clip[14];
|
||||
this.normalizePlane(this.m_Frustum, 4);
|
||||
this.m_Frustum[5][0] = this.clip[3] + this.clip[2];
|
||||
this.m_Frustum[5][1] = this.clip[7] + this.clip[6];
|
||||
this.m_Frustum[5][2] = this.clip[11] + this.clip[10];
|
||||
this.m_Frustum[5][3] = this.clip[15] + this.clip[14];
|
||||
this.normalizePlane(this.m_Frustum, 5);
|
||||
}
|
||||
|
||||
public boolean pointInFrustum(final float x, final float y, final float z) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (this.m_Frustum[i][0] * x + this.m_Frustum[i][1] * y + this.m_Frustum[i][2] * z + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean sphereInFrustum(final float x, final float y, final float z, final float radius) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (this.m_Frustum[i][0] * x + this.m_Frustum[i][1] * y + this.m_Frustum[i][2] * z + this.m_Frustum[i][3] <= -radius) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean cubeFullyInFrustum(final float x1, final float y1, final float z1, final float x2, final float y2, final float z2) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean cubeInFrustum(final float x1, final float y1, final float z1, final float x2, final float y2, final float z2) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isVisible(final AABB aabb) {
|
||||
return this.cubeInFrustum(aabb.x0, aabb.y0, aabb.z0, aabb.x1, aabb.y1, aabb.z1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,267 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level;
|
||||
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
import com.mojang.minecraft.level.tile.Tile;
|
||||
import java.util.Random;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Level
|
||||
{
|
||||
private static final int TILE_UPDATE_INTERVAL = 200;
|
||||
public int width;
|
||||
public int height;
|
||||
public int depth;
|
||||
byte[] blocks;
|
||||
private int[] lightDepths;
|
||||
private ArrayList<LevelListener> levelListeners;
|
||||
private Random random;
|
||||
private int randValue;
|
||||
public String name;
|
||||
public String creator;
|
||||
public long createTime;
|
||||
int unprocessed;
|
||||
private static final int multiplier = 1664525;
|
||||
private static final int addend = 1013904223;
|
||||
|
||||
public Level() {
|
||||
this.levelListeners = new ArrayList<LevelListener>();
|
||||
this.random = new Random();
|
||||
this.randValue = this.random.nextInt();
|
||||
this.unprocessed = 0;
|
||||
}
|
||||
|
||||
public void setData(final int w, final int d, final int h, final byte[] blocks) {
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
this.depth = d;
|
||||
this.blocks = blocks;
|
||||
this.lightDepths = new int[w * h];
|
||||
this.calcLightDepths(0, 0, w, h);
|
||||
for (int i = 0; i < this.levelListeners.size(); ++i) {
|
||||
this.levelListeners.get(i).allChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void calcLightDepths(final int x0, final int y0, final int x1, final int y1) {
|
||||
for (int x2 = x0; x2 < x0 + x1; ++x2) {
|
||||
for (int z = y0; z < y0 + y1; ++z) {
|
||||
final int oldDepth = this.lightDepths[x2 + z * this.width];
|
||||
int y2;
|
||||
for (y2 = this.depth - 1; y2 > 0 && !this.isLightBlocker(x2, y2, z); --y2) {}
|
||||
this.lightDepths[x2 + z * this.width] = y2 + 1;
|
||||
if (oldDepth != y2) {
|
||||
final int yl0 = (oldDepth < y2) ? oldDepth : y2;
|
||||
final int yl2 = (oldDepth > y2) ? oldDepth : y2;
|
||||
for (int i = 0; i < this.levelListeners.size(); ++i) {
|
||||
this.levelListeners.get(i).lightColumnChanged(x2, z, yl0, yl2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addListener(final LevelListener levelListener) {
|
||||
this.levelListeners.add(levelListener);
|
||||
}
|
||||
|
||||
public void removeListener(final LevelListener levelListener) {
|
||||
this.levelListeners.remove(levelListener);
|
||||
}
|
||||
|
||||
public boolean isLightBlocker(final int x, final int y, final int z) {
|
||||
final Tile tile = Tile.tiles[this.getTile(x, y, z)];
|
||||
return tile != null && tile.blocksLight();
|
||||
}
|
||||
|
||||
public ArrayList<AABB> getCubes(final AABB box) {
|
||||
final ArrayList<AABB> boxes = new ArrayList<AABB>();
|
||||
final int x0 = (int)Math.floor(box.x0);
|
||||
final int x2 = (int)Math.floor(box.x1 + 1.0f);
|
||||
final int y0 = (int)Math.floor(box.y0);
|
||||
final int y2 = (int)Math.floor(box.y1 + 1.0f);
|
||||
final int z0 = (int)Math.floor(box.z0);
|
||||
final int z2 = (int)Math.floor(box.z1 + 1.0f);
|
||||
for (int x3 = x0; x3 < x2; ++x3) {
|
||||
for (int y3 = y0; y3 < y2; ++y3) {
|
||||
for (int z3 = z0; z3 < z2; ++z3) {
|
||||
if (x3 >= 0 && y3 >= 0 && z3 >= 0 && x3 < this.width && y3 < this.depth && z3 < this.height) {
|
||||
final Tile tile = Tile.tiles[this.getTile(x3, y3, z3)];
|
||||
if (tile != null) {
|
||||
final AABB aabb = tile.getAABB(x3, y3, z3);
|
||||
if (aabb != null) {
|
||||
boxes.add(aabb);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (x3 < 0 || y3 < 0 || z3 < 0 || x3 >= this.width || z3 >= this.height) {
|
||||
final AABB aabb2 = Tile.unbreakable.getAABB(x3, y3, z3);
|
||||
if (aabb2 != null) {
|
||||
boxes.add(aabb2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return boxes;
|
||||
}
|
||||
|
||||
public boolean setTile(final int x, final int y, final int z, final int type) {
|
||||
if (x < 0 || y < 0 || z < 0 || x >= this.width || y >= this.depth || z >= this.height) {
|
||||
return false;
|
||||
}
|
||||
if (type == this.blocks[(y * this.height + z) * this.width + x]) {
|
||||
return false;
|
||||
}
|
||||
this.blocks[(y * this.height + z) * this.width + x] = (byte)type;
|
||||
this.neighborChanged(x - 1, y, z, type);
|
||||
this.neighborChanged(x + 1, y, z, type);
|
||||
this.neighborChanged(x, y - 1, z, type);
|
||||
this.neighborChanged(x, y + 1, z, type);
|
||||
this.neighborChanged(x, y, z - 1, type);
|
||||
this.neighborChanged(x, y, z + 1, type);
|
||||
this.calcLightDepths(x, z, 1, 1);
|
||||
for (int i = 0; i < this.levelListeners.size(); ++i) {
|
||||
this.levelListeners.get(i).tileChanged(x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setTileNoUpdate(final int x, final int y, final int z, final int type) {
|
||||
if (x < 0 || y < 0 || z < 0 || x >= this.width || y >= this.depth || z >= this.height) {
|
||||
return false;
|
||||
}
|
||||
if (type == this.blocks[(y * this.height + z) * this.width + x]) {
|
||||
return false;
|
||||
}
|
||||
this.blocks[(y * this.height + z) * this.width + x] = (byte)type;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void neighborChanged(final int x, final int y, final int z, final int type) {
|
||||
if (x < 0 || y < 0 || z < 0 || x >= this.width || y >= this.depth || z >= this.height) {
|
||||
return;
|
||||
}
|
||||
final Tile tile = Tile.tiles[this.blocks[(y * this.height + z) * this.width + x]];
|
||||
if (tile != null) {
|
||||
tile.neighborChanged(this, x, y, z, type);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLit(final int x, final int y, final int z) {
|
||||
return x < 0 || y < 0 || z < 0 || x >= this.width || y >= this.depth || z >= this.height || y >= this.lightDepths[x + z * this.width];
|
||||
}
|
||||
|
||||
public int getTile(final int x, final int y, final int z) {
|
||||
if (x < 0 || y < 0 || z < 0 || x >= this.width || y >= this.depth || z >= this.height) {
|
||||
return 0;
|
||||
}
|
||||
return this.blocks[(y * this.height + z) * this.width + x];
|
||||
}
|
||||
|
||||
public boolean isSolidTile(final int x, final int y, final int z) {
|
||||
final Tile tile = Tile.tiles[this.getTile(x, y, z)];
|
||||
return tile != null && tile.isSolid();
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
this.unprocessed += this.width * this.height * this.depth;
|
||||
final int ticks = this.unprocessed / 200;
|
||||
this.unprocessed -= ticks * 200;
|
||||
for (int i = 0; i < ticks; ++i) {
|
||||
this.randValue = this.randValue * 1664525 + 1013904223;
|
||||
final int x = this.randValue >> 16 & this.width - 1;
|
||||
this.randValue = this.randValue * 1664525 + 1013904223;
|
||||
final int y = this.randValue >> 16 & this.depth - 1;
|
||||
this.randValue = this.randValue * 1664525 + 1013904223;
|
||||
final int z = this.randValue >> 16 & this.height - 1;
|
||||
final int id = this.blocks[(y * this.height + z) * this.width + x];
|
||||
if (Tile.shouldTick[id]) {
|
||||
Tile.tiles[id].tick(this, x, y, z, this.random);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float getGroundLevel() {
|
||||
return 32.0f;
|
||||
}
|
||||
|
||||
public boolean containsAnyLiquid(final AABB box) {
|
||||
int x0 = (int)Math.floor(box.x0);
|
||||
int x2 = (int)Math.floor(box.x1 + 1.0f);
|
||||
int y0 = (int)Math.floor(box.y0);
|
||||
int y2 = (int)Math.floor(box.y1 + 1.0f);
|
||||
int z0 = (int)Math.floor(box.z0);
|
||||
int z2 = (int)Math.floor(box.z1 + 1.0f);
|
||||
if (x0 < 0) {
|
||||
x0 = 0;
|
||||
}
|
||||
if (y0 < 0) {
|
||||
y0 = 0;
|
||||
}
|
||||
if (z0 < 0) {
|
||||
z0 = 0;
|
||||
}
|
||||
if (x2 > this.width) {
|
||||
x2 = this.width;
|
||||
}
|
||||
if (y2 > this.depth) {
|
||||
y2 = this.depth;
|
||||
}
|
||||
if (z2 > this.height) {
|
||||
z2 = this.height;
|
||||
}
|
||||
for (int x3 = x0; x3 < x2; ++x3) {
|
||||
for (int y3 = y0; y3 < y2; ++y3) {
|
||||
for (int z3 = z0; z3 < z2; ++z3) {
|
||||
final Tile tile = Tile.tiles[this.getTile(x3, y3, z3)];
|
||||
if (tile != null && tile.getLiquidType() > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean containsLiquid(final AABB box, final int liquidId) {
|
||||
int x0 = (int)Math.floor(box.x0);
|
||||
int x2 = (int)Math.floor(box.x1 + 1.0f);
|
||||
int y0 = (int)Math.floor(box.y0);
|
||||
int y2 = (int)Math.floor(box.y1 + 1.0f);
|
||||
int z0 = (int)Math.floor(box.z0);
|
||||
int z2 = (int)Math.floor(box.z1 + 1.0f);
|
||||
if (x0 < 0) {
|
||||
x0 = 0;
|
||||
}
|
||||
if (y0 < 0) {
|
||||
y0 = 0;
|
||||
}
|
||||
if (z0 < 0) {
|
||||
z0 = 0;
|
||||
}
|
||||
if (x2 > this.width) {
|
||||
x2 = this.width;
|
||||
}
|
||||
if (y2 > this.depth) {
|
||||
y2 = this.depth;
|
||||
}
|
||||
if (z2 > this.height) {
|
||||
z2 = this.height;
|
||||
}
|
||||
for (int x3 = x0; x3 < x2; ++x3) {
|
||||
for (int y3 = y0; y3 < y2; ++y3) {
|
||||
for (int z3 = z0; z3 < z2; ++z3) {
|
||||
final Tile tile = Tile.tiles[this.getTile(x3, y3, z3)];
|
||||
if (tile != null && tile.getLiquidType() == liquidId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class LevelIO
|
||||
{
|
||||
private static final int MAGIC_NUMBER = 656127880;
|
||||
private static final int CURRENT_VERSION = 1;
|
||||
private LevelLoaderListener levelLoaderListener;
|
||||
public String error;
|
||||
|
||||
public LevelIO(final LevelLoaderListener levelLoaderListener) {
|
||||
this.error = null;
|
||||
this.levelLoaderListener = levelLoaderListener;
|
||||
}
|
||||
|
||||
public boolean load(final Level level, final InputStream in) {
|
||||
this.levelLoaderListener.beginLevelLoading("Loading level");
|
||||
this.levelLoaderListener.levelLoadUpdate("Reading..");
|
||||
try {
|
||||
final DataInputStream dis = new DataInputStream(new GZIPInputStream(in));
|
||||
final int magic = dis.readInt();
|
||||
if (magic != 656127880) {
|
||||
this.error = "Bad level file format";
|
||||
return false;
|
||||
}
|
||||
final byte version = dis.readByte();
|
||||
if (version > 1) {
|
||||
this.error = "Bad level file format";
|
||||
return false;
|
||||
}
|
||||
final String name = dis.readUTF();
|
||||
final String creator = dis.readUTF();
|
||||
final long createTime = dis.readLong();
|
||||
final int width = dis.readShort();
|
||||
final int height = dis.readShort();
|
||||
final int depth = dis.readShort();
|
||||
final byte[] blocks = new byte[width * height * depth];
|
||||
dis.readFully(blocks);
|
||||
dis.close();
|
||||
level.setData(width, depth, height, blocks);
|
||||
level.name = name;
|
||||
level.creator = creator;
|
||||
level.createTime = createTime;
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
this.error = "Failed to load level: " + e.toString();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean loadLegacy(final Level level, final InputStream in) {
|
||||
this.levelLoaderListener.beginLevelLoading("Loading level");
|
||||
this.levelLoaderListener.levelLoadUpdate("Reading..");
|
||||
try {
|
||||
final DataInputStream dis = new DataInputStream(new GZIPInputStream(in));
|
||||
final String name = "--";
|
||||
final String creator = "unknown";
|
||||
final long createTime = 0L;
|
||||
final int width = 256;
|
||||
final int height = 256;
|
||||
final int depth = 64;
|
||||
final byte[] blocks = new byte[width * height * depth];
|
||||
dis.readFully(blocks);
|
||||
dis.close();
|
||||
level.setData(width, depth, height, blocks);
|
||||
level.name = name;
|
||||
level.creator = creator;
|
||||
level.createTime = createTime;
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
this.error = "Failed to load level: " + e.toString();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void save(final Level level, final OutputStream out) {
|
||||
try {
|
||||
final DataOutputStream dos = new DataOutputStream(new GZIPOutputStream(out));
|
||||
dos.writeInt(656127880);
|
||||
dos.writeByte(1);
|
||||
dos.writeUTF(level.name);
|
||||
dos.writeUTF(level.creator);
|
||||
dos.writeLong(level.createTime);
|
||||
dos.writeShort(level.width);
|
||||
dos.writeShort(level.height);
|
||||
dos.writeShort(level.depth);
|
||||
dos.write(level.blocks);
|
||||
dos.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level;
|
||||
|
||||
public interface LevelListener
|
||||
{
|
||||
void tileChanged(final int p0, final int p1, final int p2);
|
||||
|
||||
void lightColumnChanged(final int p0, final int p1, final int p2, final int p3);
|
||||
|
||||
void allChanged();
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level;
|
||||
|
||||
public interface LevelLoaderListener
|
||||
{
|
||||
void beginLevelLoading(final String p0);
|
||||
|
||||
void levelLoadUpdate(final String p0);
|
||||
}
|
|
@ -0,0 +1,441 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level;
|
||||
|
||||
import com.mojang.minecraft.HitResult;
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
import com.mojang.minecraft.level.tile.Tile;
|
||||
import com.mojang.minecraft.renderer.Frustum;
|
||||
import java.util.Collections;
|
||||
import com.mojang.minecraft.renderer.Tesselator;
|
||||
import java.util.Comparator;
|
||||
import java.util.Arrays;
|
||||
import com.mojang.minecraft.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import com.mojang.minecraft.renderer.Textures;
|
||||
|
||||
public class LevelRenderer implements LevelListener
|
||||
{
|
||||
public static final int MAX_REBUILDS_PER_FRAME = 4;
|
||||
public static final int CHUNK_SIZE = 16;
|
||||
private Level level;
|
||||
private Chunk[] chunks;
|
||||
private Chunk[] sortedChunks;
|
||||
private int xChunks;
|
||||
private int yChunks;
|
||||
private int zChunks;
|
||||
private Textures textures;
|
||||
private int surroundLists;
|
||||
private int drawDistance;
|
||||
float lX;
|
||||
float lY;
|
||||
float lZ;
|
||||
|
||||
public LevelRenderer(final Level level, final Textures textures) {
|
||||
this.drawDistance = 0;
|
||||
this.lX = 0.0f;
|
||||
this.lY = 0.0f;
|
||||
this.lZ = 0.0f;
|
||||
this.level = level;
|
||||
this.textures = textures;
|
||||
level.addListener(this);
|
||||
this.surroundLists = GL11.glGenLists(2);
|
||||
this.allChanged();
|
||||
}
|
||||
|
||||
public void allChanged() {
|
||||
this.lX = -900000.0f;
|
||||
this.lY = -900000.0f;
|
||||
this.lZ = -900000.0f;
|
||||
this.xChunks = (this.level.width + 16 - 1) / 16;
|
||||
this.yChunks = (this.level.depth + 16 - 1) / 16;
|
||||
this.zChunks = (this.level.height + 16 - 1) / 16;
|
||||
this.chunks = new Chunk[this.xChunks * this.yChunks * this.zChunks];
|
||||
this.sortedChunks = new Chunk[this.xChunks * this.yChunks * this.zChunks];
|
||||
for (int x = 0; x < this.xChunks; ++x) {
|
||||
for (int y = 0; y < this.yChunks; ++y) {
|
||||
for (int z = 0; z < this.zChunks; ++z) {
|
||||
final int x2 = x * 16;
|
||||
final int y2 = y * 16;
|
||||
final int z2 = z * 16;
|
||||
int x3 = (x + 1) * 16;
|
||||
int y3 = (y + 1) * 16;
|
||||
int z3 = (z + 1) * 16;
|
||||
if (x3 > this.level.width) {
|
||||
x3 = this.level.width;
|
||||
}
|
||||
if (y3 > this.level.depth) {
|
||||
y3 = this.level.depth;
|
||||
}
|
||||
if (z3 > this.level.height) {
|
||||
z3 = this.level.height;
|
||||
}
|
||||
this.chunks[(x + y * this.xChunks) * this.zChunks + z] = new Chunk(this.level, x2, y2, z2, x3, y3, z3);
|
||||
this.sortedChunks[(x + y * this.xChunks) * this.zChunks + z] = this.chunks[(x + y * this.xChunks) * this.zChunks + z];
|
||||
}
|
||||
}
|
||||
}
|
||||
GL11.glNewList(this.surroundLists + 0, 4864);
|
||||
this.compileSurroundingGround();
|
||||
GL11.glEndList();
|
||||
GL11.glNewList(this.surroundLists + 1, 4864);
|
||||
this.compileSurroundingWater();
|
||||
GL11.glEndList();
|
||||
for (int i = 0; i < this.chunks.length; ++i) {
|
||||
this.chunks[i].reset();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Chunk> getAllDirtyChunks() {
|
||||
ArrayList<Chunk> dirty = null;
|
||||
for (int i = 0; i < this.chunks.length; ++i) {
|
||||
final Chunk chunk = this.chunks[i];
|
||||
if (chunk.isDirty()) {
|
||||
if (dirty == null) {
|
||||
dirty = new ArrayList<Chunk>();
|
||||
}
|
||||
dirty.add(chunk);
|
||||
}
|
||||
}
|
||||
return dirty;
|
||||
}
|
||||
|
||||
public void render(final Player player, final int layer) {
|
||||
GL11.glEnable(3553);
|
||||
GL11.glBindTexture(3553, this.textures.loadTexture("/terrain.png", 9728));
|
||||
final float xd = player.x - this.lX;
|
||||
final float yd = player.y - this.lY;
|
||||
final float zd = player.z - this.lZ;
|
||||
if (xd * xd + yd * yd + zd * zd > 64.0f) {
|
||||
this.lX = player.x;
|
||||
this.lY = player.y;
|
||||
this.lZ = player.z;
|
||||
Arrays.sort(this.sortedChunks, new DistanceSorter(player));
|
||||
}
|
||||
for (int i = 0; i < this.sortedChunks.length; ++i) {
|
||||
if (this.sortedChunks[i].visible) {
|
||||
final float dd = (float)(256 / (1 << this.drawDistance));
|
||||
if (this.drawDistance == 0 || this.sortedChunks[i].distanceToSqr(player) < dd * dd) {
|
||||
this.sortedChunks[i].render(layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
GL11.glDisable(3553);
|
||||
}
|
||||
|
||||
public void renderSurroundingGround() {
|
||||
GL11.glCallList(this.surroundLists + 0);
|
||||
}
|
||||
|
||||
public void compileSurroundingGround() {
|
||||
GL11.glEnable(3553);
|
||||
GL11.glBindTexture(3553, this.textures.loadTexture("/rock.png", 9728));
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
final Tesselator t = Tesselator.instance;
|
||||
final float y = this.level.getGroundLevel() - 2.0f;
|
||||
int s = 128;
|
||||
if (s > this.level.width) {
|
||||
s = this.level.width;
|
||||
}
|
||||
if (s > this.level.height) {
|
||||
s = this.level.height;
|
||||
}
|
||||
final int d = 5;
|
||||
t.begin();
|
||||
for (int xx = -s * d; xx < this.level.width + s * d; xx += s) {
|
||||
for (int zz = -s * d; zz < this.level.height + s * d; zz += s) {
|
||||
float yy = y;
|
||||
if (xx >= 0 && zz >= 0 && xx < this.level.width && zz < this.level.height) {
|
||||
yy = 0.0f;
|
||||
}
|
||||
t.vertexUV((float)(xx + 0), yy, (float)(zz + s), 0.0f, (float)s);
|
||||
t.vertexUV((float)(xx + s), yy, (float)(zz + s), (float)s, (float)s);
|
||||
t.vertexUV((float)(xx + s), yy, (float)(zz + 0), (float)s, 0.0f);
|
||||
t.vertexUV((float)(xx + 0), yy, (float)(zz + 0), 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
t.end();
|
||||
GL11.glBindTexture(3553, this.textures.loadTexture("/rock.png", 9728));
|
||||
GL11.glColor3f(0.8f, 0.8f, 0.8f);
|
||||
t.begin();
|
||||
for (int xx = 0; xx < this.level.width; xx += s) {
|
||||
t.vertexUV((float)(xx + 0), 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
t.vertexUV((float)(xx + s), 0.0f, 0.0f, (float)s, 0.0f);
|
||||
t.vertexUV((float)(xx + s), y, 0.0f, (float)s, y);
|
||||
t.vertexUV((float)(xx + 0), y, 0.0f, 0.0f, y);
|
||||
t.vertexUV((float)(xx + 0), y, (float)this.level.height, 0.0f, y);
|
||||
t.vertexUV((float)(xx + s), y, (float)this.level.height, (float)s, y);
|
||||
t.vertexUV((float)(xx + s), 0.0f, (float)this.level.height, (float)s, 0.0f);
|
||||
t.vertexUV((float)(xx + 0), 0.0f, (float)this.level.height, 0.0f, 0.0f);
|
||||
}
|
||||
GL11.glColor3f(0.6f, 0.6f, 0.6f);
|
||||
for (int zz2 = 0; zz2 < this.level.height; zz2 += s) {
|
||||
t.vertexUV(0.0f, y, (float)(zz2 + 0), 0.0f, 0.0f);
|
||||
t.vertexUV(0.0f, y, (float)(zz2 + s), (float)s, 0.0f);
|
||||
t.vertexUV(0.0f, 0.0f, (float)(zz2 + s), (float)s, y);
|
||||
t.vertexUV(0.0f, 0.0f, (float)(zz2 + 0), 0.0f, y);
|
||||
t.vertexUV((float)this.level.width, 0.0f, (float)(zz2 + 0), 0.0f, y);
|
||||
t.vertexUV((float)this.level.width, 0.0f, (float)(zz2 + s), (float)s, y);
|
||||
t.vertexUV((float)this.level.width, y, (float)(zz2 + s), (float)s, 0.0f);
|
||||
t.vertexUV((float)this.level.width, y, (float)(zz2 + 0), 0.0f, 0.0f);
|
||||
}
|
||||
t.end();
|
||||
GL11.glDisable(3042);
|
||||
GL11.glDisable(3553);
|
||||
}
|
||||
|
||||
public void renderSurroundingWater() {
|
||||
GL11.glCallList(this.surroundLists + 1);
|
||||
}
|
||||
|
||||
public void compileSurroundingWater() {
|
||||
GL11.glEnable(3553);
|
||||
GL11.glColor3f(1.0f, 1.0f, 1.0f);
|
||||
GL11.glBindTexture(3553, this.textures.loadTexture("/water.png", 9728));
|
||||
final float y = this.level.getGroundLevel();
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
final Tesselator t = Tesselator.instance;
|
||||
int s = 128;
|
||||
if (s > this.level.width) {
|
||||
s = this.level.width;
|
||||
}
|
||||
if (s > this.level.height) {
|
||||
s = this.level.height;
|
||||
}
|
||||
final int d = 5;
|
||||
t.begin();
|
||||
for (int xx = -s * d; xx < this.level.width + s * d; xx += s) {
|
||||
for (int zz = -s * d; zz < this.level.height + s * d; zz += s) {
|
||||
final float yy = y - 0.1f;
|
||||
if (xx < 0 || zz < 0 || xx >= this.level.width || zz >= this.level.height) {
|
||||
t.vertexUV((float)(xx + 0), yy, (float)(zz + s), 0.0f, (float)s);
|
||||
t.vertexUV((float)(xx + s), yy, (float)(zz + s), (float)s, (float)s);
|
||||
t.vertexUV((float)(xx + s), yy, (float)(zz + 0), (float)s, 0.0f);
|
||||
t.vertexUV((float)(xx + 0), yy, (float)(zz + 0), 0.0f, 0.0f);
|
||||
t.vertexUV((float)(xx + 0), yy, (float)(zz + 0), 0.0f, 0.0f);
|
||||
t.vertexUV((float)(xx + s), yy, (float)(zz + 0), (float)s, 0.0f);
|
||||
t.vertexUV((float)(xx + s), yy, (float)(zz + s), (float)s, (float)s);
|
||||
t.vertexUV((float)(xx + 0), yy, (float)(zz + s), 0.0f, (float)s);
|
||||
}
|
||||
}
|
||||
}
|
||||
t.end();
|
||||
GL11.glDisable(3042);
|
||||
GL11.glDisable(3553);
|
||||
}
|
||||
|
||||
public void updateDirtyChunks(final Player player) {
|
||||
final List<Chunk> dirty = this.getAllDirtyChunks();
|
||||
if (dirty == null) {
|
||||
return;
|
||||
}
|
||||
Collections.sort(dirty, new DirtyChunkSorter(player));
|
||||
for (int i = 0; i < 4 && i < dirty.size(); ++i) {
|
||||
dirty.get(i).rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
public void pick(final Player player, final Frustum frustum) {
|
||||
final Tesselator t = Tesselator.instance;
|
||||
final float r = 2.5f;
|
||||
final AABB box = player.bb.grow(r, r, r);
|
||||
final int x0 = (int)box.x0;
|
||||
final int x2 = (int)(box.x1 + 1.0f);
|
||||
final int y0 = (int)box.y0;
|
||||
final int y2 = (int)(box.y1 + 1.0f);
|
||||
final int z0 = (int)box.z0;
|
||||
final int z2 = (int)(box.z1 + 1.0f);
|
||||
GL11.glInitNames();
|
||||
GL11.glPushName(0);
|
||||
GL11.glPushName(0);
|
||||
for (int x3 = x0; x3 < x2; ++x3) {
|
||||
GL11.glLoadName(x3);
|
||||
GL11.glPushName(0);
|
||||
for (int y3 = y0; y3 < y2; ++y3) {
|
||||
GL11.glLoadName(y3);
|
||||
GL11.glPushName(0);
|
||||
for (int z3 = z0; z3 < z2; ++z3) {
|
||||
final Tile tile = Tile.tiles[this.level.getTile(x3, y3, z3)];
|
||||
if (tile != null && tile.mayPick() && frustum.isVisible(tile.getTileAABB(x3, y3, z3))) {
|
||||
GL11.glLoadName(z3);
|
||||
GL11.glPushName(0);
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
GL11.glLoadName(i);
|
||||
t.begin();
|
||||
tile.renderFaceNoTexture(player, t, x3, y3, z3, i);
|
||||
t.end();
|
||||
}
|
||||
GL11.glPopName();
|
||||
}
|
||||
}
|
||||
GL11.glPopName();
|
||||
}
|
||||
GL11.glPopName();
|
||||
}
|
||||
GL11.glPopName();
|
||||
GL11.glPopName();
|
||||
}
|
||||
|
||||
public void renderHit(final Player player, final HitResult h, final int mode, final int tileType) {
|
||||
final Tesselator t = Tesselator.instance;
|
||||
GL11.glEnable(3042);
|
||||
GL11.glEnable(3008);
|
||||
GL11.glBlendFunc(770, 1);
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, ((float)Math.sin(System.currentTimeMillis() / 100.0) * 0.2f + 0.4f) * 0.5f);
|
||||
if (mode == 0) {
|
||||
t.begin();
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
Tile.rock.renderFaceNoTexture(player, t, h.x, h.y, h.z, i);
|
||||
}
|
||||
t.end();
|
||||
}
|
||||
else {
|
||||
GL11.glBlendFunc(770, 771);
|
||||
final float br = (float)Math.sin(System.currentTimeMillis() / 100.0) * 0.2f + 0.8f;
|
||||
GL11.glColor4f(br, br, br, (float)Math.sin(System.currentTimeMillis() / 200.0) * 0.2f + 0.5f);
|
||||
GL11.glEnable(3553);
|
||||
final int id = this.textures.loadTexture("/terrain.png", 9728);
|
||||
GL11.glBindTexture(3553, id);
|
||||
int x = h.x;
|
||||
int y = h.y;
|
||||
int z = h.z;
|
||||
if (h.f == 0) {
|
||||
--y;
|
||||
}
|
||||
if (h.f == 1) {
|
||||
++y;
|
||||
}
|
||||
if (h.f == 2) {
|
||||
--z;
|
||||
}
|
||||
if (h.f == 3) {
|
||||
++z;
|
||||
}
|
||||
if (h.f == 4) {
|
||||
--x;
|
||||
}
|
||||
if (h.f == 5) {
|
||||
++x;
|
||||
}
|
||||
t.begin();
|
||||
t.noColor();
|
||||
Tile.tiles[tileType].render(t, this.level, 0, x, y, z);
|
||||
Tile.tiles[tileType].render(t, this.level, 1, x, y, z);
|
||||
t.end();
|
||||
GL11.glDisable(3553);
|
||||
}
|
||||
GL11.glDisable(3042);
|
||||
GL11.glDisable(3008);
|
||||
}
|
||||
|
||||
public void renderHitOutline(final Player player, final HitResult h, final int mode, final int tileType) {
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
GL11.glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
|
||||
float x = (float)h.x;
|
||||
float y = (float)h.y;
|
||||
float z = (float)h.z;
|
||||
if (mode == 1) {
|
||||
if (h.f == 0) {
|
||||
--y;
|
||||
}
|
||||
if (h.f == 1) {
|
||||
++y;
|
||||
}
|
||||
if (h.f == 2) {
|
||||
--z;
|
||||
}
|
||||
if (h.f == 3) {
|
||||
++z;
|
||||
}
|
||||
if (h.f == 4) {
|
||||
--x;
|
||||
}
|
||||
if (h.f == 5) {
|
||||
++x;
|
||||
}
|
||||
}
|
||||
GL11.glBegin(3);
|
||||
GL11.glVertex3f(x, y, z);
|
||||
GL11.glVertex3f(x + 1.0f, y, z);
|
||||
GL11.glVertex3f(x + 1.0f, y, z + 1.0f);
|
||||
GL11.glVertex3f(x, y, z + 1.0f);
|
||||
GL11.glVertex3f(x, y, z);
|
||||
GL11.glEnd();
|
||||
GL11.glBegin(3);
|
||||
GL11.glVertex3f(x, y + 1.0f, z);
|
||||
GL11.glVertex3f(x + 1.0f, y + 1.0f, z);
|
||||
GL11.glVertex3f(x + 1.0f, y + 1.0f, z + 1.0f);
|
||||
GL11.glVertex3f(x, y + 1.0f, z + 1.0f);
|
||||
GL11.glVertex3f(x, y + 1.0f, z);
|
||||
GL11.glEnd();
|
||||
GL11.glBegin(1);
|
||||
GL11.glVertex3f(x, y, z);
|
||||
GL11.glVertex3f(x, y + 1.0f, z);
|
||||
GL11.glVertex3f(x + 1.0f, y, z);
|
||||
GL11.glVertex3f(x + 1.0f, y + 1.0f, z);
|
||||
GL11.glVertex3f(x + 1.0f, y, z + 1.0f);
|
||||
GL11.glVertex3f(x + 1.0f, y + 1.0f, z + 1.0f);
|
||||
GL11.glVertex3f(x, y, z + 1.0f);
|
||||
GL11.glVertex3f(x, y + 1.0f, z + 1.0f);
|
||||
GL11.glEnd();
|
||||
GL11.glDisable(3042);
|
||||
}
|
||||
|
||||
public void setDirty(int x0, int y0, int z0, int x1, int y1, int z1) {
|
||||
x0 /= 16;
|
||||
x1 /= 16;
|
||||
y0 /= 16;
|
||||
y1 /= 16;
|
||||
z0 /= 16;
|
||||
z1 /= 16;
|
||||
if (x0 < 0) {
|
||||
x0 = 0;
|
||||
}
|
||||
if (y0 < 0) {
|
||||
y0 = 0;
|
||||
}
|
||||
if (z0 < 0) {
|
||||
z0 = 0;
|
||||
}
|
||||
if (x1 >= this.xChunks) {
|
||||
x1 = this.xChunks - 1;
|
||||
}
|
||||
if (y1 >= this.yChunks) {
|
||||
y1 = this.yChunks - 1;
|
||||
}
|
||||
if (z1 >= this.zChunks) {
|
||||
z1 = this.zChunks - 1;
|
||||
}
|
||||
for (int x2 = x0; x2 <= x1; ++x2) {
|
||||
for (int y2 = y0; y2 <= y1; ++y2) {
|
||||
for (int z2 = z0; z2 <= z1; ++z2) {
|
||||
this.chunks[(x2 + y2 * this.xChunks) * this.zChunks + z2].setDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void tileChanged(final int x, final int y, final int z) {
|
||||
this.setDirty(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
|
||||
}
|
||||
|
||||
public void lightColumnChanged(final int x, final int z, final int y0, final int y1) {
|
||||
this.setDirty(x - 1, y0 - 1, z - 1, x + 1, y1 + 1, z + 1);
|
||||
}
|
||||
|
||||
public void toggleDrawDistance() {
|
||||
this.drawDistance = (this.drawDistance + 1) % 4;
|
||||
}
|
||||
|
||||
public void cull(final Frustum frustum) {
|
||||
for (int i = 0; i < this.chunks.length; ++i) {
|
||||
this.chunks[i].visible = frustum.isVisible(this.chunks[i].aabb);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class PerlinNoiseFilter
|
||||
{
|
||||
Random random;
|
||||
int seed;
|
||||
int levels;
|
||||
int fuzz;
|
||||
|
||||
public PerlinNoiseFilter(final int levels) {
|
||||
this.random = new Random();
|
||||
this.seed = this.random.nextInt();
|
||||
this.levels = 0;
|
||||
this.fuzz = 16;
|
||||
this.levels = levels;
|
||||
}
|
||||
|
||||
public int[] read(final int width, final int height) {
|
||||
final Random random = new Random();
|
||||
final int[] tmp = new int[width * height];
|
||||
final int level = this.levels;
|
||||
for (int step = width >> level, y = 0; y < height; y += step) {
|
||||
for (int x = 0; x < width; x += step) {
|
||||
tmp[x + y * width] = (random.nextInt(256) - 128) * this.fuzz;
|
||||
}
|
||||
}
|
||||
for (int step = width >> level; step > 1; step /= 2) {
|
||||
final int val = 256 * (step << level);
|
||||
final int ss = step / 2;
|
||||
for (int y2 = 0; y2 < height; y2 += step) {
|
||||
for (int x2 = 0; x2 < width; x2 += step) {
|
||||
final int ul = tmp[(x2 + 0) % width + (y2 + 0) % height * width];
|
||||
final int ur = tmp[(x2 + step) % width + (y2 + 0) % height * width];
|
||||
final int dl = tmp[(x2 + 0) % width + (y2 + step) % height * width];
|
||||
final int dr = tmp[(x2 + step) % width + (y2 + step) % height * width];
|
||||
final int m = (ul + dl + ur + dr) / 4 + random.nextInt(val * 2) - val;
|
||||
tmp[x2 + ss + (y2 + ss) * width] = m;
|
||||
}
|
||||
}
|
||||
for (int y2 = 0; y2 < height; y2 += step) {
|
||||
for (int x2 = 0; x2 < width; x2 += step) {
|
||||
final int c = tmp[x2 + y2 * width];
|
||||
final int r = tmp[(x2 + step) % width + y2 * width];
|
||||
final int d = tmp[x2 + (y2 + step) % width * width];
|
||||
final int mu = tmp[(x2 + ss & width - 1) + (y2 + ss - step & height - 1) * width];
|
||||
final int ml = tmp[(x2 + ss - step & width - 1) + (y2 + ss & height - 1) * width];
|
||||
final int i = tmp[(x2 + ss) % width + (y2 + ss) % height * width];
|
||||
final int u = (c + r + i + mu) / 4 + random.nextInt(val * 2) - val;
|
||||
final int l = (c + d + i + ml) / 4 + random.nextInt(val * 2) - val;
|
||||
tmp[x2 + ss + y2 * width] = u;
|
||||
tmp[x2 + (y2 + ss) * width] = l;
|
||||
}
|
||||
}
|
||||
}
|
||||
final int[] result = new int[width * height];
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
result[x + y * width] = tmp[x % width + y % height * width] / 512 + 128;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
public class Tesselator
|
||||
{
|
||||
private static final int MAX_MEMORY_USE = 4194304;
|
||||
private static final int MAX_FLOATS = 524288;
|
||||
private FloatBuffer buffer;
|
||||
private float[] array;
|
||||
private int vertices;
|
||||
private float u;
|
||||
private float v;
|
||||
private float r;
|
||||
private float g;
|
||||
private float b;
|
||||
private boolean hasColor;
|
||||
private boolean hasTexture;
|
||||
private int len;
|
||||
private int p;
|
||||
public static Tesselator instance;
|
||||
|
||||
static {
|
||||
Tesselator.instance = new Tesselator();
|
||||
}
|
||||
|
||||
private Tesselator() {
|
||||
this.buffer = BufferUtils.createFloatBuffer(524288);
|
||||
this.array = new float[524288];
|
||||
this.vertices = 0;
|
||||
this.hasColor = false;
|
||||
this.hasTexture = false;
|
||||
this.len = 3;
|
||||
this.p = 0;
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
this.buffer.clear();
|
||||
this.buffer.put(this.array, 0, this.p);
|
||||
this.buffer.flip();
|
||||
if (this.hasTexture && this.hasColor) {
|
||||
GL11.glInterleavedArrays(10794, 0, this.buffer);
|
||||
}
|
||||
else if (this.hasTexture) {
|
||||
GL11.glInterleavedArrays(10791, 0, this.buffer);
|
||||
}
|
||||
else if (this.hasColor) {
|
||||
GL11.glInterleavedArrays(10788, 0, this.buffer);
|
||||
}
|
||||
else {
|
||||
GL11.glInterleavedArrays(10785, 0, this.buffer);
|
||||
}
|
||||
GL11.glEnableClientState(32884);
|
||||
if (this.hasTexture) {
|
||||
GL11.glEnableClientState(32888);
|
||||
}
|
||||
if (this.hasColor) {
|
||||
GL11.glEnableClientState(32886);
|
||||
}
|
||||
GL11.glDrawArrays(7, 0, this.vertices);
|
||||
GL11.glDisableClientState(32884);
|
||||
if (this.hasTexture) {
|
||||
GL11.glDisableClientState(32888);
|
||||
}
|
||||
if (this.hasColor) {
|
||||
GL11.glDisableClientState(32886);
|
||||
}
|
||||
this.clear();
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
this.vertices = 0;
|
||||
this.buffer.clear();
|
||||
this.p = 0;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
this.clear();
|
||||
this.hasColor = false;
|
||||
this.hasTexture = false;
|
||||
}
|
||||
|
||||
public void tex(final float u, final float v) {
|
||||
if (!this.hasTexture) {
|
||||
this.len += 2;
|
||||
}
|
||||
this.hasTexture = true;
|
||||
this.u = u;
|
||||
this.v = v;
|
||||
}
|
||||
|
||||
public void color(final float r, final float g, final float b) {
|
||||
if (!this.hasColor) {
|
||||
this.len += 3;
|
||||
}
|
||||
this.hasColor = true;
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
public void vertexUV(final float x, final float y, final float z, final float u, final float v) {
|
||||
this.tex(u, v);
|
||||
this.vertex(x, y, z);
|
||||
}
|
||||
|
||||
public void vertex(final float x, final float y, final float z) {
|
||||
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++] = x;
|
||||
this.array[this.p++] = y;
|
||||
this.array[this.p++] = z;
|
||||
++this.vertices;
|
||||
if (this.vertices % 4 == 0 && this.p >= 524288 - this.len * 4) {
|
||||
this.flush();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,259 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level.levelgen;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import com.mojang.minecraft.level.tile.Tile;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import java.util.Random;
|
||||
import com.mojang.minecraft.level.LevelLoaderListener;
|
||||
|
||||
public class LevelGen
|
||||
{
|
||||
private LevelLoaderListener levelLoaderListener;
|
||||
private int width;
|
||||
private int height;
|
||||
private int depth;
|
||||
private Random random;
|
||||
private byte[] blocks;
|
||||
private int[] coords;
|
||||
|
||||
public LevelGen(final LevelLoaderListener levelLoaderListener) {
|
||||
this.random = new Random();
|
||||
this.coords = new int[1048576];
|
||||
this.levelLoaderListener = levelLoaderListener;
|
||||
}
|
||||
|
||||
public boolean generateLevel(final Level level, final String userName, final int width, final int height, final int depth) {
|
||||
this.levelLoaderListener.beginLevelLoading("Generating level");
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.depth = depth;
|
||||
this.blocks = new byte[width * height * depth];
|
||||
this.levelLoaderListener.levelLoadUpdate("Raising..");
|
||||
final double[] heightMap = this.buildHeightmap(width, height);
|
||||
this.levelLoaderListener.levelLoadUpdate("Eroding..");
|
||||
this.buildBlocks(heightMap);
|
||||
this.levelLoaderListener.levelLoadUpdate("Carving..");
|
||||
this.carveTunnels();
|
||||
this.levelLoaderListener.levelLoadUpdate("Watering..");
|
||||
this.addWater();
|
||||
this.levelLoaderListener.levelLoadUpdate("Melting..");
|
||||
this.addLava();
|
||||
level.setData(width, depth, height, this.blocks);
|
||||
level.createTime = System.currentTimeMillis();
|
||||
level.creator = userName;
|
||||
level.name = "A Nice World";
|
||||
return true;
|
||||
}
|
||||
|
||||
private void buildBlocks(final double[] heightMap) {
|
||||
final int w = this.width;
|
||||
final int h = this.height;
|
||||
final int d = this.depth;
|
||||
for (int x = 0; x < w; ++x) {
|
||||
for (int y = 0; y < d; ++y) {
|
||||
for (int z = 0; z < h; ++z) {
|
||||
final int dh = d / 2;
|
||||
final int rh = d / 3;
|
||||
final int i = (y * this.height + z) * this.width + x;
|
||||
int id = 0;
|
||||
if (y == dh && y >= d / 2 - 1) {
|
||||
id = Tile.grass.id;
|
||||
}
|
||||
else if (y <= dh) {
|
||||
id = Tile.dirt.id;
|
||||
}
|
||||
if (y <= rh) {
|
||||
id = Tile.rock.id;
|
||||
}
|
||||
this.blocks[i] = (byte)id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private double[] buildHeightmap(final int width, final int height) {
|
||||
final double[] heightmap = new double[width * height];
|
||||
return heightmap;
|
||||
}
|
||||
|
||||
public void carveTunnels() {
|
||||
final int w = this.width;
|
||||
final int h = this.height;
|
||||
final int d = this.depth;
|
||||
for (int count = w * h * d / 256 / 64, i = 0; i < count; ++i) {
|
||||
float x = this.random.nextFloat() * w;
|
||||
float y = this.random.nextFloat() * d;
|
||||
float z = this.random.nextFloat() * h;
|
||||
final int length = (int)(this.random.nextFloat() + this.random.nextFloat() * 150.0f);
|
||||
float dir1 = (float)(this.random.nextFloat() * 3.141592653589793 * 2.0);
|
||||
float dira1 = 0.0f;
|
||||
float dir2 = (float)(this.random.nextFloat() * 3.141592653589793 * 2.0);
|
||||
float dira2 = 0.0f;
|
||||
for (int l = 0; l < length; ++l) {
|
||||
x += (float)(Math.sin(dir1) * Math.cos(dir2));
|
||||
z += (float)(Math.cos(dir1) * Math.cos(dir2));
|
||||
y += (float)Math.sin(dir2);
|
||||
dir1 += dira1 * 0.2f;
|
||||
dira1 *= 0.9f;
|
||||
dira1 += this.random.nextFloat() - this.random.nextFloat();
|
||||
dir2 += dira2 * 0.5f;
|
||||
dir2 *= 0.5f;
|
||||
dira2 *= 0.9f;
|
||||
dira2 += this.random.nextFloat() - this.random.nextFloat();
|
||||
final float size = (float)(Math.sin(l * 3.141592653589793 / length) * 2.5 + 1.0);
|
||||
for (int xx = (int)(x - size); xx <= (int)(x + size); ++xx) {
|
||||
for (int yy = (int)(y - size); yy <= (int)(y + size); ++yy) {
|
||||
for (int zz = (int)(z - size); zz <= (int)(z + size); ++zz) {
|
||||
final float xd = xx - x;
|
||||
final float yd = yy - y;
|
||||
final float zd = zz - z;
|
||||
final float dd = xd * xd + yd * yd * 2.0f + zd * zd;
|
||||
if (dd < size * size && xx >= 1 && yy >= 1 && zz >= 1 && xx < this.width - 1 && yy < this.depth - 1 && zz < this.height - 1) {
|
||||
final int ii = (yy * this.height + zz) * this.width + xx;
|
||||
if (this.blocks[ii] == Tile.rock.id) {
|
||||
this.blocks[ii] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addWater() {
|
||||
final long before = System.nanoTime();
|
||||
long tiles = 0L;
|
||||
final int source = 0;
|
||||
final int target = Tile.calmWater.id;
|
||||
for (int x = 0; x < this.width; ++x) {
|
||||
tiles += this.floodFillLiquid(x, this.depth / 2 - 1, 0, source, target);
|
||||
tiles += this.floodFillLiquid(x, this.depth / 2 - 1, this.height - 1, source, target);
|
||||
}
|
||||
for (int y = 0; y < this.height; ++y) {
|
||||
tiles += this.floodFillLiquid(0, this.depth / 2 - 1, y, source, target);
|
||||
tiles += this.floodFillLiquid(this.width - 1, this.depth / 2 - 1, y, source, target);
|
||||
}
|
||||
for (int i = 0; i < this.width * this.height / 5000; ++i) {
|
||||
final int x2 = this.random.nextInt(this.width);
|
||||
final int y2 = this.depth / 2 - 1;
|
||||
final int z = this.random.nextInt(this.height);
|
||||
if (this.blocks[(y2 * this.height + z) * this.width + x2] == 0) {
|
||||
tiles += this.floodFillLiquid(x2, y2, z, 0, target);
|
||||
}
|
||||
}
|
||||
final long after = System.nanoTime();
|
||||
System.out.println("Flood filled " + tiles + " tiles in " + (after - before) / 1000000.0 + " ms");
|
||||
}
|
||||
|
||||
public void addLava() {
|
||||
int lavaCount = 0;
|
||||
for (int i = 0; i < this.width * this.height * this.depth / 10000; ++i) {
|
||||
final int x = this.random.nextInt(this.width);
|
||||
final int y = this.random.nextInt(this.depth / 2);
|
||||
final int z = this.random.nextInt(this.height);
|
||||
if (this.blocks[(y * this.height + z) * this.width + x] == 0) {
|
||||
++lavaCount;
|
||||
this.floodFillLiquid(x, y, z, 0, Tile.calmLava.id);
|
||||
}
|
||||
}
|
||||
System.out.println("LavaCount: " + lavaCount);
|
||||
}
|
||||
|
||||
public long floodFillLiquid(final int x, final int y, final int z, final int source, final int tt) {
|
||||
final byte target = (byte)tt;
|
||||
final ArrayList<int[]> coordBuffer = new ArrayList<int[]>();
|
||||
int p = 0;
|
||||
int wBits = 1;
|
||||
int hBits = 1;
|
||||
while (1 << wBits < this.width) {
|
||||
++wBits;
|
||||
}
|
||||
while (1 << hBits < this.height) {
|
||||
++hBits;
|
||||
}
|
||||
final int hMask = this.height - 1;
|
||||
final int wMask = this.width - 1;
|
||||
this.coords[p++] = ((y << hBits) + z << wBits) + x;
|
||||
long tiles = 0L;
|
||||
final int upStep = this.width * this.height;
|
||||
while (p > 0) {
|
||||
int cl = this.coords[--p];
|
||||
if (p == 0 && coordBuffer.size() > 0) {
|
||||
System.out.println("IT HAPPENED!");
|
||||
this.coords = coordBuffer.remove(coordBuffer.size() - 1);
|
||||
p = this.coords.length;
|
||||
}
|
||||
final int z2 = cl >> wBits & hMask;
|
||||
final int y2 = cl >> wBits + hBits;
|
||||
int x3;
|
||||
int x2;
|
||||
for (x2 = (x3 = (cl & wMask)); x2 > 0; --x2, --cl) {
|
||||
if (this.blocks[cl - 1] != source) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (x3 < this.width && this.blocks[cl + x3 - x2] == source) {
|
||||
++x3;
|
||||
}
|
||||
final int z3 = cl >> wBits & hMask;
|
||||
final int y3 = cl >> wBits + hBits;
|
||||
if (z3 != z2 || y3 != y2) {
|
||||
System.out.println("hoooly fuck");
|
||||
}
|
||||
boolean lastNorth = false;
|
||||
boolean lastSouth = false;
|
||||
boolean lastBelow = false;
|
||||
tiles += x3 - x2;
|
||||
for (int xx = x2; xx < x3; ++xx) {
|
||||
this.blocks[cl] = target;
|
||||
if (z2 > 0) {
|
||||
final boolean north = this.blocks[cl - this.width] == source;
|
||||
if (north && !lastNorth) {
|
||||
if (p == this.coords.length) {
|
||||
coordBuffer.add(this.coords);
|
||||
this.coords = new int[1048576];
|
||||
p = 0;
|
||||
}
|
||||
this.coords[p++] = cl - this.width;
|
||||
}
|
||||
lastNorth = north;
|
||||
}
|
||||
if (z2 < this.height - 1) {
|
||||
final boolean south = this.blocks[cl + this.width] == source;
|
||||
if (south && !lastSouth) {
|
||||
if (p == this.coords.length) {
|
||||
coordBuffer.add(this.coords);
|
||||
this.coords = new int[1048576];
|
||||
p = 0;
|
||||
}
|
||||
this.coords[p++] = cl + this.width;
|
||||
}
|
||||
lastSouth = south;
|
||||
}
|
||||
if (y2 > 0) {
|
||||
final int belowId = this.blocks[cl - upStep];
|
||||
if ((target == Tile.lava.id || target == Tile.calmLava.id) && (belowId == Tile.water.id || belowId == Tile.calmWater.id)) {
|
||||
this.blocks[cl - upStep] = (byte)Tile.rock.id;
|
||||
}
|
||||
final boolean below = belowId == source;
|
||||
if (below && !lastBelow) {
|
||||
if (p == this.coords.length) {
|
||||
coordBuffer.add(this.coords);
|
||||
this.coords = new int[1048576];
|
||||
p = 0;
|
||||
}
|
||||
this.coords[p++] = cl - upStep;
|
||||
}
|
||||
lastBelow = below;
|
||||
}
|
||||
++cl;
|
||||
}
|
||||
}
|
||||
return tiles;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level.levelgen.synth;
|
||||
|
||||
public class Distort extends Synth
|
||||
{
|
||||
private Synth source;
|
||||
private Synth distort;
|
||||
|
||||
public Distort(final Synth source, final Synth distort) {
|
||||
this.source = source;
|
||||
this.distort = distort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getValue(final double x, final double y) {
|
||||
return this.source.getValue(x + this.distort.getValue(x, y), y);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level.levelgen.synth;
|
||||
|
||||
public class Emboss extends Synth
|
||||
{
|
||||
private Synth synth;
|
||||
|
||||
public Emboss(final Synth synth) {
|
||||
this.synth = synth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getValue(final double x, final double y) {
|
||||
return this.synth.getValue(x, y) - this.synth.getValue(x + 1.0, y + 1.0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level.levelgen.synth;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ImprovedNoise extends Synth
|
||||
{
|
||||
private int[] p;
|
||||
public double scale;
|
||||
|
||||
public ImprovedNoise() {
|
||||
this(new Random());
|
||||
}
|
||||
|
||||
public ImprovedNoise(final Random random) {
|
||||
this.p = new int[512];
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
this.p[i] = i;
|
||||
}
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
final int j = random.nextInt(256 - i) + i;
|
||||
final int tmp = this.p[i];
|
||||
this.p[i] = this.p[j];
|
||||
this.p[j] = tmp;
|
||||
this.p[i + 256] = this.p[i];
|
||||
}
|
||||
}
|
||||
|
||||
public double noise(double x, double y, double z) {
|
||||
final int X = (int)Math.floor(x) & 0xFF;
|
||||
final int Y = (int)Math.floor(y) & 0xFF;
|
||||
final int Z = (int)Math.floor(z) & 0xFF;
|
||||
x -= Math.floor(x);
|
||||
y -= Math.floor(y);
|
||||
z -= Math.floor(z);
|
||||
final double u = this.fade(x);
|
||||
final double v = this.fade(y);
|
||||
final double w = this.fade(z);
|
||||
final int A = this.p[X] + Y;
|
||||
final int AA = this.p[A] + Z;
|
||||
final int AB = this.p[A + 1] + Z;
|
||||
final int B = this.p[X + 1] + Y;
|
||||
final int BA = this.p[B] + Z;
|
||||
final int BB = this.p[B + 1] + Z;
|
||||
return this.lerp(w, this.lerp(v, this.lerp(u, this.grad(this.p[AA], x, y, z), this.grad(this.p[BA], x - 1.0, y, z)), this.lerp(u, this.grad(this.p[AB], x, y - 1.0, z), this.grad(this.p[BB], x - 1.0, y - 1.0, z))), this.lerp(v, this.lerp(u, this.grad(this.p[AA + 1], x, y, z - 1.0), this.grad(this.p[BA + 1], x - 1.0, y, z - 1.0)), this.lerp(u, this.grad(this.p[AB + 1], x, y - 1.0, z - 1.0), this.grad(this.p[BB + 1], x - 1.0, y - 1.0, z - 1.0))));
|
||||
}
|
||||
|
||||
public double fade(final double t) {
|
||||
return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
|
||||
}
|
||||
|
||||
public double lerp(final double t, final double a, final double b) {
|
||||
return a + t * (b - a);
|
||||
}
|
||||
|
||||
public double grad(final int hash, final double x, final double y, final double z) {
|
||||
final int h = hash & 0xF;
|
||||
final double u = (h < 8) ? x : y;
|
||||
final double v = (h < 4) ? y : ((h == 12 || h == 14) ? x : z);
|
||||
return (((h & 0x1) == 0x0) ? u : (-u)) + (((h & 0x2) == 0x0) ? v : (-v));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getValue(final double x, final double y) {
|
||||
return this.noise(x, y, 0.0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level.levelgen.synth;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class PerlinNoise extends Synth
|
||||
{
|
||||
private ImprovedNoise[] noiseLevels;
|
||||
private int levels;
|
||||
|
||||
public PerlinNoise(final int levels) {
|
||||
this(new Random(), levels);
|
||||
}
|
||||
|
||||
public PerlinNoise(final Random random, final int levels) {
|
||||
this.levels = levels;
|
||||
this.noiseLevels = new ImprovedNoise[levels];
|
||||
for (int i = 0; i < levels; ++i) {
|
||||
this.noiseLevels[i] = new ImprovedNoise(random);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getValue(final double x, final double y) {
|
||||
double value = 0.0;
|
||||
double pow = 1.0;
|
||||
for (int i = 0; i < this.levels; ++i) {
|
||||
value += this.noiseLevels[i].getValue(x / pow, y / pow) * pow;
|
||||
pow *= 2.0;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level.levelgen.synth;
|
||||
|
||||
public class Rotate extends Synth
|
||||
{
|
||||
private Synth synth;
|
||||
private double sin;
|
||||
private double cos;
|
||||
|
||||
public Rotate(final Synth synth, final double angle) {
|
||||
this.synth = synth;
|
||||
this.sin = Math.sin(angle);
|
||||
this.cos = Math.cos(angle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getValue(final double x, final double y) {
|
||||
return this.synth.getValue(x * this.cos + y * this.sin, y * this.cos - x * this.sin);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level.levelgen.synth;
|
||||
|
||||
public class Scale extends Synth
|
||||
{
|
||||
private Synth synth;
|
||||
private double xScale;
|
||||
private double yScale;
|
||||
|
||||
public Scale(final Synth synth, final double xScale, final double yScale) {
|
||||
this.synth = synth;
|
||||
this.xScale = 1.0 / xScale;
|
||||
this.yScale = 1.0 / yScale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getValue(final double x, final double y) {
|
||||
return this.synth.getValue(x * this.xScale, y * this.yScale);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level.levelgen.synth;
|
||||
|
||||
public abstract class Synth
|
||||
{
|
||||
public abstract double getValue(final double p0, final double p1);
|
||||
|
||||
public double[] create(final int width, final int height) {
|
||||
final double[] result = new double[width * height];
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
result[x + y * width] = this.getValue(x, y);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
import com.mojang.minecraft.renderer.Tesselator;
|
||||
import java.util.Random;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
|
||||
public class Bush extends Tile
|
||||
{
|
||||
protected Bush(final int id) {
|
||||
super(id);
|
||||
this.tex = 15;
|
||||
this.setTicking(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(final Level level, final int x, final int y, final int z, final Random random) {
|
||||
final int below = level.getTile(x, y - 1, z);
|
||||
if (!level.isLit(x, y, z) || (below != Tile.dirt.id && below != Tile.grass.id)) {
|
||||
level.setTile(x, y, z, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final Tesselator t, final Level level, final int layer, final int x, final int y, final int z) {
|
||||
if (level.isLit(x, y, z) ^ layer != 1) {
|
||||
return;
|
||||
}
|
||||
final int tex = this.getTexture(15);
|
||||
final float u0 = tex % 16 / 16.0f;
|
||||
final float u2 = u0 + 0.0624375f;
|
||||
final float v0 = tex / 16 / 16.0f;
|
||||
final float v2 = v0 + 0.0624375f;
|
||||
final int rots = 2;
|
||||
t.color(255, 255, 255);
|
||||
for (int r = 0; r < rots; ++r) {
|
||||
final float xa = (float)(Math.sin(r * 3.141592653589793 / rots + 0.7853981633974483) * 0.5);
|
||||
final float za = (float)(Math.cos(r * 3.141592653589793 / rots + 0.7853981633974483) * 0.5);
|
||||
final float x2 = x + 0.5f - xa;
|
||||
final float x3 = x + 0.5f + xa;
|
||||
final float y2 = y + 0.0f;
|
||||
final float y3 = y + 1.0f;
|
||||
final float z2 = z + 0.5f - za;
|
||||
final float z3 = z + 0.5f + za;
|
||||
t.vertexUV(x2, y3, z2, u2, v0);
|
||||
t.vertexUV(x3, y3, z3, u0, v0);
|
||||
t.vertexUV(x3, y2, z3, u0, v2);
|
||||
t.vertexUV(x2, y2, z2, u2, v2);
|
||||
t.vertexUV(x3, y3, z3, u2, v0);
|
||||
t.vertexUV(x2, y3, z2, u0, v0);
|
||||
t.vertexUV(x2, y2, z2, u0, v2);
|
||||
t.vertexUV(x3, y2, z3, u2, v2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AABB getAABB(final int x, final int y, final int z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean blocksLight() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolid() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
import java.util.Random;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
|
||||
public class CalmLiquidTile extends LiquidTile
|
||||
{
|
||||
protected CalmLiquidTile(final int id, final int liquidType) {
|
||||
super(id, liquidType);
|
||||
this.tileId = id - 1;
|
||||
this.calmTileId = id;
|
||||
this.setTicking(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(final Level level, final int x, final int y, final int z, final Random random) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(final Level level, final int x, final int y, final int z, final int type) {
|
||||
boolean hasAirNeighbor = false;
|
||||
if (level.getTile(x - 1, y, z) == 0) {
|
||||
hasAirNeighbor = true;
|
||||
}
|
||||
if (level.getTile(x + 1, y, z) == 0) {
|
||||
hasAirNeighbor = true;
|
||||
}
|
||||
if (level.getTile(x, y, z - 1) == 0) {
|
||||
hasAirNeighbor = true;
|
||||
}
|
||||
if (level.getTile(x, y, z + 1) == 0) {
|
||||
hasAirNeighbor = true;
|
||||
}
|
||||
if (level.getTile(x, y - 1, z) == 0) {
|
||||
hasAirNeighbor = true;
|
||||
}
|
||||
if (hasAirNeighbor) {
|
||||
level.setTileNoUpdate(x, y, z, this.tileId);
|
||||
}
|
||||
if (this.liquidType == 1 && type == Tile.lava.id) {
|
||||
level.setTileNoUpdate(x, y, z, Tile.rock.id);
|
||||
}
|
||||
if (this.liquidType == 2 && type == Tile.water.id) {
|
||||
level.setTileNoUpdate(x, y, z, Tile.rock.id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
public class DirtTile extends Tile
|
||||
{
|
||||
protected DirtTile(final int id, final int tex) {
|
||||
super(id, tex);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
import java.util.Random;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
|
||||
public class GrassTile extends Tile
|
||||
{
|
||||
protected GrassTile(final int id) {
|
||||
super(id);
|
||||
this.tex = 3;
|
||||
this.setTicking(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getTexture(final int face) {
|
||||
if (face == 1) {
|
||||
return 0;
|
||||
}
|
||||
if (face == 0) {
|
||||
return 2;
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(final Level level, final int x, final int y, final int z, final Random random) {
|
||||
if (random.nextInt(4) != 0) {
|
||||
return;
|
||||
}
|
||||
if (!level.isLit(x, y + 1, z)) {
|
||||
level.setTile(x, y, z, Tile.dirt.id);
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
final int xt = x + random.nextInt(3) - 1;
|
||||
final int yt = y + random.nextInt(5) - 3;
|
||||
final int zt = z + random.nextInt(3) - 1;
|
||||
if (level.getTile(xt, yt, zt) == Tile.dirt.id && level.isLit(xt, yt + 1, zt)) {
|
||||
level.setTile(xt, yt, zt, Tile.grass.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
import com.mojang.minecraft.renderer.Tesselator;
|
||||
import java.util.Random;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
|
||||
public class LiquidTile extends Tile
|
||||
{
|
||||
protected int liquidType;
|
||||
protected int calmTileId;
|
||||
protected int tileId;
|
||||
protected int spreadSpeed;
|
||||
|
||||
protected LiquidTile(final int id, final int liquidType) {
|
||||
super(id);
|
||||
this.spreadSpeed = 1;
|
||||
this.liquidType = liquidType;
|
||||
this.tex = 14;
|
||||
if (liquidType == 2) {
|
||||
this.tex = 30;
|
||||
}
|
||||
if (liquidType == 1) {
|
||||
this.spreadSpeed = 8;
|
||||
}
|
||||
if (liquidType == 2) {
|
||||
this.spreadSpeed = 2;
|
||||
}
|
||||
this.tileId = id;
|
||||
this.calmTileId = id + 1;
|
||||
final float dd = 0.1f;
|
||||
this.setShape(0.0f, 0.0f - dd, 0.0f, 1.0f, 1.0f - dd, 1.0f);
|
||||
this.setTicking(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(final Level level, final int x, final int y, final int z, final Random random) {
|
||||
this.updateWater(level, x, y, z, 0);
|
||||
}
|
||||
|
||||
public boolean updateWater(final Level level, final int x, int y, final int z, final int depth) {
|
||||
boolean hasChanged = false;
|
||||
while (level.getTile(x, --y, z) == 0) {
|
||||
final boolean change = level.setTile(x, y, z, this.tileId);
|
||||
if (change) {
|
||||
hasChanged = true;
|
||||
}
|
||||
if (!change) {
|
||||
break;
|
||||
}
|
||||
if (this.liquidType == 2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
++y;
|
||||
if (this.liquidType == 1 || !hasChanged) {
|
||||
hasChanged |= this.checkWater(level, x - 1, y, z, depth);
|
||||
hasChanged |= this.checkWater(level, x + 1, y, z, depth);
|
||||
hasChanged |= this.checkWater(level, x, y, z - 1, depth);
|
||||
hasChanged |= this.checkWater(level, x, y, z + 1, depth);
|
||||
}
|
||||
if (!hasChanged) {
|
||||
level.setTileNoUpdate(x, y, z, this.calmTileId);
|
||||
}
|
||||
return hasChanged;
|
||||
}
|
||||
|
||||
private boolean checkWater(final Level level, final int x, final int y, final int z, final int depth) {
|
||||
boolean hasChanged = false;
|
||||
final int type = level.getTile(x, y, z);
|
||||
if (type == 0) {
|
||||
final boolean changed = level.setTile(x, y, z, this.tileId);
|
||||
if (changed && depth < this.spreadSpeed) {
|
||||
hasChanged |= this.updateWater(level, x, y, z, depth + 1);
|
||||
}
|
||||
}
|
||||
return hasChanged;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldRenderFace(final Level level, final int x, final int y, final int z, final int layer, final int face) {
|
||||
if (x < 0 || y < 0 || z < 0 || x >= level.width || z >= level.height) {
|
||||
return false;
|
||||
}
|
||||
if (layer != 2 && this.liquidType == 1) {
|
||||
return false;
|
||||
}
|
||||
final int id = level.getTile(x, y, z);
|
||||
return id != this.tileId && id != this.calmTileId && super.shouldRenderFace(level, x, y, z, -1, face);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFace(final Tesselator t, final int x, final int y, final int z, final int face) {
|
||||
super.renderFace(t, x, y, z, face);
|
||||
super.renderBackFace(t, x, y, z, face);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mayPick() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AABB getAABB(final int x, final int y, final int z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean blocksLight() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolid() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLiquidType() {
|
||||
return this.liquidType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(final Level level, final int x, final int y, final int z, final int type) {
|
||||
if (this.liquidType == 1 && (type == Tile.lava.id || type == Tile.calmLava.id)) {
|
||||
level.setTileNoUpdate(x, y, z, Tile.rock.id);
|
||||
}
|
||||
if (this.liquidType == 2 && (type == Tile.water.id || type == Tile.calmWater.id)) {
|
||||
level.setTileNoUpdate(x, y, z, Tile.rock.id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,323 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
import com.mojang.minecraft.particle.Particle;
|
||||
import com.mojang.minecraft.particle.ParticleEngine;
|
||||
import java.util.Random;
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
import com.mojang.minecraft.Player;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.renderer.Tesselator;
|
||||
|
||||
public class Tile
|
||||
{
|
||||
public static final int NOT_LIQUID = 0;
|
||||
public static final int LIQUID_WATER = 1;
|
||||
public static final int LIQUID_LAVA = 2;
|
||||
public static final Tile[] tiles;
|
||||
public static final boolean[] shouldTick;
|
||||
public static final Tile empty;
|
||||
public static final Tile rock;
|
||||
public static final Tile grass;
|
||||
public static final Tile dirt;
|
||||
public static final Tile stoneBrick;
|
||||
public static final Tile wood;
|
||||
public static final Tile bush;
|
||||
public static final Tile unbreakable;
|
||||
public static final Tile water;
|
||||
public static final Tile calmWater;
|
||||
public static final Tile lava;
|
||||
public static final Tile calmLava;
|
||||
public int tex;
|
||||
public final int id;
|
||||
protected float xx0;
|
||||
protected float yy0;
|
||||
protected float zz0;
|
||||
protected float xx1;
|
||||
protected float yy1;
|
||||
protected float zz1;
|
||||
|
||||
static {
|
||||
tiles = new Tile[256];
|
||||
shouldTick = new boolean[256];
|
||||
empty = null;
|
||||
rock = new Tile(1, 1);
|
||||
grass = new GrassTile(2);
|
||||
dirt = new DirtTile(3, 2);
|
||||
stoneBrick = new Tile(4, 16);
|
||||
wood = new Tile(5, 4);
|
||||
bush = new Bush(6);
|
||||
unbreakable = new Tile(7, 17);
|
||||
water = new LiquidTile(8, 1);
|
||||
calmWater = new CalmLiquidTile(9, 1);
|
||||
lava = new LiquidTile(10, 2);
|
||||
calmLava = new CalmLiquidTile(11, 2);
|
||||
}
|
||||
|
||||
protected Tile(final int id) {
|
||||
Tile.tiles[id] = this;
|
||||
this.id = id;
|
||||
this.setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
protected void setTicking(final boolean tick) {
|
||||
Tile.shouldTick[this.id] = tick;
|
||||
}
|
||||
|
||||
protected void setShape(final float x0, final float y0, final float z0, final float x1, final float y1, final float z1) {
|
||||
this.xx0 = x0;
|
||||
this.yy0 = y0;
|
||||
this.zz0 = z0;
|
||||
this.xx1 = x1;
|
||||
this.yy1 = y1;
|
||||
this.zz1 = z1;
|
||||
}
|
||||
|
||||
protected Tile(final int id, final int tex) {
|
||||
this(id);
|
||||
this.tex = tex;
|
||||
}
|
||||
|
||||
public void render(final Tesselator t, final Level level, final int layer, final int x, final int y, final int z) {
|
||||
final byte c1 = -1;
|
||||
final byte c2 = -52;
|
||||
final byte c3 = -103;
|
||||
if (this.shouldRenderFace(level, x, y - 1, z, layer, 0)) {
|
||||
t.color(c1, c1, c1);
|
||||
this.renderFace(t, x, y, z, 0);
|
||||
}
|
||||
if (this.shouldRenderFace(level, x, y + 1, z, layer, 1)) {
|
||||
t.color(c1, c1, c1);
|
||||
this.renderFace(t, x, y, z, 1);
|
||||
}
|
||||
if (this.shouldRenderFace(level, x, y, z - 1, layer, 2)) {
|
||||
t.color(c2, c2, c2);
|
||||
this.renderFace(t, x, y, z, 2);
|
||||
}
|
||||
if (this.shouldRenderFace(level, x, y, z + 1, layer, 3)) {
|
||||
t.color(c2, c2, c2);
|
||||
this.renderFace(t, x, y, z, 3);
|
||||
}
|
||||
if (this.shouldRenderFace(level, x - 1, y, z, layer, 4)) {
|
||||
t.color(c3, c3, c3);
|
||||
this.renderFace(t, x, y, z, 4);
|
||||
}
|
||||
if (this.shouldRenderFace(level, x + 1, y, z, layer, 5)) {
|
||||
t.color(c3, c3, c3);
|
||||
this.renderFace(t, x, y, z, 5);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean shouldRenderFace(final Level level, final int x, final int y, final int z, final int layer, final int face) {
|
||||
boolean layerOk = true;
|
||||
if (layer == 2) {
|
||||
return false;
|
||||
}
|
||||
if (layer >= 0) {
|
||||
layerOk = (level.isLit(x, y, z) ^ layer == 1);
|
||||
}
|
||||
return !level.isSolidTile(x, y, z) && layerOk;
|
||||
}
|
||||
|
||||
protected int getTexture(final int face) {
|
||||
return this.tex;
|
||||
}
|
||||
|
||||
public void renderFace(final Tesselator t, final int x, final int y, final int z, final int face) {
|
||||
final int tex = this.getTexture(face);
|
||||
final int xt = tex % 16 * 16;
|
||||
final int yt = tex / 16 * 16;
|
||||
final float u0 = xt / 256.0f;
|
||||
final float u2 = (xt + 15.99f) / 256.0f;
|
||||
final float v0 = yt / 256.0f;
|
||||
final float v2 = (yt + 15.99f) / 256.0f;
|
||||
final float x2 = x + this.xx0;
|
||||
final float x3 = x + this.xx1;
|
||||
final float y2 = y + this.yy0;
|
||||
final float y3 = y + this.yy1;
|
||||
final float z2 = z + this.zz0;
|
||||
final float z3 = z + this.zz1;
|
||||
if (face == 0) {
|
||||
t.vertexUV(x2, y2, z3, u0, v2);
|
||||
t.vertexUV(x2, y2, z2, u0, v0);
|
||||
t.vertexUV(x3, y2, z2, u2, v0);
|
||||
t.vertexUV(x3, y2, z3, u2, v2);
|
||||
return;
|
||||
}
|
||||
if (face == 1) {
|
||||
t.vertexUV(x3, y3, z3, u2, v2);
|
||||
t.vertexUV(x3, y3, z2, u2, v0);
|
||||
t.vertexUV(x2, y3, z2, u0, v0);
|
||||
t.vertexUV(x2, y3, z3, u0, v2);
|
||||
return;
|
||||
}
|
||||
if (face == 2) {
|
||||
t.vertexUV(x2, y3, z2, u2, v0);
|
||||
t.vertexUV(x3, y3, z2, u0, v0);
|
||||
t.vertexUV(x3, y2, z2, u0, v2);
|
||||
t.vertexUV(x2, y2, z2, u2, v2);
|
||||
return;
|
||||
}
|
||||
if (face == 3) {
|
||||
t.vertexUV(x2, y3, z3, u0, v0);
|
||||
t.vertexUV(x2, y2, z3, u0, v2);
|
||||
t.vertexUV(x3, y2, z3, u2, v2);
|
||||
t.vertexUV(x3, y3, z3, u2, v0);
|
||||
return;
|
||||
}
|
||||
if (face == 4) {
|
||||
t.vertexUV(x2, y3, z3, u2, v0);
|
||||
t.vertexUV(x2, y3, z2, u0, v0);
|
||||
t.vertexUV(x2, y2, z2, u0, v2);
|
||||
t.vertexUV(x2, y2, z3, u2, v2);
|
||||
return;
|
||||
}
|
||||
if (face == 5) {
|
||||
t.vertexUV(x3, y2, z3, u0, v2);
|
||||
t.vertexUV(x3, y2, z2, u2, v2);
|
||||
t.vertexUV(x3, y3, z2, u2, v0);
|
||||
t.vertexUV(x3, y3, z3, u0, v0);
|
||||
}
|
||||
}
|
||||
|
||||
public void renderBackFace(final Tesselator t, final int x, final int y, final int z, final int face) {
|
||||
final int tex = this.getTexture(face);
|
||||
final float u0 = tex % 16 / 16.0f;
|
||||
final float u2 = u0 + 0.0624375f;
|
||||
final float v0 = tex / 16 / 16.0f;
|
||||
final float v2 = v0 + 0.0624375f;
|
||||
final float x2 = x + this.xx0;
|
||||
final float x3 = x + this.xx1;
|
||||
final float y2 = y + this.yy0;
|
||||
final float y3 = y + this.yy1;
|
||||
final float z2 = z + this.zz0;
|
||||
final float z3 = z + this.zz1;
|
||||
if (face == 0) {
|
||||
t.vertexUV(x3, y2, z3, u2, v2);
|
||||
t.vertexUV(x3, y2, z2, u2, v0);
|
||||
t.vertexUV(x2, y2, z2, u0, v0);
|
||||
t.vertexUV(x2, y2, z3, u0, v2);
|
||||
}
|
||||
if (face == 1) {
|
||||
t.vertexUV(x2, y3, z3, u0, v2);
|
||||
t.vertexUV(x2, y3, z2, u0, v0);
|
||||
t.vertexUV(x3, y3, z2, u2, v0);
|
||||
t.vertexUV(x3, y3, z3, u2, v2);
|
||||
}
|
||||
if (face == 2) {
|
||||
t.vertexUV(x2, y2, z2, u2, v2);
|
||||
t.vertexUV(x3, y2, z2, u0, v2);
|
||||
t.vertexUV(x3, y3, z2, u0, v0);
|
||||
t.vertexUV(x2, y3, z2, u2, v0);
|
||||
}
|
||||
if (face == 3) {
|
||||
t.vertexUV(x3, y3, z3, u2, v0);
|
||||
t.vertexUV(x3, y2, z3, u2, v2);
|
||||
t.vertexUV(x2, y2, z3, u0, v2);
|
||||
t.vertexUV(x2, y3, z3, u0, v0);
|
||||
}
|
||||
if (face == 4) {
|
||||
t.vertexUV(x2, y2, z3, u2, v2);
|
||||
t.vertexUV(x2, y2, z2, u0, v2);
|
||||
t.vertexUV(x2, y3, z2, u0, v0);
|
||||
t.vertexUV(x2, y3, z3, u2, v0);
|
||||
}
|
||||
if (face == 5) {
|
||||
t.vertexUV(x3, y3, z3, u0, v0);
|
||||
t.vertexUV(x3, y3, z2, u2, v0);
|
||||
t.vertexUV(x3, y2, z2, u2, v2);
|
||||
t.vertexUV(x3, y2, z3, u0, v2);
|
||||
}
|
||||
}
|
||||
|
||||
public void renderFaceNoTexture(final Player player, final Tesselator t, final int x, final int y, final int z, final int face) {
|
||||
final float x2 = x + 0.0f;
|
||||
final float x3 = x + 1.0f;
|
||||
final float y2 = y + 0.0f;
|
||||
final float y3 = y + 1.0f;
|
||||
final float z2 = z + 0.0f;
|
||||
final float z3 = z + 1.0f;
|
||||
if (face == 0 && y > player.y) {
|
||||
t.vertex(x2, y2, z3);
|
||||
t.vertex(x2, y2, z2);
|
||||
t.vertex(x3, y2, z2);
|
||||
t.vertex(x3, y2, z3);
|
||||
}
|
||||
if (face == 1 && y < player.y) {
|
||||
t.vertex(x3, y3, z3);
|
||||
t.vertex(x3, y3, z2);
|
||||
t.vertex(x2, y3, z2);
|
||||
t.vertex(x2, y3, z3);
|
||||
}
|
||||
if (face == 2 && z > player.z) {
|
||||
t.vertex(x2, y3, z2);
|
||||
t.vertex(x3, y3, z2);
|
||||
t.vertex(x3, y2, z2);
|
||||
t.vertex(x2, y2, z2);
|
||||
}
|
||||
if (face == 3 && z < player.z) {
|
||||
t.vertex(x2, y3, z3);
|
||||
t.vertex(x2, y2, z3);
|
||||
t.vertex(x3, y2, z3);
|
||||
t.vertex(x3, y3, z3);
|
||||
}
|
||||
if (face == 4 && x > player.x) {
|
||||
t.vertex(x2, y3, z3);
|
||||
t.vertex(x2, y3, z2);
|
||||
t.vertex(x2, y2, z2);
|
||||
t.vertex(x2, y2, z3);
|
||||
}
|
||||
if (face == 5 && x < player.x) {
|
||||
t.vertex(x3, y2, z3);
|
||||
t.vertex(x3, y2, z2);
|
||||
t.vertex(x3, y3, z2);
|
||||
t.vertex(x3, y3, z3);
|
||||
}
|
||||
}
|
||||
|
||||
public final AABB getTileAABB(final int x, final int y, final int z) {
|
||||
return new AABB((float)x, (float)y, (float)z, (float)(x + 1), (float)(y + 1), (float)(z + 1));
|
||||
}
|
||||
|
||||
public AABB getAABB(final int x, final int y, final int z) {
|
||||
return new AABB((float)x, (float)y, (float)z, (float)(x + 1), (float)(y + 1), (float)(z + 1));
|
||||
}
|
||||
|
||||
public boolean blocksLight() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isSolid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean mayPick() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void tick(final Level level, final int x, final int y, final int z, final Random random) {
|
||||
}
|
||||
|
||||
public void destroy(final Level level, final int x, final int y, final int z, final ParticleEngine particleEngine) {
|
||||
for (int SD = 4, xx = 0; xx < SD; ++xx) {
|
||||
for (int yy = 0; yy < SD; ++yy) {
|
||||
for (int zz = 0; zz < SD; ++zz) {
|
||||
final float xp = x + (xx + 0.5f) / SD;
|
||||
final float yp = y + (yy + 0.5f) / SD;
|
||||
final float zp = z + (zz + 0.5f) / SD;
|
||||
particleEngine.add(new Particle(level, xp, yp, zp, xp - x - 0.5f, yp - y - 0.5f, zp - z - 0.5f, this.tex));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getLiquidType() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void neighborChanged(final Level level, final int x, final int y, final int z, final int type) {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.particle;
|
||||
|
||||
import com.mojang.minecraft.renderer.Tesselator;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.Entity;
|
||||
|
||||
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;
|
||||
private int lifetime;
|
||||
private float size;
|
||||
|
||||
public Particle(final Level level, final float x, final float y, final float z, final float xa, final float ya, final float za, final int tex) {
|
||||
super(level);
|
||||
this.age = 0;
|
||||
this.lifetime = 0;
|
||||
this.tex = tex;
|
||||
this.setSize(0.2f, 0.2f);
|
||||
this.heightOffset = this.bbHeight / 2.0f;
|
||||
this.setPos(x, y, z);
|
||||
this.xd = xa + (float)(Math.random() * 2.0 - 1.0) * 0.4f;
|
||||
this.yd = ya + (float)(Math.random() * 2.0 - 1.0) * 0.4f;
|
||||
this.zd = za + (float)(Math.random() * 2.0 - 1.0) * 0.4f;
|
||||
final float speed = (float)(Math.random() + Math.random() + 1.0) * 0.15f;
|
||||
final float dd = (float)Math.sqrt(this.xd * this.xd + this.yd * this.yd + this.zd * this.zd);
|
||||
this.xd = this.xd / dd * speed * 0.4f;
|
||||
this.yd = this.yd / dd * speed * 0.4f + 0.1f;
|
||||
this.zd = this.zd / dd * speed * 0.4f;
|
||||
this.uo = (float)Math.random() * 3.0f;
|
||||
this.vo = (float)Math.random() * 3.0f;
|
||||
this.size = (float)(Math.random() * 0.5 + 0.5);
|
||||
this.lifetime = (int)(4.0 / (Math.random() * 0.9 + 0.1));
|
||||
this.age = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
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)0.04;
|
||||
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(final Tesselator t, final float a, final float xa, final float ya, final float za, final float xa2, final float za2) {
|
||||
final float u0 = (this.tex % 16 + this.uo / 4.0f) / 16.0f;
|
||||
final float u2 = u0 + 0.015609375f;
|
||||
final float v0 = (this.tex / 16 + this.vo / 4.0f) / 16.0f;
|
||||
final float v2 = v0 + 0.015609375f;
|
||||
final float r = 0.1f * this.size;
|
||||
final float x = this.xo + (this.x - this.xo) * a;
|
||||
final float y = this.yo + (this.y - this.yo) * a;
|
||||
final float z = this.zo + (this.z - this.zo) * a;
|
||||
t.vertexUV(x - xa * r - xa2 * r, y - ya * r, z - za * r - za2 * r, u0, v2);
|
||||
t.vertexUV(x - xa * r + xa2 * r, y + ya * r, z - za * r + za2 * r, u0, v0);
|
||||
t.vertexUV(x + xa * r + xa2 * r, y + ya * r, z + za * r + za2 * r, u2, v0);
|
||||
t.vertexUV(x + xa * r - xa2 * r, y - ya * r, z + za * r - za2 * r, u2, v2);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.particle;
|
||||
|
||||
import com.mojang.minecraft.renderer.Tesselator;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import com.mojang.minecraft.Player;
|
||||
import java.util.ArrayList;
|
||||
import com.mojang.minecraft.renderer.Textures;
|
||||
import java.util.List;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
|
||||
public class ParticleEngine
|
||||
{
|
||||
protected Level level;
|
||||
private List<Particle> particles;
|
||||
private Textures textures;
|
||||
|
||||
public ParticleEngine(final Level level, final Textures textures) {
|
||||
this.particles = new ArrayList<Particle>();
|
||||
this.level = level;
|
||||
this.textures = textures;
|
||||
}
|
||||
|
||||
public void add(final Particle p) {
|
||||
this.particles.add(p);
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
for (int i = 0; i < this.particles.size(); ++i) {
|
||||
final Particle p = this.particles.get(i);
|
||||
p.tick();
|
||||
if (p.removed) {
|
||||
this.particles.remove(i--);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void render(final Player player, final float a, final int layer) {
|
||||
if (this.particles.size() == 0) {
|
||||
return;
|
||||
}
|
||||
GL11.glEnable(3553);
|
||||
final int id = this.textures.loadTexture("/terrain.png", 9728);
|
||||
GL11.glBindTexture(3553, id);
|
||||
final float xa = -(float)Math.cos(player.yRot * 3.141592653589793 / 180.0);
|
||||
final float za = -(float)Math.sin(player.yRot * 3.141592653589793 / 180.0);
|
||||
final float xa2 = -za * (float)Math.sin(player.xRot * 3.141592653589793 / 180.0);
|
||||
final float za2 = xa * (float)Math.sin(player.xRot * 3.141592653589793 / 180.0);
|
||||
final float ya = (float)Math.cos(player.xRot * 3.141592653589793 / 180.0);
|
||||
final Tesselator t = Tesselator.instance;
|
||||
GL11.glColor4f(0.8f, 0.8f, 0.8f, 1.0f);
|
||||
t.begin();
|
||||
for (int i = 0; i < this.particles.size(); ++i) {
|
||||
final Particle p = this.particles.get(i);
|
||||
if (p.isLit() ^ layer == 1) {
|
||||
p.render(t, a, xa, ya, za, xa2, za2);
|
||||
}
|
||||
}
|
||||
t.end();
|
||||
GL11.glDisable(3553);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.phys;
|
||||
|
||||
public class AABB
|
||||
{
|
||||
private float epsilon;
|
||||
public float x0;
|
||||
public float y0;
|
||||
public float z0;
|
||||
public float x1;
|
||||
public float y1;
|
||||
public float z1;
|
||||
|
||||
public AABB(final float x0, final float y0, final float z0, final float x1, final float y1, final float z1) {
|
||||
this.epsilon = 0.0f;
|
||||
this.x0 = x0;
|
||||
this.y0 = y0;
|
||||
this.z0 = z0;
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.z1 = z1;
|
||||
}
|
||||
|
||||
public AABB expand(final float xa, final float ya, final float za) {
|
||||
float _x0 = this.x0;
|
||||
float _y0 = this.y0;
|
||||
float _z0 = this.z0;
|
||||
float _x2 = this.x1;
|
||||
float _y2 = this.y1;
|
||||
float _z2 = this.z1;
|
||||
if (xa < 0.0f) {
|
||||
_x0 += xa;
|
||||
}
|
||||
if (xa > 0.0f) {
|
||||
_x2 += xa;
|
||||
}
|
||||
if (ya < 0.0f) {
|
||||
_y0 += ya;
|
||||
}
|
||||
if (ya > 0.0f) {
|
||||
_y2 += ya;
|
||||
}
|
||||
if (za < 0.0f) {
|
||||
_z0 += za;
|
||||
}
|
||||
if (za > 0.0f) {
|
||||
_z2 += za;
|
||||
}
|
||||
return new AABB(_x0, _y0, _z0, _x2, _y2, _z2);
|
||||
}
|
||||
|
||||
public AABB grow(final float xa, final float ya, final float za) {
|
||||
final float _x0 = this.x0 - xa;
|
||||
final float _y0 = this.y0 - ya;
|
||||
final float _z0 = this.z0 - za;
|
||||
final float _x2 = this.x1 + xa;
|
||||
final float _y2 = this.y1 + ya;
|
||||
final float _z2 = this.z1 + za;
|
||||
return new AABB(_x0, _y0, _z0, _x2, _y2, _z2);
|
||||
}
|
||||
|
||||
public AABB cloneMove(final float xa, final float ya, final float za) {
|
||||
return new AABB(this.x0 + za, this.y0 + ya, this.z0 + za, this.x1 + xa, this.y1 + ya, this.z1 + za);
|
||||
}
|
||||
|
||||
public float clipXCollide(final AABB c, float xa) {
|
||||
if (c.y1 <= this.y0 || c.y0 >= this.y1) {
|
||||
return xa;
|
||||
}
|
||||
if (c.z1 <= this.z0 || c.z0 >= this.z1) {
|
||||
return xa;
|
||||
}
|
||||
if (xa > 0.0f && c.x1 <= this.x0) {
|
||||
final float max = this.x0 - c.x1 - this.epsilon;
|
||||
if (max < xa) {
|
||||
xa = max;
|
||||
}
|
||||
}
|
||||
if (xa < 0.0f && c.x0 >= this.x1) {
|
||||
final float max = this.x1 - c.x0 + this.epsilon;
|
||||
if (max > xa) {
|
||||
xa = max;
|
||||
}
|
||||
}
|
||||
return xa;
|
||||
}
|
||||
|
||||
public float clipYCollide(final AABB c, float ya) {
|
||||
if (c.x1 <= this.x0 || c.x0 >= this.x1) {
|
||||
return ya;
|
||||
}
|
||||
if (c.z1 <= this.z0 || c.z0 >= this.z1) {
|
||||
return ya;
|
||||
}
|
||||
if (ya > 0.0f && c.y1 <= this.y0) {
|
||||
final float max = this.y0 - c.y1 - this.epsilon;
|
||||
if (max < ya) {
|
||||
ya = max;
|
||||
}
|
||||
}
|
||||
if (ya < 0.0f && c.y0 >= this.y1) {
|
||||
final float max = this.y1 - c.y0 + this.epsilon;
|
||||
if (max > ya) {
|
||||
ya = max;
|
||||
}
|
||||
}
|
||||
return ya;
|
||||
}
|
||||
|
||||
public float clipZCollide(final AABB c, float za) {
|
||||
if (c.x1 <= this.x0 || c.x0 >= this.x1) {
|
||||
return za;
|
||||
}
|
||||
if (c.y1 <= this.y0 || c.y0 >= this.y1) {
|
||||
return za;
|
||||
}
|
||||
if (za > 0.0f && c.z1 <= this.z0) {
|
||||
final float max = this.z0 - c.z1 - this.epsilon;
|
||||
if (max < za) {
|
||||
za = max;
|
||||
}
|
||||
}
|
||||
if (za < 0.0f && c.z0 >= this.z1) {
|
||||
final float max = this.z1 - c.z0 + this.epsilon;
|
||||
if (max > za) {
|
||||
za = max;
|
||||
}
|
||||
}
|
||||
return za;
|
||||
}
|
||||
|
||||
public boolean intersects(final AABB c) {
|
||||
return c.x1 > this.x0 && c.x0 < this.x1 && c.y1 > this.y0 && c.y0 < this.y1 && c.z1 > this.z0 && c.z0 < this.z1;
|
||||
}
|
||||
|
||||
public void move(final float xa, final float ya, final float za) {
|
||||
this.x0 += xa;
|
||||
this.y0 += ya;
|
||||
this.z0 += za;
|
||||
this.x1 += xa;
|
||||
this.y1 += ya;
|
||||
this.z1 += za;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.renderer;
|
||||
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
public class Frustum
|
||||
{
|
||||
public float[][] m_Frustum;
|
||||
public static final int RIGHT = 0;
|
||||
public static final int LEFT = 1;
|
||||
public static final int BOTTOM = 2;
|
||||
public static final int TOP = 3;
|
||||
public static final int BACK = 4;
|
||||
public static final int FRONT = 5;
|
||||
public static final int A = 0;
|
||||
public static final int B = 1;
|
||||
public static final int C = 2;
|
||||
public static final int D = 3;
|
||||
private static Frustum frustum;
|
||||
private FloatBuffer _proj;
|
||||
private FloatBuffer _modl;
|
||||
private FloatBuffer _clip;
|
||||
float[] proj;
|
||||
float[] modl;
|
||||
float[] clip;
|
||||
|
||||
static {
|
||||
Frustum.frustum = new Frustum();
|
||||
}
|
||||
|
||||
private Frustum() {
|
||||
this.m_Frustum = new float[6][4];
|
||||
this._proj = BufferUtils.createFloatBuffer(16);
|
||||
this._modl = BufferUtils.createFloatBuffer(16);
|
||||
this._clip = BufferUtils.createFloatBuffer(16);
|
||||
this.proj = new float[16];
|
||||
this.modl = new float[16];
|
||||
this.clip = new float[16];
|
||||
}
|
||||
|
||||
public static Frustum getFrustum() {
|
||||
Frustum.frustum.calculateFrustum();
|
||||
return Frustum.frustum;
|
||||
}
|
||||
|
||||
private void normalizePlane(final float[][] frustum, final int side) {
|
||||
final float magnitude = (float)Math.sqrt(frustum[side][0] * frustum[side][0] + frustum[side][1] * frustum[side][1] + frustum[side][2] * frustum[side][2]);
|
||||
final float[] array = frustum[side];
|
||||
final int n = 0;
|
||||
array[n] /= magnitude;
|
||||
final float[] array2 = frustum[side];
|
||||
final int n2 = 1;
|
||||
array2[n2] /= magnitude;
|
||||
final float[] array3 = frustum[side];
|
||||
final int n3 = 2;
|
||||
array3[n3] /= magnitude;
|
||||
final float[] array4 = frustum[side];
|
||||
final int n4 = 3;
|
||||
array4[n4] /= magnitude;
|
||||
}
|
||||
|
||||
private void calculateFrustum() {
|
||||
this._proj.clear();
|
||||
this._modl.clear();
|
||||
this._clip.clear();
|
||||
GL11.glGetFloat(2983, this._proj);
|
||||
GL11.glGetFloat(2982, this._modl);
|
||||
this._proj.flip().limit(16);
|
||||
this._proj.get(this.proj);
|
||||
this._modl.flip().limit(16);
|
||||
this._modl.get(this.modl);
|
||||
this.clip[0] = this.modl[0] * this.proj[0] + this.modl[1] * this.proj[4] + this.modl[2] * this.proj[8] + this.modl[3] * this.proj[12];
|
||||
this.clip[1] = this.modl[0] * this.proj[1] + this.modl[1] * this.proj[5] + this.modl[2] * this.proj[9] + this.modl[3] * this.proj[13];
|
||||
this.clip[2] = this.modl[0] * this.proj[2] + this.modl[1] * this.proj[6] + this.modl[2] * this.proj[10] + this.modl[3] * this.proj[14];
|
||||
this.clip[3] = this.modl[0] * this.proj[3] + this.modl[1] * this.proj[7] + this.modl[2] * this.proj[11] + this.modl[3] * this.proj[15];
|
||||
this.clip[4] = this.modl[4] * this.proj[0] + this.modl[5] * this.proj[4] + this.modl[6] * this.proj[8] + this.modl[7] * this.proj[12];
|
||||
this.clip[5] = this.modl[4] * this.proj[1] + this.modl[5] * this.proj[5] + this.modl[6] * this.proj[9] + this.modl[7] * this.proj[13];
|
||||
this.clip[6] = this.modl[4] * this.proj[2] + this.modl[5] * this.proj[6] + this.modl[6] * this.proj[10] + this.modl[7] * this.proj[14];
|
||||
this.clip[7] = this.modl[4] * this.proj[3] + this.modl[5] * this.proj[7] + this.modl[6] * this.proj[11] + this.modl[7] * this.proj[15];
|
||||
this.clip[8] = this.modl[8] * this.proj[0] + this.modl[9] * this.proj[4] + this.modl[10] * this.proj[8] + this.modl[11] * this.proj[12];
|
||||
this.clip[9] = this.modl[8] * this.proj[1] + this.modl[9] * this.proj[5] + this.modl[10] * this.proj[9] + this.modl[11] * this.proj[13];
|
||||
this.clip[10] = this.modl[8] * this.proj[2] + this.modl[9] * this.proj[6] + this.modl[10] * this.proj[10] + this.modl[11] * this.proj[14];
|
||||
this.clip[11] = this.modl[8] * this.proj[3] + this.modl[9] * this.proj[7] + this.modl[10] * this.proj[11] + this.modl[11] * this.proj[15];
|
||||
this.clip[12] = this.modl[12] * this.proj[0] + this.modl[13] * this.proj[4] + this.modl[14] * this.proj[8] + this.modl[15] * this.proj[12];
|
||||
this.clip[13] = this.modl[12] * this.proj[1] + this.modl[13] * this.proj[5] + this.modl[14] * this.proj[9] + this.modl[15] * this.proj[13];
|
||||
this.clip[14] = this.modl[12] * this.proj[2] + this.modl[13] * this.proj[6] + this.modl[14] * this.proj[10] + this.modl[15] * this.proj[14];
|
||||
this.clip[15] = this.modl[12] * this.proj[3] + this.modl[13] * this.proj[7] + this.modl[14] * this.proj[11] + this.modl[15] * this.proj[15];
|
||||
this.m_Frustum[0][0] = this.clip[3] - this.clip[0];
|
||||
this.m_Frustum[0][1] = this.clip[7] - this.clip[4];
|
||||
this.m_Frustum[0][2] = this.clip[11] - this.clip[8];
|
||||
this.m_Frustum[0][3] = this.clip[15] - this.clip[12];
|
||||
this.normalizePlane(this.m_Frustum, 0);
|
||||
this.m_Frustum[1][0] = this.clip[3] + this.clip[0];
|
||||
this.m_Frustum[1][1] = this.clip[7] + this.clip[4];
|
||||
this.m_Frustum[1][2] = this.clip[11] + this.clip[8];
|
||||
this.m_Frustum[1][3] = this.clip[15] + this.clip[12];
|
||||
this.normalizePlane(this.m_Frustum, 1);
|
||||
this.m_Frustum[2][0] = this.clip[3] + this.clip[1];
|
||||
this.m_Frustum[2][1] = this.clip[7] + this.clip[5];
|
||||
this.m_Frustum[2][2] = this.clip[11] + this.clip[9];
|
||||
this.m_Frustum[2][3] = this.clip[15] + this.clip[13];
|
||||
this.normalizePlane(this.m_Frustum, 2);
|
||||
this.m_Frustum[3][0] = this.clip[3] - this.clip[1];
|
||||
this.m_Frustum[3][1] = this.clip[7] - this.clip[5];
|
||||
this.m_Frustum[3][2] = this.clip[11] - this.clip[9];
|
||||
this.m_Frustum[3][3] = this.clip[15] - this.clip[13];
|
||||
this.normalizePlane(this.m_Frustum, 3);
|
||||
this.m_Frustum[4][0] = this.clip[3] - this.clip[2];
|
||||
this.m_Frustum[4][1] = this.clip[7] - this.clip[6];
|
||||
this.m_Frustum[4][2] = this.clip[11] - this.clip[10];
|
||||
this.m_Frustum[4][3] = this.clip[15] - this.clip[14];
|
||||
this.normalizePlane(this.m_Frustum, 4);
|
||||
this.m_Frustum[5][0] = this.clip[3] + this.clip[2];
|
||||
this.m_Frustum[5][1] = this.clip[7] + this.clip[6];
|
||||
this.m_Frustum[5][2] = this.clip[11] + this.clip[10];
|
||||
this.m_Frustum[5][3] = this.clip[15] + this.clip[14];
|
||||
this.normalizePlane(this.m_Frustum, 5);
|
||||
}
|
||||
|
||||
public boolean pointInFrustum(final float x, final float y, final float z) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (this.m_Frustum[i][0] * x + this.m_Frustum[i][1] * y + this.m_Frustum[i][2] * z + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean sphereInFrustum(final float x, final float y, final float z, final float radius) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (this.m_Frustum[i][0] * x + this.m_Frustum[i][1] * y + this.m_Frustum[i][2] * z + this.m_Frustum[i][3] <= -radius) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean cubeFullyInFrustum(final float x1, final float y1, final float z1, final float x2, final float y2, final float z2) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean cubeInFrustum(final float x1, final float y1, final float z1, final float x2, final float y2, final float z2) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z1 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y1 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
if (this.m_Frustum[i][0] * x1 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
if (this.m_Frustum[i][0] * x2 + this.m_Frustum[i][1] * y2 + this.m_Frustum[i][2] * z2 + this.m_Frustum[i][3] <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isVisible(final AABB aabb) {
|
||||
return this.cubeInFrustum(aabb.x0, aabb.y0, aabb.z0, aabb.x1, aabb.y1, aabb.z1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.renderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
public class Tesselator
|
||||
{
|
||||
private static final int MAX_MEMORY_USE = 4194304;
|
||||
private static final int MAX_FLOATS = 524288;
|
||||
private FloatBuffer buffer;
|
||||
private float[] array;
|
||||
private int vertices;
|
||||
private float u;
|
||||
private float v;
|
||||
private float r;
|
||||
private float g;
|
||||
private float b;
|
||||
private boolean hasColor;
|
||||
private boolean hasTexture;
|
||||
private int len;
|
||||
private int p;
|
||||
private boolean noColor;
|
||||
public static Tesselator instance;
|
||||
|
||||
static {
|
||||
Tesselator.instance = new Tesselator();
|
||||
}
|
||||
|
||||
private Tesselator() {
|
||||
this.buffer = BufferUtils.createFloatBuffer(524288);
|
||||
this.array = new float[524288];
|
||||
this.vertices = 0;
|
||||
this.hasColor = false;
|
||||
this.hasTexture = false;
|
||||
this.len = 3;
|
||||
this.p = 0;
|
||||
this.noColor = false;
|
||||
}
|
||||
|
||||
public 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(10794, 0, this.buffer);
|
||||
}
|
||||
else if (this.hasTexture) {
|
||||
GL11.glInterleavedArrays(10791, 0, this.buffer);
|
||||
}
|
||||
else if (this.hasColor) {
|
||||
GL11.glInterleavedArrays(10788, 0, this.buffer);
|
||||
}
|
||||
else {
|
||||
GL11.glInterleavedArrays(10785, 0, this.buffer);
|
||||
}
|
||||
GL11.glEnableClientState(32884);
|
||||
if (this.hasTexture) {
|
||||
GL11.glEnableClientState(32888);
|
||||
}
|
||||
if (this.hasColor) {
|
||||
GL11.glEnableClientState(32886);
|
||||
}
|
||||
GL11.glDrawArrays(7, 0, this.vertices);
|
||||
GL11.glDisableClientState(32884);
|
||||
if (this.hasTexture) {
|
||||
GL11.glDisableClientState(32888);
|
||||
}
|
||||
if (this.hasColor) {
|
||||
GL11.glDisableClientState(32886);
|
||||
}
|
||||
}
|
||||
this.clear();
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
this.vertices = 0;
|
||||
this.buffer.clear();
|
||||
this.p = 0;
|
||||
}
|
||||
|
||||
public void begin() {
|
||||
this.clear();
|
||||
this.hasColor = false;
|
||||
this.hasTexture = false;
|
||||
this.noColor = false;
|
||||
}
|
||||
|
||||
public void tex(final float u, final float v) {
|
||||
if (!this.hasTexture) {
|
||||
this.len += 2;
|
||||
}
|
||||
this.hasTexture = true;
|
||||
this.u = u;
|
||||
this.v = v;
|
||||
}
|
||||
|
||||
public void color(final int r, final int g, final int b) {
|
||||
this.color((byte)r, (byte)g, (byte)b);
|
||||
}
|
||||
|
||||
public void color(final byte r, final byte g, final byte b) {
|
||||
if (this.noColor) {
|
||||
return;
|
||||
}
|
||||
if (!this.hasColor) {
|
||||
this.len += 3;
|
||||
}
|
||||
this.hasColor = true;
|
||||
this.r = (r & 0xFF) / 255.0f;
|
||||
this.g = (g & 0xFF) / 255.0f;
|
||||
this.b = (b & 0xFF) / 255.0f;
|
||||
}
|
||||
|
||||
public void vertexUV(final float x, final float y, final float z, final float u, final float v) {
|
||||
this.tex(u, v);
|
||||
this.vertex(x, y, z);
|
||||
}
|
||||
|
||||
public void vertex(final float x, final float y, final float z) {
|
||||
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++] = x;
|
||||
this.array[this.p++] = y;
|
||||
this.array[this.p++] = z;
|
||||
++this.vertices;
|
||||
if (this.vertices % 4 == 0 && this.p >= 524288 - this.len * 4) {
|
||||
this.end();
|
||||
}
|
||||
}
|
||||
|
||||
public void color(final int c) {
|
||||
final int r = c >> 16 & 0xFF;
|
||||
final int g = c >> 8 & 0xFF;
|
||||
final int b = c & 0xFF;
|
||||
this.color(r, g, b);
|
||||
}
|
||||
|
||||
public void noColor() {
|
||||
this.noColor = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.renderer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.nio.IntBuffer;
|
||||
import java.io.IOException;
|
||||
import org.lwjgl.util.glu.GLU;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Textures
|
||||
{
|
||||
private HashMap<String, Integer> idMap;
|
||||
|
||||
public Textures() {
|
||||
this.idMap = new HashMap<String, Integer>();
|
||||
}
|
||||
|
||||
public int loadTexture(final String resourceName, final int mode) {
|
||||
try {
|
||||
if (this.idMap.containsKey(resourceName)) {
|
||||
return this.idMap.get(resourceName);
|
||||
}
|
||||
final IntBuffer ib = BufferUtils.createIntBuffer(1);
|
||||
ib.clear();
|
||||
GL11.glGenTextures(ib);
|
||||
final int id = ib.get(0);
|
||||
this.idMap.put(resourceName, id);
|
||||
GL11.glBindTexture(3553, id);
|
||||
GL11.glTexParameteri(3553, 10241, mode);
|
||||
GL11.glTexParameteri(3553, 10240, mode);
|
||||
final BufferedImage img = ImageIO.read(Textures.class.getResourceAsStream(resourceName));
|
||||
final int w = img.getWidth();
|
||||
final int h = img.getHeight();
|
||||
final ByteBuffer pixels = BufferUtils.createByteBuffer(w * h * 4);
|
||||
final int[] rawPixels = new int[w * h];
|
||||
final byte[] newPixels = new byte[w * h * 4];
|
||||
img.getRGB(0, 0, w, h, rawPixels, 0, w);
|
||||
for (int i = 0; i < rawPixels.length; ++i) {
|
||||
final int a = rawPixels[i] >> 24 & 0xFF;
|
||||
final int r = rawPixels[i] >> 16 & 0xFF;
|
||||
final int g = rawPixels[i] >> 8 & 0xFF;
|
||||
final int b = rawPixels[i] & 0xFF;
|
||||
newPixels[i * 4 + 0] = (byte)r;
|
||||
newPixels[i * 4 + 1] = (byte)g;
|
||||
newPixels[i * 4 + 2] = (byte)b;
|
||||
newPixels[i * 4 + 3] = (byte)a;
|
||||
}
|
||||
pixels.put(newPixels);
|
||||
pixels.position(0).limit(newPixels.length);
|
||||
GLU.gluBuild2DMipmaps(3553, 6408, w, h, 6408, 5121, pixels);
|
||||
return id;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException("!!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.server;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import com.mojang.minecraft.comm.SocketConnection;
|
||||
import com.mojang.minecraft.comm.ConnectionListener;
|
||||
|
||||
public class Client implements ConnectionListener
|
||||
{
|
||||
public final SocketConnection serverConnection;
|
||||
private final MinecraftServer server;
|
||||
|
||||
public Client(final MinecraftServer server, final SocketConnection serverConnection) {
|
||||
this.server = server;
|
||||
(this.serverConnection = serverConnection).setConnectionListener(this);
|
||||
}
|
||||
|
||||
public void command(final byte cmd, final int remaining, final ByteBuffer in) {
|
||||
}
|
||||
|
||||
public void handleException(final Exception e) {
|
||||
this.disconnect();
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
this.server.disconnect(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package com.mojang.minecraft.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import com.mojang.minecraft.comm.SocketConnection;
|
||||
import java.util.Map;
|
||||
import com.mojang.minecraft.comm.SocketServer;
|
||||
import com.mojang.minecraft.comm.ServerListener;
|
||||
|
||||
public class MinecraftServer implements Runnable, ServerListener
|
||||
{
|
||||
private SocketServer socketServer;
|
||||
private Map<SocketConnection, Client> clientMap;
|
||||
private List<Client> clients;
|
||||
|
||||
public MinecraftServer(final byte[] ips, final int port) throws IOException {
|
||||
this.clientMap = new HashMap<SocketConnection, Client>();
|
||||
this.clients = new ArrayList<Client>();
|
||||
this.socketServer = new SocketServer(ips, port, this);
|
||||
}
|
||||
|
||||
public void clientConnected(final SocketConnection serverConnection) {
|
||||
final Client client = new Client(this, serverConnection);
|
||||
this.clientMap.put(serverConnection, client);
|
||||
this.clients.add(client);
|
||||
}
|
||||
|
||||
public void disconnect(final Client client) {
|
||||
this.clientMap.remove(client.serverConnection);
|
||||
this.clients.remove(client);
|
||||
}
|
||||
|
||||
public void clientException(final SocketConnection serverConnection, final Exception e) {
|
||||
final Client client = this.clientMap.get(serverConnection);
|
||||
client.handleException(e);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while (true) {
|
||||
this.tick();
|
||||
try {
|
||||
Thread.sleep(5L);
|
||||
}
|
||||
catch (InterruptedException ex) {}
|
||||
}
|
||||
}
|
||||
|
||||
private void tick() {
|
||||
try {
|
||||
this.socketServer.tick();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(final String[] args) throws IOException {
|
||||
final MinecraftServer server = new MinecraftServer(new byte[] { 127, 0, 0, 1 }, 20801);
|
||||
final Thread thread = new Thread(server);
|
||||
thread.start();
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 1011 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 306 B |