Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Update to 24r04
Browse files Browse the repository at this point in the history
  • Loading branch information
CiroZDP committed Mar 18, 2024
1 parent bbd65b6 commit 4dafb5c
Show file tree
Hide file tree
Showing 42 changed files with 356 additions and 347 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/libraries/JOSL.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions opcraft/logs/latest.log
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
[12:50:33] [main/INFO]: Initializing the game...
[12:50:33] [main/INFO]: Game initializated!
[22:25:35] [main/INFO]: OpenCraft 24r03 started!
53 changes: 24 additions & 29 deletions src/main/java/net/opencraft/client/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
import static net.opencraft.LoggerConfig.handle;
import static net.opencraft.renderer.display.DisplayManager.destroyDisplay;

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Locale;
import java.util.logging.Logger;

import net.opencraft.config.GameConfig;
import net.opencraft.config.GameExperiments;
import net.opencraft.config.Workspace;
import net.opencraft.data.packs.DefaultPack;
import net.opencraft.data.packs.Pack;
import net.opencraft.renderer.RenderDragon;
import net.opencraft.renderer.Screen;
Expand All @@ -22,17 +21,17 @@
public class Game implements Runnable {

public static final String NAME = "OpenCraft";
public static final String VERSION = "24r03";
public static final String TITLE = NAME + ' ' + VERSION;
public static final String VERSION = "24r04";
public static final String TITLE = NAME + ((char) 0x20) + VERSION;

public static final int NANOSECONDS = 1000000000;
public static final double NANO_PER_TICK = NANOSECONDS / GameConfig.TICK_RATE;

private static Game instance;
private static Pack selected_pack;
public static final double NANO_PER_TICK = (double) NANOSECONDS / GameConfig.TICK_RATE;

private static final Game instance = new Game();
private static final Logger logger = Logger.getLogger("main");

private static Pack selected_pack = DefaultPack.getDefaultPack();

private boolean running = false;
private Screen screen;

Expand All @@ -41,12 +40,21 @@ public class Game implements Runnable {
System.setProperty("java.util.logging.SimpleFormatter.format", LOG_FORMAT);
handle(logger);
}

public void init() {
Thread.currentThread().setName("main");

RenderDragon.init();
this.screen = RenderDragon.getScreen();
Scene.setCurrent(Scene.LOAD_SCENE);

running = true;
}

@Override
public void run() {
logger.info("Initializing the game...");
init();
logger.info("Game initializated!");
logger.info(Game.TITLE + " started!");

long lastUpdate = System.nanoTime();

Expand Down Expand Up @@ -74,8 +82,8 @@ public void run() {
}

public void render() {
Graphics g = this.screen.getGraphics();
Scene.renderCurrent(g);
BufferedImage img = this.screen.getImage();
Scene.renderCurrent(img);
RenderDragon.update();
}

Expand All @@ -91,18 +99,6 @@ public void stop() {
destroyDisplay();
}

public void init() {
Thread.currentThread().setName("main");

Workspace.create();

RenderDragon.init();
screen = RenderDragon.getScreen();
Scene.setCurrent(Scene.LOAD_SCENE);

running = true;
}

public static Locale getLanguage() {
return GameConfig.LANGUAGE;
}
Expand Down Expand Up @@ -132,7 +128,7 @@ public static void selectPack(Pack pack) {
}

public static void useDefaultPack() {
selectPack(null);
selectPack(DefaultPack.getDefaultPack());
}

public static Pack getResourcePack() {
Expand All @@ -144,15 +140,14 @@ public static Game getInstance() {
}

public static boolean isDefaultPackSelected() {
return selected_pack == null;
return selected_pack instanceof DefaultPack;
}

public static BufferedImage screenshot() {
Game game = getInstance();
return game.screen.screenshot();
return getInstance().screen.screenshot();
}

public static void main(String[] args) throws IOException {
new Thread(instance = new Game()).start();
new Thread(instance).start();
}
}
1 change: 1 addition & 0 deletions src/main/java/net/opencraft/config/GameConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public class GameConfig {
public static byte TICK_RATE = 60;
public static boolean UNICODE = false;
public static Pack PACK_SELECTED = null;
public static String GAME_DIR = "opcraft";

}
2 changes: 1 addition & 1 deletion src/main/java/net/opencraft/config/GameExperiments.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ private GameExperiments() {
* This experiment skip completly the load screen.<br>
* Recommended for developers!
* */
public static final boolean SKIP_LOAD_SCENE = false;
public static final boolean SKIP_LOAD_SCENE = true;

}
77 changes: 0 additions & 77 deletions src/main/java/net/opencraft/config/Workspace.java

This file was deleted.

30 changes: 30 additions & 0 deletions src/main/java/net/opencraft/data/packs/DefaultPack.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.opencraft.data.packs;

import java.io.FileInputStream;
import java.io.InputStream;

public final class DefaultPack extends Pack {

private static final DefaultPack defaultPack = new DefaultPack();

public DefaultPack() {
}

public static Pack getDefaultPack() {
return DefaultPack.defaultPack;
}

@Override
public InputStream getResource(String resource) {
InputStream in = InputStream.nullInputStream();

System.out.println("Resource adquired: " + resource);
try {
in = new FileInputStream(resource);
} catch (Exception ignored) {
}

return in;
}

}
4 changes: 2 additions & 2 deletions src/main/java/net/opencraft/data/packs/Pack.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

import java.io.InputStream;

public interface Pack {
InputStream getResource(String resource);
public abstract class Pack {
public abstract InputStream getResource(String resource);
}
2 changes: 1 addition & 1 deletion src/main/java/net/opencraft/data/packs/ResourcePack.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.zip.ZipException;
import java.util.zip.ZipFile;

public class ResourcePack implements Pack {
public class ResourcePack extends Pack {

private ZipFile zfile;

Expand Down
Loading

0 comments on commit 4dafb5c

Please sign in to comment.