Compare commits
5 Commits
9749990052
...
d9dfb47c62
Author | SHA1 | Date |
---|---|---|
Chaziz | d9dfb47c62 | |
Chaziz | 7d242ff7ea | |
Chaziz | bedfee502c | |
Chaziz | 1ae441a8b7 | |
Chaziz | ef3cc78a02 |
|
@ -11,6 +11,7 @@ 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.DebugScreen;
|
||||
import com.mojang.minecraft.gui.PauseScreen;
|
||||
import com.mojang.minecraft.gui.MenuScreen;
|
||||
import com.mojang.minecraft.level.Chunk;
|
||||
|
@ -82,6 +83,7 @@ public class Minecraft implements Runnable, LevelLoaderListener {
|
|||
private String title;
|
||||
|
||||
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.fogColor0 = BufferUtils.createFloatBuffer(4);
|
||||
this.fogColor1 = BufferUtils.createFloatBuffer(4);
|
||||
|
@ -114,6 +116,7 @@ public class Minecraft implements Runnable, LevelLoaderListener {
|
|||
}
|
||||
|
||||
public void init() throws LWJGLException, IOException {
|
||||
System.out.println("Initializing Gamerappa's Minecraft Version " + VERSION_STRING);
|
||||
final int col1 = 920330;
|
||||
final float fr = 0.5f;
|
||||
final float fg = 0.8f;
|
||||
|
@ -146,6 +149,7 @@ public class Minecraft implements Runnable, LevelLoaderListener {
|
|||
Keyboard.create();
|
||||
Mouse.create();
|
||||
this.checkGlError("Pre startup");
|
||||
System.out.println("Pre-startup");
|
||||
GL11.glEnable(3553);
|
||||
GL11.glShadeModel(7425);
|
||||
GL11.glClearColor(fr, fg, fb, 0.0f);
|
||||
|
@ -159,24 +163,27 @@ public class Minecraft implements Runnable, LevelLoaderListener {
|
|||
GL11.glLoadIdentity();
|
||||
GL11.glMatrixMode(5888);
|
||||
this.checkGlError("Startup");
|
||||
System.out.println("Startup");
|
||||
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);
|
||||
imgData.clear().limit(256);
|
||||
GL11.glViewport(0, 0, this.width, this.height);
|
||||
//this.setScreen(new MenuScreen());
|
||||
Minecraft.level = new Level();
|
||||
System.out.println("Initalizing level.");
|
||||
boolean success = false;
|
||||
try {
|
||||
success = Minecraft.levelIo.load(Minecraft.level,
|
||||
new FileInputStream(new File("level.dat")));
|
||||
if (!success) {
|
||||
success = Minecraft.levelIo.loadLegacy(Minecraft.level,
|
||||
new FileInputStream(new File("level.dat")));
|
||||
new FileInputStream(new File("level.dat")));
|
||||
}
|
||||
} catch (Exception e3) {
|
||||
success = false;
|
||||
}
|
||||
if (!success) {
|
||||
System.out.println("Save file doesn't exist.");
|
||||
this.levelGen.generateLevel(Minecraft.level, User.name, 256,
|
||||
256, 64, nameLevel);
|
||||
}
|
||||
|
@ -198,6 +205,7 @@ public class Minecraft implements Runnable, LevelLoaderListener {
|
|||
}
|
||||
}
|
||||
this.checkGlError("Post startup");
|
||||
System.out.println("Post-startup");
|
||||
}
|
||||
|
||||
public void setScreen(final Screen screen) {
|
||||
|
@ -230,7 +238,6 @@ public class Minecraft implements Runnable, LevelLoaderListener {
|
|||
}
|
||||
|
||||
public void destroy() {
|
||||
this.attemptSaveLevel();
|
||||
Mouse.destroy();
|
||||
Keyboard.destroy();
|
||||
Display.destroy();
|
||||
|
@ -257,7 +264,7 @@ public class Minecraft implements Runnable, LevelLoaderListener {
|
|||
}
|
||||
this.setScreen(null);
|
||||
}
|
||||
|
||||
|
||||
public void releaseMouse() {
|
||||
if (!this.mouseGrabbed) {
|
||||
return;
|
||||
|
@ -273,6 +280,24 @@ public class Minecraft implements Runnable, LevelLoaderListener {
|
|||
} else {
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -341,8 +366,12 @@ public class Minecraft implements Runnable, LevelLoaderListener {
|
|||
Keyboard.getEventKeyState());
|
||||
if (Keyboard.getEventKeyState()) {
|
||||
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.
|
||||
if (Keyboard.getEventKey() == Keyboard.KEY_END) {
|
||||
this.releaseMouse();
|
||||
this.setScreen(new DebugScreen()); //bad menu
|
||||
}
|
||||
if (Keyboard.getEventKey() == 28) {
|
||||
this.attemptSaveLevel();
|
||||
}
|
||||
|
@ -353,7 +382,7 @@ public class Minecraft implements Runnable, LevelLoaderListener {
|
|||
if (Keyboard.getEventKey() == Keyboard.KEY_PERIOD) {
|
||||
if (this.paintTexture != 36) // prevents game from
|
||||
// crashing if user goes
|
||||
// above the last
|
||||
// beyond the last
|
||||
// available block.
|
||||
this.paintTexture += 1;
|
||||
this.paintTextureString = ("Block Selected: " + this.paintTexture);
|
||||
|
@ -475,7 +504,7 @@ public class Minecraft implements Runnable, LevelLoaderListener {
|
|||
|
||||
public void render(final float a) {
|
||||
if (!Display.isActive()) {
|
||||
this.releaseMouse();
|
||||
this.pause();
|
||||
}
|
||||
GL11.glViewport(0, 0, this.width, this.height);
|
||||
if (this.mouseGrabbed) {
|
||||
|
@ -519,12 +548,12 @@ public class Minecraft implements Runnable, LevelLoaderListener {
|
|||
this.setupFog(1);
|
||||
this.levelRenderer.clouds(a);
|
||||
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);
|
||||
// }
|
||||
// }
|
||||
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) {
|
||||
|
@ -571,10 +600,10 @@ public class Minecraft implements Runnable, LevelLoaderListener {
|
|||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, e.toString(),
|
||||
"Failed to start MinecraftGRPF", 0);
|
||||
"Failed to start Gamerappa's Minecraft", 0);
|
||||
return;
|
||||
}
|
||||
long lastTime = System.currentTimeMillis();
|
||||
long lastTime = System.currentTimeMillis();
|
||||
int frames = 0;
|
||||
try {
|
||||
while (this.running) {
|
||||
|
@ -626,7 +655,8 @@ public class Minecraft implements Runnable, LevelLoaderListener {
|
|||
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
|
||||
this.checkGlError("GUI: Init");
|
||||
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;
|
||||
GL11.glScalef(16.0f, 16.0f, 16.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.glEnable(3553);
|
||||
t.begin();
|
||||
//this is the block preview used for the HUD
|
||||
Tile.tiles[this.paintTexture].render(t, Minecraft.level, 0, -2, 0, 0);
|
||||
t.end();
|
||||
GL11.glDisable(3553);
|
||||
GL11.glPopMatrix();
|
||||
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
|
||||
// implement multiplayer. -Chaziz 5/31/2021
|
||||
//this.font.drawShadow("Gamerappa's Minecraft", 2, 2, 16777215);
|
||||
this.font.drawShadow(VERSION_STRING + " - " + this.fpsString, 2, 2, 16777215);
|
||||
this.font.drawShadow(this.paintTextureString, 2, 12, 13948116);
|
||||
this.font.drawShadow("Gamerappa's Minecraft", 2, 2, 3394560); //green text
|
||||
this.font.drawShadow(VERSION_STRING + " - " + this.fpsString, 120, 2, 16777215);
|
||||
this.font.drawShadow(this.paintTextureString, 2, 202, 13948116); //gray text
|
||||
this.font.drawShadow("User: " + User.name, 2, 212, 16764165); //yellow text
|
||||
this.font.drawShadow("Level: " + Minecraft.nameLevel, 2, 222, 11528191); //blue text
|
||||
this.checkGlError("GUI: Draw text");
|
||||
|
@ -762,10 +793,11 @@ public class Minecraft implements Runnable, LevelLoaderListener {
|
|||
}
|
||||
|
||||
public class inputLevelName {
|
||||
JFrame f;
|
||||
JFrame f;
|
||||
public inputLevelName(){
|
||||
f=new JFrame();
|
||||
nameLevel=JOptionPane.showInputDialog(f,"Enter name for level.");
|
||||
f=new JFrame();
|
||||
System.out.println("A dialog asking for the level name should open.");
|
||||
nameLevel=JOptionPane.showInputDialog(f,"Please input the name for the level.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,9 +86,9 @@ public class Player extends Entity
|
|||
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.xd *= 0.825f;
|
||||
this.yd *= 0.825f;
|
||||
this.zd *= 0.825f;
|
||||
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;
|
||||
|
@ -98,9 +98,9 @@ public class Player extends Entity
|
|||
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.xd *= 0.65f;
|
||||
this.yd *= 0.65f;
|
||||
this.zd *= 0.65f;
|
||||
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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ public class Font
|
|||
img = ImageIO.read(Textures.class.getResourceAsStream(name));
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.out.println("Font couldn't load");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
final int w = img.getWidth();
|
||||
|
|
|
@ -11,12 +11,14 @@ 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.gui.Screen;
|
||||
import com.mojang.minecraft.gui.Font;
|
||||
import com.mojang.minecraft.level.LevelIO;
|
||||
|
||||
public class MenuScreen extends Screen
|
||||
{
|
||||
public Font font;
|
||||
private List<Button> buttons;
|
||||
public Textures textures;
|
||||
|
||||
|
@ -26,11 +28,11 @@ public class MenuScreen extends Screen
|
|||
|
||||
@Override
|
||||
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(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(4, this.width / 2 - 100, this.height / 4 + 128, 200, 20, "Exit"));
|
||||
//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
|
||||
|
@ -66,7 +68,10 @@ public class MenuScreen extends Screen
|
|||
|
||||
@Override
|
||||
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) {
|
||||
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);
|
||||
|
|
|
@ -26,7 +26,6 @@ public class PauseScreen extends Screen
|
|||
@Override
|
||||
public void init() {
|
||||
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(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.."));
|
||||
|
|
|
@ -26,6 +26,7 @@ public class LevelIO
|
|||
}
|
||||
|
||||
public boolean load(final Level level, final InputStream in) {
|
||||
System.out.println("Save file exists, loading.");
|
||||
this.levelLoaderListener.beginLevelLoading("Loading level");
|
||||
this.levelLoaderListener.levelLoadUpdate("Reading..");
|
||||
try {
|
||||
|
@ -53,8 +54,7 @@ public class LevelIO
|
|||
level.name = name;
|
||||
level.creator = creator;
|
||||
level.createTime = createTime;
|
||||
System.out.println("Level Loaded");
|
||||
System.out.println(level.name);
|
||||
System.out.println(level.name + " by " + level.creator + ". ");
|
||||
Minecraft.nameLevel = level.name;
|
||||
return true;
|
||||
}
|
||||
|
@ -66,7 +66,8 @@ public class LevelIO
|
|||
}
|
||||
|
||||
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..");
|
||||
try {
|
||||
final DataInputStream dis = new DataInputStream(new GZIPInputStream(in));
|
||||
|
@ -105,6 +106,7 @@ public class LevelIO
|
|||
dos.writeShort(level.depth);
|
||||
dos.write(level.blocks);
|
||||
dos.close();
|
||||
System.out.println("Saved.");
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -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) {
|
||||
System.out.println("Generating new level.");
|
||||
this.levelLoaderListener.beginLevelLoading("Generating level");
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
@ -50,7 +51,7 @@ public class LevelGen
|
|||
level.createTime = System.currentTimeMillis();
|
||||
level.creator = userName;
|
||||
level.name = levelName;
|
||||
System.out.println("Level Generated -" + level.name);
|
||||
System.out.println("Level Generated: " + level.name);
|
||||
Minecraft.nameLevel = level.name;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -55,10 +55,11 @@ public class Textures
|
|||
pixels.put(newPixels);
|
||||
pixels.position(0).limit(newPixels.length);
|
||||
GLU.gluBuild2DMipmaps(3553, 6408, w, h, 6408, 5121, pixels);
|
||||
System.out.println("Loaded texture " + (resourceName));
|
||||
return id;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException("!!");
|
||||
throw new RuntimeException("Couldn't load texture");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ public class Client implements ConnectionListener
|
|||
public Client(final MinecraftServer server, final SocketConnection serverConnection) {
|
||||
this.server = server;
|
||||
(this.serverConnection = serverConnection).setConnectionListener(this);
|
||||
System.out.println("Connection");
|
||||
}
|
||||
|
||||
public void command(final byte cmd, final int remaining, final ByteBuffer in) {
|
||||
|
@ -27,5 +28,6 @@ public class Client implements ConnectionListener
|
|||
|
||||
public void disconnect() {
|
||||
this.server.disconnect(this);
|
||||
System.out.println("Disconnection");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,17 +23,22 @@ public class MinecraftServer implements Runnable, ServerListener
|
|||
this.clientMap = new HashMap<SocketConnection, Client>();
|
||||
this.clients = new ArrayList<Client>();
|
||||
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) {
|
||||
final Client client = new Client(this, serverConnection);
|
||||
this.clientMap.put(serverConnection, client);
|
||||
this.clients.add(client);
|
||||
System.out.println("Server - Connection");
|
||||
}
|
||||
|
||||
public void disconnect(final Client client) {
|
||||
this.clientMap.remove(client.serverConnection);
|
||||
this.clients.remove(client);
|
||||
System.out.println("Server - Disconnection");
|
||||
}
|
||||
|
||||
public void clientException(final SocketConnection serverConnection, final Exception e) {
|
||||
|
@ -42,6 +47,7 @@ public class MinecraftServer implements Runnable, ServerListener
|
|||
}
|
||||
|
||||
public void run() {
|
||||
System.out.println("Running");
|
||||
while (true) {
|
||||
this.tick();
|
||||
try {
|
||||
|
@ -61,6 +67,7 @@ public class MinecraftServer implements Runnable, ServerListener
|
|||
}
|
||||
|
||||
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 Thread thread = new Thread(server);
|
||||
thread.start();
|
||||
|
|
BIN
src/terrain.png
BIN
src/terrain.png
Binary file not shown.
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 21 KiB |
Loading…
Reference in New Issue