Compare commits

...

5 Commits

Author SHA1 Message Date
Chaziz d9dfb47c62 random shit 2021-06-07 20:05:48 -04:00
Chaziz 7d242ff7ea background 2021-06-05 00:36:17 -04:00
Chaziz bedfee502c readd main menu, still crappy though 2021-06-05 00:18:54 -04:00
Chaziz 1ae441a8b7 edit HUD again, make movement slightly faster 2021-06-04 23:14:22 -04:00
Chaziz ef3cc78a02 Add debug text + new diamond textures 2021-05-31 22:19:16 -04:00
13 changed files with 180 additions and 41 deletions

BIN
level.dat

Binary file not shown.

View File

@ -11,6 +11,7 @@ import com.mojang.minecraft.renderer.Tesselator;
import com.mojang.minecraft.renderer.Frustum; import com.mojang.minecraft.renderer.Frustum;
import com.mojang.minecraft.phys.AABB; import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.level.tile.Tile; import com.mojang.minecraft.level.tile.Tile;
import com.mojang.minecraft.gui.DebugScreen;
import com.mojang.minecraft.gui.PauseScreen; import com.mojang.minecraft.gui.PauseScreen;
import com.mojang.minecraft.gui.MenuScreen; import com.mojang.minecraft.gui.MenuScreen;
import com.mojang.minecraft.level.Chunk; import com.mojang.minecraft.level.Chunk;
@ -82,6 +83,7 @@ public class Minecraft implements Runnable, LevelLoaderListener {
private String title; private String title;
public Minecraft(final Canvas parent, final int width, final int height, final boolean fullscreen) { public Minecraft(final Canvas parent, final int width, final int height, final boolean fullscreen) {
System.out.println("Gamerappa's Minecraft has been launched.");
this.fullscreen = false; this.fullscreen = false;
this.fogColor0 = BufferUtils.createFloatBuffer(4); this.fogColor0 = BufferUtils.createFloatBuffer(4);
this.fogColor1 = BufferUtils.createFloatBuffer(4); this.fogColor1 = BufferUtils.createFloatBuffer(4);
@ -114,6 +116,7 @@ public class Minecraft implements Runnable, LevelLoaderListener {
} }
public void init() throws LWJGLException, IOException { public void init() throws LWJGLException, IOException {
System.out.println("Initializing Gamerappa's Minecraft Version " + VERSION_STRING);
final int col1 = 920330; final int col1 = 920330;
final float fr = 0.5f; final float fr = 0.5f;
final float fg = 0.8f; final float fg = 0.8f;
@ -146,6 +149,7 @@ public class Minecraft implements Runnable, LevelLoaderListener {
Keyboard.create(); Keyboard.create();
Mouse.create(); Mouse.create();
this.checkGlError("Pre startup"); this.checkGlError("Pre startup");
System.out.println("Pre-startup");
GL11.glEnable(3553); GL11.glEnable(3553);
GL11.glShadeModel(7425); GL11.glShadeModel(7425);
GL11.glClearColor(fr, fg, fb, 0.0f); GL11.glClearColor(fr, fg, fb, 0.0f);
@ -159,24 +163,27 @@ public class Minecraft implements Runnable, LevelLoaderListener {
GL11.glLoadIdentity(); GL11.glLoadIdentity();
GL11.glMatrixMode(5888); GL11.glMatrixMode(5888);
this.checkGlError("Startup"); this.checkGlError("Startup");
System.out.println("Startup");
this.font = new Font("/default.gif", this.textures); this.font = new Font("/default.gif", this.textures);
GL11.glViewport(0, 0, this.width, this.height);
this.setScreen(new MenuScreen()); //bad menu
final IntBuffer imgData = BufferUtils.createIntBuffer(256); final IntBuffer imgData = BufferUtils.createIntBuffer(256);
imgData.clear().limit(256); imgData.clear().limit(256);
GL11.glViewport(0, 0, this.width, this.height);
//this.setScreen(new MenuScreen());
Minecraft.level = new Level(); Minecraft.level = new Level();
System.out.println("Initalizing level.");
boolean success = false; boolean success = false;
try { try {
success = Minecraft.levelIo.load(Minecraft.level, success = Minecraft.levelIo.load(Minecraft.level,
new FileInputStream(new File("level.dat"))); new FileInputStream(new File("level.dat")));
if (!success) { if (!success) {
success = Minecraft.levelIo.loadLegacy(Minecraft.level, success = Minecraft.levelIo.loadLegacy(Minecraft.level,
new FileInputStream(new File("level.dat"))); new FileInputStream(new File("level.dat")));
} }
} catch (Exception e3) { } catch (Exception e3) {
success = false; success = false;
} }
if (!success) { if (!success) {
System.out.println("Save file doesn't exist.");
this.levelGen.generateLevel(Minecraft.level, User.name, 256, this.levelGen.generateLevel(Minecraft.level, User.name, 256,
256, 64, nameLevel); 256, 64, nameLevel);
} }
@ -198,6 +205,7 @@ public class Minecraft implements Runnable, LevelLoaderListener {
} }
} }
this.checkGlError("Post startup"); this.checkGlError("Post startup");
System.out.println("Post-startup");
} }
public void setScreen(final Screen screen) { public void setScreen(final Screen screen) {
@ -230,7 +238,6 @@ public class Minecraft implements Runnable, LevelLoaderListener {
} }
public void destroy() { public void destroy() {
this.attemptSaveLevel();
Mouse.destroy(); Mouse.destroy();
Keyboard.destroy(); Keyboard.destroy();
Display.destroy(); Display.destroy();
@ -257,7 +264,7 @@ public class Minecraft implements Runnable, LevelLoaderListener {
} }
this.setScreen(null); this.setScreen(null);
} }
public void releaseMouse() { public void releaseMouse() {
if (!this.mouseGrabbed) { if (!this.mouseGrabbed) {
return; return;
@ -273,6 +280,24 @@ public class Minecraft implements Runnable, LevelLoaderListener {
} else { } else {
Mouse.setGrabbed(false); Mouse.setGrabbed(false);
} }
}
public void pause() {
// why. 6/5/21
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()); this.setScreen(new PauseScreen());
} }
@ -341,8 +366,12 @@ public class Minecraft implements Runnable, LevelLoaderListener {
Keyboard.getEventKeyState()); Keyboard.getEventKeyState());
if (Keyboard.getEventKeyState()) { if (Keyboard.getEventKeyState()) {
if (Keyboard.getEventKey() == 1) { if (Keyboard.getEventKey() == 1) {
this.releaseMouse(); this.pause(); //bad implementation but for some reason it kept spam-saving
} // refer to tile.java to find tile ID. } // refer to tile.java to find tile ID.
if (Keyboard.getEventKey() == Keyboard.KEY_END) {
this.releaseMouse();
this.setScreen(new DebugScreen()); //bad menu
}
if (Keyboard.getEventKey() == 28) { if (Keyboard.getEventKey() == 28) {
this.attemptSaveLevel(); this.attemptSaveLevel();
} }
@ -353,7 +382,7 @@ public class Minecraft implements Runnable, LevelLoaderListener {
if (Keyboard.getEventKey() == Keyboard.KEY_PERIOD) { if (Keyboard.getEventKey() == Keyboard.KEY_PERIOD) {
if (this.paintTexture != 36) // prevents game from if (this.paintTexture != 36) // prevents game from
// crashing if user goes // crashing if user goes
// above the last // beyond the last
// available block. // available block.
this.paintTexture += 1; this.paintTexture += 1;
this.paintTextureString = ("Block Selected: " + this.paintTexture); this.paintTextureString = ("Block Selected: " + this.paintTexture);
@ -475,7 +504,7 @@ public class Minecraft implements Runnable, LevelLoaderListener {
public void render(final float a) { public void render(final float a) {
if (!Display.isActive()) { if (!Display.isActive()) {
this.releaseMouse(); this.pause();
} }
GL11.glViewport(0, 0, this.width, this.height); GL11.glViewport(0, 0, this.width, this.height);
if (this.mouseGrabbed) { if (this.mouseGrabbed) {
@ -519,12 +548,12 @@ public class Minecraft implements Runnable, LevelLoaderListener {
this.setupFog(1); this.setupFog(1);
this.levelRenderer.clouds(a); this.levelRenderer.clouds(a);
this.levelRenderer.render(this.player, 1); this.levelRenderer.render(this.player, 1);
// for (int i = 0; i < this.entities.size(); ++i) { for (int i = 0; i < this.entities.size(); ++i) {
// final Entity zombie = this.entities.get(i); final Entity zombie = this.entities.get(i);
// if (!zombie.isLit() && frustum.isVisible(zombie.bb)) { if (!zombie.isLit() && frustum.isVisible(zombie.bb)) {
// this.entities.get(i).render(a); this.entities.get(i).render(a);
// } }
// } }
this.particleEngine.render(this.player, a, 1); this.particleEngine.render(this.player, a, 1);
this.levelRenderer.renderSurroundingGround(); this.levelRenderer.renderSurroundingGround();
if (this.hitResult != null) { if (this.hitResult != null) {
@ -571,10 +600,10 @@ public class Minecraft implements Runnable, LevelLoaderListener {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
JOptionPane.showMessageDialog(null, e.toString(), JOptionPane.showMessageDialog(null, e.toString(),
"Failed to start MinecraftGRPF", 0); "Failed to start Gamerappa's Minecraft", 0);
return; return;
} }
long lastTime = System.currentTimeMillis(); long lastTime = System.currentTimeMillis();
int frames = 0; int frames = 0;
try { try {
while (this.running) { while (this.running) {
@ -626,7 +655,8 @@ public class Minecraft implements Runnable, LevelLoaderListener {
GL11.glTranslatef(0.0f, 0.0f, -200.0f); GL11.glTranslatef(0.0f, 0.0f, -200.0f);
this.checkGlError("GUI: Init"); this.checkGlError("GUI: Init");
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef((float) (screenWidth - 16), 16.0f, -50.0f); //location of block preview?
GL11.glTranslatef((float) (screenWidth - 16), (screenHeight - 16), -50.0f);
final Tesselator t = Tesselator.instance; final Tesselator t = Tesselator.instance;
GL11.glScalef(16.0f, 16.0f, 16.0f); GL11.glScalef(16.0f, 16.0f, 16.0f);
GL11.glRotatef(-30.0f, 1.0f, 0.0f, 0.0f); GL11.glRotatef(-30.0f, 1.0f, 0.0f, 0.0f);
@ -637,17 +667,18 @@ public class Minecraft implements Runnable, LevelLoaderListener {
GL11.glBindTexture(3553, id); GL11.glBindTexture(3553, id);
GL11.glEnable(3553); GL11.glEnable(3553);
t.begin(); t.begin();
//this is the block preview used for the HUD
Tile.tiles[this.paintTexture].render(t, Minecraft.level, 0, -2, 0, 0); Tile.tiles[this.paintTexture].render(t, Minecraft.level, 0, -2, 0, 0);
t.end(); t.end();
GL11.glDisable(3553); GL11.glDisable(3553);
GL11.glPopMatrix(); GL11.glPopMatrix();
this.checkGlError("GUI: Draw selected"); this.checkGlError("GUI: Draw selected");
// For some random reason, the text color uses BGR and not RGB. // For some random reason, the text color uses BGR and not RGB. (or not??????????????)
// We should add a text color system later, in case we actually // We should add a text color system later, in case we actually
// implement multiplayer. -Chaziz 5/31/2021 // implement multiplayer. -Chaziz 5/31/2021
//this.font.drawShadow("Gamerappa's Minecraft", 2, 2, 16777215); this.font.drawShadow("Gamerappa's Minecraft", 2, 2, 3394560); //green text
this.font.drawShadow(VERSION_STRING + " - " + this.fpsString, 2, 2, 16777215); this.font.drawShadow(VERSION_STRING + " - " + this.fpsString, 120, 2, 16777215);
this.font.drawShadow(this.paintTextureString, 2, 12, 13948116); this.font.drawShadow(this.paintTextureString, 2, 202, 13948116); //gray text
this.font.drawShadow("User: " + User.name, 2, 212, 16764165); //yellow text this.font.drawShadow("User: " + User.name, 2, 212, 16764165); //yellow text
this.font.drawShadow("Level: " + Minecraft.nameLevel, 2, 222, 11528191); //blue text this.font.drawShadow("Level: " + Minecraft.nameLevel, 2, 222, 11528191); //blue text
this.checkGlError("GUI: Draw text"); this.checkGlError("GUI: Draw text");
@ -762,10 +793,11 @@ public class Minecraft implements Runnable, LevelLoaderListener {
} }
public class inputLevelName { public class inputLevelName {
JFrame f; JFrame f;
public inputLevelName(){ public inputLevelName(){
f=new JFrame(); f=new JFrame();
nameLevel=JOptionPane.showInputDialog(f,"Enter name for level."); System.out.println("A dialog asking for the level name should open.");
nameLevel=JOptionPane.showInputDialog(f,"Please input the name for the level.");
} }
} }

View File

@ -86,9 +86,9 @@ public class Player extends Entity
final float yo = this.y; final float yo = this.y;
this.moveRelative(xa, ya, 0.02f); this.moveRelative(xa, ya, 0.02f);
this.move(this.xd, this.yd, this.zd); this.move(this.xd, this.yd, this.zd);
this.xd *= 0.8f; this.xd *= 0.825f;
this.yd *= 0.8f; this.yd *= 0.825f;
this.zd *= 0.8f; this.zd *= 0.825f;
this.yd -= (float)0.02; this.yd -= (float)0.02;
if (this.horizontalCollision && this.isFree(this.xd, this.yd + 0.6f - this.y + yo, this.zd)) { if (this.horizontalCollision && this.isFree(this.xd, this.yd + 0.6f - this.y + yo, this.zd)) {
this.yd = 0.3f; this.yd = 0.3f;
@ -98,9 +98,9 @@ public class Player extends Entity
final float yo = this.y; final float yo = this.y;
this.moveRelative(xa, ya, 0.02f); this.moveRelative(xa, ya, 0.02f);
this.move(this.xd, this.yd, this.zd); this.move(this.xd, this.yd, this.zd);
this.xd *= 0.5f; this.xd *= 0.65f;
this.yd *= 0.5f; this.yd *= 0.65f;
this.zd *= 0.5f; this.zd *= 0.65f;
this.yd -= (float)0.02; this.yd -= (float)0.02;
if (this.horizontalCollision && this.isFree(this.xd, this.yd + 0.6f - this.y + yo, this.zd)) { if (this.horizontalCollision && this.isFree(this.xd, this.yd + 0.6f - this.y + yo, this.zd)) {
this.yd = 0.3f; this.yd = 0.3f;

View File

@ -0,0 +1,89 @@
//
// Decompiled by Procyon v0.5.36
//
package com.mojang.minecraft.gui;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
import com.mojang.minecraft.renderer.Tesselator;
import com.mojang.minecraft.renderer.Textures;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.character.Zombie;
import com.mojang.minecraft.gui.Screen;
import com.mojang.minecraft.gui.Font;
import com.mojang.minecraft.level.LevelIO;
public class DebugScreen extends Screen
{
public Font font;
private List<Button> buttons;
public Textures textures;
public DebugScreen() {
this.buttons = new ArrayList<Button>();
}
@Override
public void init() {
this.buttons.add(new Button(0, this.width / 2 - 100, this.height / 4 + 0, 200, 20, "Spawn Human"));
//this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 4 + 32, 200, 20, "Save level.."));
//this.buttons.add(new Button(2, this.width / 2 - 100, this.height / 4 + 64, 200, 20, "Load level.."));
this.buttons.add(new Button(3, this.width / 2 - 100, this.height / 4 + 32, 200, 20, "Continue level"));
this.buttons.add(new Button(4, this.width / 2 - 100, this.height / 4 + 96, 200, 20, "Exit"));
}
@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.setScreen(null);
this.minecraft.grabMouse();
}
if (button.id == 3) {
this.minecraft.setScreen(null);
this.minecraft.grabMouse();
}
if (button.id == 4) {
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);
this.drawString("Todo: Make this actually fucking work. 6/5/21", this.width / 2 / 2, 30, 3394560);
this.drawString("1 day until 8th anniversary of the Chazpelo Roblox Account!!!", this.width / 2 / 2, 40, 3394560);
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);
}
}
}
}

View File

@ -24,6 +24,7 @@ public class Font
img = ImageIO.read(Textures.class.getResourceAsStream(name)); img = ImageIO.read(Textures.class.getResourceAsStream(name));
} }
catch (IOException e) { catch (IOException e) {
System.out.println("Font couldn't load");
throw new RuntimeException(e); throw new RuntimeException(e);
} }
final int w = img.getWidth(); final int w = img.getWidth();

View File

@ -11,12 +11,14 @@ import org.lwjgl.opengl.GL11;
import com.mojang.minecraft.renderer.Tesselator; import com.mojang.minecraft.renderer.Tesselator;
import com.mojang.minecraft.renderer.Textures; import com.mojang.minecraft.renderer.Textures;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.gui.Screen; import com.mojang.minecraft.gui.Screen;
import com.mojang.minecraft.gui.Font; import com.mojang.minecraft.gui.Font;
import com.mojang.minecraft.level.LevelIO; import com.mojang.minecraft.level.LevelIO;
public class MenuScreen extends Screen public class MenuScreen extends Screen
{ {
public Font font;
private List<Button> buttons; private List<Button> buttons;
public Textures textures; public Textures textures;
@ -26,11 +28,11 @@ public class MenuScreen extends Screen
@Override @Override
public void init() { public void init() {
this.buttons.add(new Button(0, this.width / 2 - 100, this.height / 4 + 0, 200, 20, "New level..")); this.buttons.add(new Button(0, this.width / 2 - 100, this.height / 4 + 0, 200, 20, "New level"));
//this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 4 + 32, 200, 20, "Save level..")); //this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 4 + 32, 200, 20, "Save level.."));
this.buttons.add(new Button(2, this.width / 2 - 100, this.height / 4 + 64, 200, 20, "Load level..")); //this.buttons.add(new Button(2, this.width / 2 - 100, this.height / 4 + 64, 200, 20, "Load level.."));
this.buttons.add(new Button(3, this.width / 2 - 100, this.height / 4 + 96, 200, 20, "Continue level..")); this.buttons.add(new Button(3, this.width / 2 - 100, this.height / 4 + 32, 200, 20, "Continue level"));
this.buttons.add(new Button(4, this.width / 2 - 100, this.height / 4 + 128, 200, 20, "Exit")); this.buttons.add(new Button(4, this.width / 2 - 100, this.height / 4 + 96, 200, 20, "Exit"));
} }
@Override @Override
@ -66,7 +68,10 @@ public class MenuScreen extends Screen
@Override @Override
public void render(final int xm, final int ym) { public void render(final int xm, final int ym) {
this.fillGradient(0, 0, this.width, this.height, 537199872, -1607454624); this.fill(0, 0, this.width, this.height, 869007615);
//how the actual fuck does java handle colors? how can it be semi-transparent pink and not weird proper green
this.drawCenteredString("Gamerappa's Minecraft", this.width / 2 / 2, 30, 339456050);
this.drawString("This is version " + Minecraft.VERSION_STRING, this.width / 2 / 2, 40, 3394560);
for (int i = 0; i < this.buttons.size(); ++i) { for (int i = 0; i < this.buttons.size(); ++i) {
final Button button = this.buttons.get(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); this.fill(button.x - 1, button.y - 1, button.x + button.w + 1, button.y + button.h + 1, -16777216);

View File

@ -26,7 +26,6 @@ public class PauseScreen extends Screen
@Override @Override
public void init() { public void init() {
attemptSaveLevel(); attemptSaveLevel();
System.out.println("Level saved? [PAUSE MENU]");
this.buttons.add(new Button(0, this.width / 2 - 100, this.height / 4 + 32, 200, 20, "Generate new level")); this.buttons.add(new Button(0, this.width / 2 - 100, this.height / 4 + 32, 200, 20, "Generate new level"));
//this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 4 + 96, 200, 20, "Save level..")); //this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 4 + 96, 200, 20, "Save level.."));
//this.buttons.add(new Button(2, this.width / 2 - 100, this.height / 4 + 128, 200, 20, "Load level..")); //this.buttons.add(new Button(2, this.width / 2 - 100, this.height / 4 + 128, 200, 20, "Load level.."));

View File

@ -26,6 +26,7 @@ public class LevelIO
} }
public boolean load(final Level level, final InputStream in) { public boolean load(final Level level, final InputStream in) {
System.out.println("Save file exists, loading.");
this.levelLoaderListener.beginLevelLoading("Loading level"); this.levelLoaderListener.beginLevelLoading("Loading level");
this.levelLoaderListener.levelLoadUpdate("Reading.."); this.levelLoaderListener.levelLoadUpdate("Reading..");
try { try {
@ -53,8 +54,7 @@ public class LevelIO
level.name = name; level.name = name;
level.creator = creator; level.creator = creator;
level.createTime = createTime; level.createTime = createTime;
System.out.println("Level Loaded"); System.out.println(level.name + " by " + level.creator + ". ");
System.out.println(level.name);
Minecraft.nameLevel = level.name; Minecraft.nameLevel = level.name;
return true; return true;
} }
@ -66,7 +66,8 @@ public class LevelIO
} }
public boolean loadLegacy(final Level level, final InputStream in) { public boolean loadLegacy(final Level level, final InputStream in) {
this.levelLoaderListener.beginLevelLoading("Loading level"); System.out.println("Save file does exist, but it's in a legacy pre-classic format, loading with alternative function.");
this.levelLoaderListener.beginLevelLoading("Loading legacy level");
this.levelLoaderListener.levelLoadUpdate("Reading.."); this.levelLoaderListener.levelLoadUpdate("Reading..");
try { try {
final DataInputStream dis = new DataInputStream(new GZIPInputStream(in)); final DataInputStream dis = new DataInputStream(new GZIPInputStream(in));
@ -105,6 +106,7 @@ public class LevelIO
dos.writeShort(level.depth); dos.writeShort(level.depth);
dos.write(level.blocks); dos.write(level.blocks);
dos.close(); dos.close();
System.out.println("Saved.");
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -31,6 +31,7 @@ public class LevelGen
} }
public boolean generateLevel(final Level level, final String userName, final int width, final int height, final int depth, final String levelName) { public boolean generateLevel(final Level level, final String userName, final int width, final int height, final int depth, final String levelName) {
System.out.println("Generating new level.");
this.levelLoaderListener.beginLevelLoading("Generating level"); this.levelLoaderListener.beginLevelLoading("Generating level");
this.width = width; this.width = width;
this.height = height; this.height = height;
@ -50,7 +51,7 @@ public class LevelGen
level.createTime = System.currentTimeMillis(); level.createTime = System.currentTimeMillis();
level.creator = userName; level.creator = userName;
level.name = levelName; level.name = levelName;
System.out.println("Level Generated -" + level.name); System.out.println("Level Generated: " + level.name);
Minecraft.nameLevel = level.name; Minecraft.nameLevel = level.name;
return true; return true;
} }

View File

@ -55,10 +55,11 @@ public class Textures
pixels.put(newPixels); pixels.put(newPixels);
pixels.position(0).limit(newPixels.length); pixels.position(0).limit(newPixels.length);
GLU.gluBuild2DMipmaps(3553, 6408, w, h, 6408, 5121, pixels); GLU.gluBuild2DMipmaps(3553, 6408, w, h, 6408, 5121, pixels);
System.out.println("Loaded texture " + (resourceName));
return id; return id;
} }
catch (IOException e) { catch (IOException e) {
throw new RuntimeException("!!"); throw new RuntimeException("Couldn't load texture");
} }
} }
} }

View File

@ -16,6 +16,7 @@ public class Client implements ConnectionListener
public Client(final MinecraftServer server, final SocketConnection serverConnection) { public Client(final MinecraftServer server, final SocketConnection serverConnection) {
this.server = server; this.server = server;
(this.serverConnection = serverConnection).setConnectionListener(this); (this.serverConnection = serverConnection).setConnectionListener(this);
System.out.println("Connection");
} }
public void command(final byte cmd, final int remaining, final ByteBuffer in) { public void command(final byte cmd, final int remaining, final ByteBuffer in) {
@ -27,5 +28,6 @@ public class Client implements ConnectionListener
public void disconnect() { public void disconnect() {
this.server.disconnect(this); this.server.disconnect(this);
System.out.println("Disconnection");
} }
} }

View File

@ -23,17 +23,22 @@ public class MinecraftServer implements Runnable, ServerListener
this.clientMap = new HashMap<SocketConnection, Client>(); this.clientMap = new HashMap<SocketConnection, Client>();
this.clients = new ArrayList<Client>(); this.clients = new ArrayList<Client>();
this.socketServer = new SocketServer(ips, port, this); this.socketServer = new SocketServer(ips, port, this);
System.out.println("Gamerappa's Minecraft Server");
System.out.println(ips);
System.out.println(port);
} }
public void clientConnected(final SocketConnection serverConnection) { public void clientConnected(final SocketConnection serverConnection) {
final Client client = new Client(this, serverConnection); final Client client = new Client(this, serverConnection);
this.clientMap.put(serverConnection, client); this.clientMap.put(serverConnection, client);
this.clients.add(client); this.clients.add(client);
System.out.println("Server - Connection");
} }
public void disconnect(final Client client) { public void disconnect(final Client client) {
this.clientMap.remove(client.serverConnection); this.clientMap.remove(client.serverConnection);
this.clients.remove(client); this.clients.remove(client);
System.out.println("Server - Disconnection");
} }
public void clientException(final SocketConnection serverConnection, final Exception e) { public void clientException(final SocketConnection serverConnection, final Exception e) {
@ -42,6 +47,7 @@ public class MinecraftServer implements Runnable, ServerListener
} }
public void run() { public void run() {
System.out.println("Running");
while (true) { while (true) {
this.tick(); this.tick();
try { try {
@ -61,6 +67,7 @@ public class MinecraftServer implements Runnable, ServerListener
} }
public static void main(final String[] args) throws IOException { public static void main(final String[] args) throws IOException {
System.out.println("Initializing");
final MinecraftServer server = new MinecraftServer(new byte[] { 127, 0, 0, 1 }, 20801); final MinecraftServer server = new MinecraftServer(new byte[] { 127, 0, 0, 1 }, 20801);
final Thread thread = new Thread(server); final Thread thread = new Thread(server);
thread.start(); thread.start();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 21 KiB