Removed references to classes within the Litecraft package from Ginger

pull/12/head
Caroline Bell 2020-03-02 22:15:23 -08:00
parent 77d3d14753
commit cab3121c7a
26 changed files with 194 additions and 223 deletions

View File

@ -18,9 +18,10 @@ import com.github.hydos.ginger.engine.common.info.RenderAPI;
import com.github.hydos.ginger.engine.common.io.Window; import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.common.obj.ModelLoader; import com.github.hydos.ginger.engine.common.obj.ModelLoader;
import com.github.hydos.ginger.engine.opengl.api.*; import com.github.hydos.ginger.engine.opengl.api.*;
import com.github.hydos.ginger.engine.opengl.postprocessing.PostProcessing;
import com.github.hydos.ginger.engine.opengl.render.MasterRenderer; import com.github.hydos.ginger.engine.opengl.render.MasterRenderer;
import com.github.hydos.ginger.engine.opengl.render.models.TexturedModel; import com.github.hydos.ginger.engine.opengl.render.models.TexturedModel;
import com.github.hydos.ginger.engine.opengl.utils.GlLoader; import com.github.hydos.ginger.engine.opengl.utils.GLLoader;
import tk.valoeghese.gateways.client.io.*; import tk.valoeghese.gateways.client.io.*;
@ -30,14 +31,10 @@ public class Litecraft extends Game
private World world; private World world;
private LitecraftSave save; private LitecraftSave save;
private GingerGL engine; private GingerGL engine;
public PlayerEntity playerEntity;
private Camera camera;
public int fps, ups, tps; public int fps, ups, tps;
public Vector4i dbgStats = new Vector4i(); public Vector4i dbgStats = new Vector4i();
private long frameTimer; private long frameTimer;
public int threadWaitlist = 0;
public Litecraft() public Litecraft()
{ {
Litecraft.INSTANCE = this; Litecraft.INSTANCE = this;
@ -61,7 +58,7 @@ public class Litecraft extends Game
System.out.println("Saving chunks..."); System.out.println("Saving chunks...");
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
this.world.unloadAllChunks(); this.world.unloadAllChunks();
this.getSave().saveGlobalData(this.world.getSeed(), this.playerEntity); this.getSave().saveGlobalData(this.world.getSeed(), ((PlayerEntity) this.player));
System.out.println("Saved world in " + (System.currentTimeMillis() - time) + " milliseconds"); System.out.println("Saved world in " + (System.currentTimeMillis() - time) + " milliseconds");
} }
engine.cleanup(); engine.cleanup();
@ -80,7 +77,7 @@ public class Litecraft extends Game
// Render shadows // Render shadows
GingerRegister.getInstance().masterRenderer.renderShadowMap(data.entities, data.lights.get(0)); GingerRegister.getInstance().masterRenderer.renderShadowMap(data.entities, data.lights.get(0));
// If there's a world, render it! // If there's a world, render it!
if (this.world != null) this.engine.renderWorld(this); if (this.world != null) renderWorld(this);
// Render any overlays (GUIs, HUDs) // Render any overlays (GUIs, HUDs)
this.engine.renderOverlays(this); this.engine.renderOverlays(this);
// Put what's stored in the inactive framebuffer on the screen // Put what's stored in the inactive framebuffer on the screen
@ -90,16 +87,27 @@ public class Litecraft extends Game
// Updates the debug stats once per real-time second, regardless of how many frames have been rendered // Updates the debug stats once per real-time second, regardless of how many frames have been rendered
private void updateDebugStats() private void updateDebugStats()
{ {
this.dbgStats.set(fps, ups, tps, threadWaitlist); this.dbgStats.set(fps, ups, tps, 0);
this.fps=0; this.fps=0;
this.ups=0; this.ups=0;
this.tps=0; this.tps=0;
this.frameTimer += 1000; this.frameTimer += 1000;
} }
public void renderWorld(Game game)
{
GameData data = game.data;
GingerUtils.preRenderScene(engine.getRegistry().masterRenderer);
engine.contrastFbo.bindFBO();
engine.getRegistry().masterRenderer.renderScene(data.entities, data.normalMapEntities, data.lights, data.camera, data.clippingPlane);
engine.contrastFbo.unbindFBO();
PostProcessing.doPostProcessing(engine.contrastFbo.colorTexture);
if (data.handleGuis) engine.renderOverlays(game);
}
public void update() public void update()
{ {
Input.invokeAllListeners(); ups += 1;
} }
private void setupConstants() private void setupConstants()
@ -124,17 +132,17 @@ public class Litecraft extends Game
//Set the player model //Set the player model
TexturedModel playerModel = ModelLoader.loadGenericCube("block/cubes/stone/brick/stonebrick.png"); TexturedModel playerModel = ModelLoader.loadGenericCube("block/cubes/stone/brick/stonebrick.png");
Light sun = new Light(new Vector3f(0, 105, 0), new Vector3f(0.9765625f, 0.98828125f, 0.05859375f), new Vector3f(0.002f, 0.002f, 0.002f)); Light sun = new Light(new Vector3f(0, 105, 0), new Vector3f(0.9765625f, 0.98828125f, 0.05859375f), new Vector3f(0.002f, 0.002f, 0.002f));
FontType font = new FontType(GlLoader.loadFontAtlas("candara.png"), "candara.fnt"); FontType font = new FontType(GLLoader.loadFontAtlas("candara.png"), "candara.fnt");
this.engine = new GingerGL(); this.engine = new GingerGL();
this.playerEntity = new PlayerEntity(playerModel, new Vector3f(0, 0, -3), 0, 180f, 0, new Vector3f(0.2f, 0.2f, 0.2f)); this.player = new PlayerEntity(playerModel, new Vector3f(0, 0, -3), 0, 180f, 0, new Vector3f(0.2f, 0.2f, 0.2f));
this.camera = new FirstPersonCamera(playerEntity); this.camera = new FirstPersonCamera(player);
this.playerEntity.setVisible(false); this.player.setVisible(false);
this.data = new GameData(this.playerEntity, this.camera, 20); this.data = new GameData(this.player, this.camera, 20);
this.data.handleGuis = false; this.data.handleGuis = false;
this.engine.setup(new MasterRenderer(this.camera), INSTANCE); this.engine.setup(new MasterRenderer(this.camera), INSTANCE);
this.engine.setGlobalFont(font); this.engine.setGlobalFont(font);
this.data.lights.add(sun); this.data.lights.add(sun);
this.data.entities.add(this.playerEntity); this.data.entities.add(this.player);
} }
} }
@ -143,12 +151,12 @@ public class Litecraft extends Game
Input.addPressCallback(Keybind.EXIT, this::exit); Input.addPressCallback(Keybind.EXIT, this::exit);
Input.addInitialPressCallback(Keybind.FULLSCREEN, Window::fullscreen); Input.addInitialPressCallback(Keybind.FULLSCREEN, Window::fullscreen);
Input.addInitialPressCallback(Keybind.WIREFRAME, GingerRegister.getInstance()::toggleWireframe); Input.addInitialPressCallback(Keybind.WIREFRAME, GingerRegister.getInstance()::toggleWireframe);
Input.addPressCallback(Keybind.MOVE_FORWARD, () -> this.playerEntity.move(RelativeDirection.FORWARD)); Input.addPressCallback(Keybind.MOVE_FORWARD, () -> ((PlayerEntity) this.player).move(RelativeDirection.FORWARD));
Input.addPressCallback(Keybind.MOVE_BACKWARD, () -> this.playerEntity.move(RelativeDirection.BACKWARD)); Input.addPressCallback(Keybind.MOVE_BACKWARD, () -> ((PlayerEntity) this.player).move(RelativeDirection.BACKWARD));
Input.addPressCallback(Keybind.STRAFE_LEFT, () -> this.playerEntity.move(RelativeDirection.LEFT)); Input.addPressCallback(Keybind.STRAFE_LEFT, () -> ((PlayerEntity) this.player).move(RelativeDirection.LEFT));
Input.addPressCallback(Keybind.STRAFE_RIGHT, () -> this.playerEntity.move(RelativeDirection.RIGHT)); Input.addPressCallback(Keybind.STRAFE_RIGHT, () -> ((PlayerEntity) this.player).move(RelativeDirection.RIGHT));
Input.addPressCallback(Keybind.FLY_UP, () -> this.playerEntity.move(RelativeDirection.UP)); Input.addPressCallback(Keybind.FLY_UP, () -> ((PlayerEntity) this.player).move(RelativeDirection.UP));
Input.addPressCallback(Keybind.FLY_DOWN, () -> this.playerEntity.move(RelativeDirection.DOWN)); Input.addPressCallback(Keybind.FLY_DOWN, () -> ((PlayerEntity) this.player).move(RelativeDirection.DOWN));
} }
/** /**
@ -158,13 +166,14 @@ public class Litecraft extends Game
@Override @Override
public void tick() public void tick()
{ {
tps += 1;
// Open the title screen if it's not already open. // Open the title screen if it's not already open.
if (GingerRegister.getInstance().currentScreen == null && world == null) if (GingerRegister.getInstance().currentScreen == null && world == null) engine.openScreen(new TitleScreen());
engine.openScreen(new TitleScreen());
if (data.playerEntity != null && data.camera != null) if (this.player instanceof PlayerEntity && camera != null)
{ {
data.playerEntity.updateMovement(); Input.invokeAllListeners();
((PlayerEntity) this.player).updateMovement();
data.camera.updateMovement(); data.camera.updateMovement();
} }
} }
@ -187,4 +196,10 @@ public class Litecraft extends Game
public void setSave(LitecraftSave save) public void setSave(LitecraftSave save)
{ this.save = save; } { this.save = save; }
@Override
public void renderScene()
{
world.render(GingerRegister.getInstance().masterRenderer.blockRenderer);
}
} }

View File

@ -1,10 +1,8 @@
package com.github.hydos.ginger; package com.github.halotroop.litecraft;
import org.lwjgl.Version; import org.lwjgl.Version;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import com.github.halotroop.litecraft.Litecraft;
public class Starter public class Starter
{ {
// private static final boolean usingEclipse = false; // private static final boolean usingEclipse = false;

View File

@ -1,4 +1,4 @@
package com.github.halotroop.litecraft.world.block; package com.github.halotroop.litecraft.render;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.lwjgl.opengl.*; import org.lwjgl.opengl.*;
@ -12,7 +12,6 @@ import com.github.hydos.ginger.engine.common.math.Maths;
import com.github.hydos.ginger.engine.opengl.render.Renderer; import com.github.hydos.ginger.engine.opengl.render.Renderer;
import com.github.hydos.ginger.engine.opengl.render.models.TexturedModel; import com.github.hydos.ginger.engine.opengl.render.models.TexturedModel;
import com.github.hydos.ginger.engine.opengl.render.shaders.StaticShader; import com.github.hydos.ginger.engine.opengl.render.shaders.StaticShader;
import com.github.hydos.ginger.engine.opengl.utils.GlLoader;
public class BlockRenderer extends Renderer implements WorldGenConstants public class BlockRenderer extends Renderer implements WorldGenConstants
{ {
@ -25,7 +24,7 @@ public class BlockRenderer extends Renderer implements WorldGenConstants
shader.start(); shader.start();
shader.loadProjectionMatrix(projectionMatrix); shader.loadProjectionMatrix(projectionMatrix);
shader.stop(); shader.stop();
this.atlasID = GlLoader.createBlockAtlas(); this.atlasID = VoxelLoader.createBlockAtlas();
} }
private void prepBlockInstance(RenderObject entity) private void prepBlockInstance(RenderObject entity)

View File

@ -0,0 +1,51 @@
package com.github.halotroop.litecraft.render;
import java.nio.ByteBuffer;
import org.lwjgl.opengl.*;
import com.github.halotroop.litecraft.types.block.*;
import com.github.hydos.ginger.engine.opengl.utils.GLLoader;
public class VoxelLoader extends GLLoader
{
public static int createBlockAtlas()
{
int width = 16;
int height = 16;
//Prepare the atlas texture and gen it
int atlasId = GL40.glGenTextures();
//Bind it to openGL
GL40.glBindTexture(GL40.GL_TEXTURE_2D, atlasId);
//Apply the settings for the texture
GL40.glTexParameteri(GL40.GL_TEXTURE_2D, GL40.GL_TEXTURE_MIN_FILTER, GL40.GL_NEAREST);
GL40.glTexParameteri(GL40.GL_TEXTURE_2D, GL40.GL_TEXTURE_MAG_FILTER, GL40.GL_NEAREST);
//Fill the image with blank image data
GL40.glTexImage2D(GL40.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width*2, height*2, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
long maxX = Math.round(Math.sqrt(Blocks.blocks.size()));
int currentX = 0;
int currentY = 0;
for(Block block: Blocks.blocks) {
//just in case
if(!block.texture.equals("DONTLOAD")) {
System.out.println(block.texture);
block.updateBlockModelData();
if(currentX > maxX) {
currentX = 0;
currentY--;
}
GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0,
currentX*width, currentY*height,
width, height,
GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE,
block.model.getTexture().getTexture().getImage()
);
currentX++;
}
}
return atlasId;
}
}

View File

@ -37,7 +37,7 @@ public class IngameHUD extends Screen
long freeMemory = Runtime.getRuntime().freeMemory(); long freeMemory = Runtime.getRuntime().freeMemory();
long usedMemory = (totalMemory - freeMemory) / 1024 / 1024; long usedMemory = (totalMemory - freeMemory) / 1024 / 1024;
Vector4i dbg = litecraft.dbgStats; Vector4i dbg = litecraft.dbgStats;
Vector3f position = GingerRegister.getInstance().game.data.playerEntity.getPosition(); Vector3f position = GingerRegister.getInstance().game.data.playerObject.getPosition();
debugText.setText("FPS: " + dbg.x() + " UPS: " + dbg.y() + " TPS: " + dbg.z() + " TWL: " + dbg.w() + " Mem: " + usedMemory + "MB"); debugText.setText("FPS: " + dbg.x() + " UPS: " + dbg.y() + " TPS: " + dbg.z() + " TWL: " + dbg.w() + " Mem: " + usedMemory + "MB");
positionText.setText("Position: " + (int) position.x() + ", " + (int) position.y() + ", "+ (int) position.z() ); positionText.setText("Position: " + (int) position.x() + ", " + (int) position.y() + ", "+ (int) position.z() );
} }

View File

@ -20,16 +20,16 @@ import com.github.hydos.ginger.engine.opengl.api.GingerGL;
public class TitleScreen extends Screen public class TitleScreen extends Screen
{ {
private GUIText debugText; private GUIText debugText;
private GingerGL ginger3D = GingerGL.getInstance(); private GingerGL engine = GingerGL.getInstance();
private TextureButton playButton; private TextureButton playButton;
private Litecraft litecraft = Litecraft.getInstance(); private Litecraft litecraft = Litecraft.getInstance();
public TitleScreen() public TitleScreen()
{ {
elements = new ArrayList<GuiTexture>(); elements = new ArrayList<GuiTexture>();
playButton = ginger3D.registerButton("/textures/guis/playbutton.png", new Vector2f(0, 0), new Vector2f(0.25f, 0.1f)); playButton = engine.registerButton("/textures/guis/playbutton.png", new Vector2f(0, 0), new Vector2f(0.25f, 0.1f));
playButton.show(Litecraft.getInstance().data.guis); playButton.show(Litecraft.getInstance().data.guis);
debugText = ginger3D.registerText("Loading...", 2, new Vector2f(0, 0), 1f, true, "debugInfo"); debugText = engine.registerText("Loading...", 2, new Vector2f(0, 0), 1f, true, "debugInfo");
debugText.setBorderWidth(0.5f); debugText.setBorderWidth(0.5f);
} }
@ -51,11 +51,11 @@ public class TitleScreen extends Screen
{ {
Litecraft.getInstance().setSave(new LitecraftSave("SegregatedOrdinalData", false)); Litecraft.getInstance().setSave(new LitecraftSave("SegregatedOrdinalData", false));
Litecraft.getInstance().changeWorld(Litecraft.getInstance().getSave().getWorldOrCreate(Dimensions.OVERWORLD)); Litecraft.getInstance().changeWorld(Litecraft.getInstance().getSave().getWorldOrCreate(Dimensions.OVERWORLD));
ginger3D.setGingerPlayer(Litecraft.getInstance().getWorld().playerEntity); engine.setGingerPlayer(Litecraft.getInstance().getWorld().playerEntity);
} }
if (Litecraft.getInstance().getWorld() != null) if (Litecraft.getInstance().getWorld() != null)
{ {
ginger3D.openScreen(new IngameHUD()); engine.openScreen(new IngameHUD());
this.cleanup(); this.cleanup();
} }
//TODO: add world creation gui so it takes u to world creation place //TODO: add world creation gui so it takes u to world creation place

View File

@ -30,8 +30,8 @@ public class PlayerEntity extends Entity implements WorldGenConstants
float ry = (float) Math.toRadians(GingerRegister.getInstance().game.data.camera.getYaw()); float ry = (float) Math.toRadians(GingerRegister.getInstance().game.data.camera.getYaw());
switch (direction) switch (direction)
{ {
case FORWARD:
default: default:
case FORWARD:
position.z -= Math.cos(ry) * Constants.movementSpeed; position.z -= Math.cos(ry) * Constants.movementSpeed;
position.x += Math.sin(ry) * Constants.movementSpeed; position.x += Math.sin(ry) * Constants.movementSpeed;
break; break;

View File

@ -6,8 +6,8 @@ import java.util.function.ToIntFunction;
import org.joml.Vector3f; import org.joml.Vector3f;
import com.github.halotroop.litecraft.logic.SODSerializable; import com.github.halotroop.litecraft.logic.SODSerializable;
import com.github.halotroop.litecraft.render.BlockRenderer;
import com.github.halotroop.litecraft.types.block.*; import com.github.halotroop.litecraft.types.block.*;
import com.github.halotroop.litecraft.world.block.BlockRenderer;
import com.github.halotroop.litecraft.world.gen.WorldGenConstants; import com.github.halotroop.litecraft.world.gen.WorldGenConstants;
import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.ints.*;

View File

@ -10,10 +10,10 @@ import java.util.function.LongConsumer;
import org.joml.Vector3f; import org.joml.Vector3f;
import com.github.halotroop.litecraft.render.BlockRenderer;
import com.github.halotroop.litecraft.save.LitecraftSave; import com.github.halotroop.litecraft.save.LitecraftSave;
import com.github.halotroop.litecraft.types.block.*; import com.github.halotroop.litecraft.types.block.*;
import com.github.halotroop.litecraft.types.entity.PlayerEntity; import com.github.halotroop.litecraft.types.entity.PlayerEntity;
import com.github.halotroop.litecraft.world.block.BlockRenderer;
import com.github.halotroop.litecraft.world.dimension.Dimension; import com.github.halotroop.litecraft.world.dimension.Dimension;
import com.github.halotroop.litecraft.world.gen.*; import com.github.halotroop.litecraft.world.gen.*;
import com.github.halotroop.litecraft.world.gen.modifier.WorldModifier; import com.github.halotroop.litecraft.world.gen.modifier.WorldModifier;

View File

@ -1,8 +1,13 @@
package com.github.hydos.ginger.engine.common.api.game; package com.github.hydos.ginger.engine.common.api.game;
import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.common.elements.objects.RenderObject;
public abstract class Game public abstract class Game
{ {
public GameData data; public GameData data;
public RenderObject player; // FIXME: @hYdos you know these probably don't need to be here, but the game stops working when they're not.
public Camera camera;
public Game() public Game()
{} {}
@ -11,6 +16,8 @@ public abstract class Game
public abstract void render(); public abstract void render();
public abstract void renderScene();
public abstract void tick(); public abstract void tick();
public abstract void update(); public abstract void update();

View File

@ -4,7 +4,6 @@ import java.util.*;
import org.joml.Vector4f; import org.joml.Vector4f;
import com.github.halotroop.litecraft.types.entity.PlayerEntity;
import com.github.hydos.ginger.engine.common.cameras.Camera; import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.common.elements.GuiTexture; import com.github.hydos.ginger.engine.common.elements.GuiTexture;
import com.github.hydos.ginger.engine.common.elements.objects.*; import com.github.hydos.ginger.engine.common.elements.objects.*;
@ -19,20 +18,20 @@ public class GameData
public List<RenderObject> entities; public List<RenderObject> entities;
public List<Light> lights; public List<Light> lights;
public List<RenderObject> normalMapEntities; public List<RenderObject> normalMapEntities;
public PlayerEntity playerEntity; public RenderObject playerObject;
public Camera camera; public Camera camera;
public Vector4f clippingPlane; public Vector4f clippingPlane;
public boolean handleGuis = true; public boolean handleGuis = true;
public int tickSpeed = 20; public int tickSpeed = 20;
public GameData(PlayerEntity playerEntity, Camera camera, int tickSpeed) public GameData(RenderObject playerEntity, Camera camera, int tickSpeed)
{ {
clippingPlane = new Vector4f(0, -1, 0, 100000); clippingPlane = new Vector4f(0, -1, 0, 100000);
guis = new ArrayList<GuiTexture>(); guis = new ArrayList<GuiTexture>();
entities = new ArrayList<RenderObject>(); entities = new ArrayList<RenderObject>();
lights = new ArrayList<Light>(); lights = new ArrayList<Light>();
normalMapEntities = new ArrayList<RenderObject>(); normalMapEntities = new ArrayList<RenderObject>();
this.playerEntity = playerEntity; this.playerObject = playerEntity;
this.camera = camera; this.camera = camera;
this.tickSpeed = tickSpeed; this.tickSpeed = tickSpeed;
} }

View File

@ -3,7 +3,7 @@ package com.github.hydos.ginger.engine.common.cameras;
import org.joml.Vector3f; import org.joml.Vector3f;
import org.lwjgl.glfw.*; import org.lwjgl.glfw.*;
import com.github.halotroop.litecraft.types.entity.PlayerEntity; import com.github.hydos.ginger.engine.common.elements.objects.RenderObject;
import com.github.hydos.ginger.engine.common.io.Window; import com.github.hydos.ginger.engine.common.io.Window;
public class Camera public class Camera
@ -13,15 +13,15 @@ public class Camera
private Vector3f position = new Vector3f(0, 0, 0); private Vector3f position = new Vector3f(0, 0, 0);
private float pitch, yaw; private float pitch, yaw;
private float roll; private float roll;
public PlayerEntity playerEntity; public RenderObject player;
public Camera(PlayerEntity playerEntity) public Camera(RenderObject playerEntity)
{ this.playerEntity = playerEntity; } { this.player = playerEntity; }
public Camera(Vector3f vector3f, PlayerEntity playerEntity) public Camera(Vector3f vector3f, RenderObject player)
{ {
this.position = vector3f; this.position = vector3f;
this.playerEntity = playerEntity; this.player = player;
} }
private void calculateAngleAroundPlayer() private void calculateAngleAroundPlayer()
@ -35,12 +35,12 @@ public class Camera
private void calculateCameraPosition(float horizDistance, float verticDistance) private void calculateCameraPosition(float horizDistance, float verticDistance)
{ {
float theta = playerEntity.getRotY() + angleAroundPlayer; float theta = player.getRotY() + angleAroundPlayer;
float offsetX = (float) (horizDistance * Math.sin(Math.toRadians(theta))); float offsetX = (float) (horizDistance * Math.sin(Math.toRadians(theta)));
float offsetZ = (float) (horizDistance * Math.cos(Math.toRadians(theta))); float offsetZ = (float) (horizDistance * Math.cos(Math.toRadians(theta)));
position.x = playerEntity.getPosition().x - offsetX; position.x = player.getPosition().x - offsetX;
position.z = playerEntity.getPosition().z - offsetZ; position.z = player.getPosition().z - offsetZ;
position.y = playerEntity.getPosition().y + verticDistance; position.y = player.getPosition().y + verticDistance;
} }
private float calculateHorizontalDistance() private float calculateHorizontalDistance()
@ -105,7 +105,7 @@ public class Camera
float horizontalDistance = calculateHorizontalDistance(); float horizontalDistance = calculateHorizontalDistance();
float verticalDistance = calculateVerticalDistance(); float verticalDistance = calculateVerticalDistance();
calculateCameraPosition(horizontalDistance, verticalDistance); calculateCameraPosition(horizontalDistance, verticalDistance);
this.yaw = 180 - (playerEntity.getRotY() + angleAroundPlayer); this.yaw = 180 - (player.getRotY() + angleAroundPlayer);
} }
public void setPitch(float pitch) public void setPitch(float pitch)

View File

@ -2,7 +2,7 @@ package com.github.hydos.ginger.engine.common.cameras;
import org.joml.Vector3f; import org.joml.Vector3f;
import com.github.halotroop.litecraft.types.entity.PlayerEntity; import com.github.hydos.ginger.engine.common.elements.objects.RenderObject;
import com.github.hydos.ginger.engine.common.io.Window; import com.github.hydos.ginger.engine.common.io.Window;
public class FirstPersonCamera extends Camera public class FirstPersonCamera extends Camera
@ -11,7 +11,7 @@ public class FirstPersonCamera extends Camera
private float pitch, yaw; private float pitch, yaw;
private float roll; private float roll;
public FirstPersonCamera(PlayerEntity playerEntity) public FirstPersonCamera(RenderObject playerEntity)
{ {
super(playerEntity); super(playerEntity);
playerEntity.setVisible(false); playerEntity.setVisible(false);
@ -36,11 +36,11 @@ public class FirstPersonCamera extends Camera
@Override @Override
public void updateMovement() public void updateMovement()
{ {
position.x = playerEntity.getPosition().x; position.x = player.getPosition().x;
position.z = playerEntity.getPosition().z; position.z = player.getPosition().z;
position.y = playerEntity.getPosition().y; position.y = player.getPosition().y;
roll = playerEntity.getRotX(); roll = player.getRotX();
yaw = -playerEntity.getRotY() + 180 + Window.getNormalizedMouseCoordinates().x() * 70; yaw = -player.getRotY() + 180 + Window.getNormalizedMouseCoordinates().x() * 70;
pitch = playerEntity.getRotZ() + -Window.getNormalizedMouseCoordinates().y() * 70; pitch = player.getRotZ() + -Window.getNormalizedMouseCoordinates().y() * 70;
} }
} }

View File

@ -7,7 +7,7 @@ import org.lwjgl.glfw.GLFW;
import com.github.hydos.ginger.engine.common.elements.GuiTexture; import com.github.hydos.ginger.engine.common.elements.GuiTexture;
import com.github.hydos.ginger.engine.common.io.Window; import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.opengl.utils.GlLoader; import com.github.hydos.ginger.engine.opengl.utils.GLLoader;
public class TextureButton public class TextureButton
{ {
@ -20,7 +20,7 @@ public class TextureButton
public TextureButton(String texture, Vector2f position, Vector2f scale) public TextureButton(String texture, Vector2f position, Vector2f scale)
{ {
resourceLocation = texture; resourceLocation = texture;
guiTexture = new GuiTexture(GlLoader.loadTextureDirectly(texture), position, scale); guiTexture = new GuiTexture(GLLoader.loadTextureDirectly(texture), position, scale);
} }
public void hide(List<GuiTexture> guiTextureList) public void hide(List<GuiTexture> guiTextureList)

View File

@ -4,7 +4,7 @@ import java.util.*;
import com.github.hydos.ginger.engine.opengl.api.GingerGL; import com.github.hydos.ginger.engine.opengl.api.GingerGL;
import com.github.hydos.ginger.engine.opengl.render.renderers.FontRenderer; import com.github.hydos.ginger.engine.opengl.render.renderers.FontRenderer;
import com.github.hydos.ginger.engine.opengl.utils.GlLoader; import com.github.hydos.ginger.engine.opengl.utils.GLLoader;
public class TextMaster public class TextMaster
{ {
@ -21,7 +21,7 @@ public class TextMaster
{ {
FontType font = text.getFont(); FontType font = text.getFont();
TextMeshData data = font.loadText(text); TextMeshData data = font.loadText(text);
int vao = GlLoader.loadToVAO(data.getVertexPositions(), data.getTextureCoords()); int vao = GLLoader.loadToVAO(data.getVertexPositions(), data.getTextureCoords());
text.setMeshInfo(vao, data.getVertexCount()); text.setMeshInfo(vao, data.getVertexCount());
List<GUIText> textBatch = texts.get(font); List<GUIText> textBatch = texts.get(font);
if (textBatch == null) if (textBatch == null)

View File

@ -3,20 +3,20 @@ package com.github.hydos.ginger.engine.common.obj;
import com.github.hydos.ginger.engine.common.obj.shapes.StaticCube; import com.github.hydos.ginger.engine.common.obj.shapes.StaticCube;
import com.github.hydos.ginger.engine.opengl.render.models.TexturedModel; import com.github.hydos.ginger.engine.opengl.render.models.TexturedModel;
import com.github.hydos.ginger.engine.opengl.render.texture.ModelTexture; import com.github.hydos.ginger.engine.opengl.render.texture.ModelTexture;
import com.github.hydos.ginger.engine.opengl.utils.GlLoader; import com.github.hydos.ginger.engine.opengl.utils.GLLoader;
public class ModelLoader public class ModelLoader
{ {
public static TexturedModel loadGenericCube(String cubeTexture) public static TexturedModel loadGenericCube(String cubeTexture)
{ {
Mesh data = StaticCube.getCube(); Mesh data = StaticCube.getCube();
TexturedModel tm = new TexturedModel(GlLoader.loadToVAO(data.getVertices(), data.getIndices(), data.getNormals(), data.getTextureCoords()), new ModelTexture(cubeTexture)); TexturedModel tm = new TexturedModel(GLLoader.loadToVAO(data.getVertices(), data.getIndices(), data.getNormals(), data.getTextureCoords()), new ModelTexture(cubeTexture));
return tm; return tm;
} }
public static TexturedModel loadModel(String objPath, String texturePath) public static TexturedModel loadModel(String objPath, String texturePath)
{ {
Mesh data = OBJFileLoader.loadModel(objPath); Mesh data = OBJFileLoader.loadModel(objPath);
return new TexturedModel(GlLoader.loadToVAO(data.getVertices(), data.getIndices(), data.getNormals(), data.getTextureCoords()), new ModelTexture(texturePath)); return new TexturedModel(GLLoader.loadToVAO(data.getVertices(), data.getIndices(), data.getNormals(), data.getTextureCoords()), new ModelTexture(texturePath));
} }
} }

View File

@ -6,7 +6,7 @@ import java.util.*;
import org.joml.*; import org.joml.*;
import com.github.hydos.ginger.engine.opengl.render.models.RawModel; import com.github.hydos.ginger.engine.opengl.render.models.RawModel;
import com.github.hydos.ginger.engine.opengl.utils.GlLoader; import com.github.hydos.ginger.engine.opengl.utils.GLLoader;
public class NormalMappedObjLoader public class NormalMappedObjLoader
{ {
@ -133,7 +133,7 @@ public class NormalMappedObjLoader
float[] normalsArray = new float[vertices.size() * 3]; float[] normalsArray = new float[vertices.size() * 3];
float[] tangentsArray = new float[vertices.size() * 3]; float[] tangentsArray = new float[vertices.size() * 3];
int[] indicesArray = convertIndicesListToArray(indices); int[] indicesArray = convertIndicesListToArray(indices);
return GlLoader.loadToVAO(verticesArray, indicesArray, normalsArray, tangentsArray, texturesArray); return GLLoader.loadToVAO(verticesArray, indicesArray, normalsArray, tangentsArray, texturesArray);
} }
private static VertexNM processVertex(String[] vertex, List<VertexNM> vertices, private static VertexNM processVertex(String[] vertex, List<VertexNM> vertices,

View File

@ -1,17 +1,13 @@
package com.github.halotroop.litecraft.logic; package com.github.hydos.ginger.engine.common.util;
import java.util.*; import java.util.*;
import com.github.hydos.multithreading.GingerThread; /** @author Jack Wilsdon (Stack Exchange)
* https://codereview.stackexchange.com/questions/111855/ticker-for-game-timing */
/** public class Timer
* @author Jack Wilsdon (Stack Exchange) {
* https://codereview.stackexchange.com/questions/111855/ticker-for-game-timing public void run()
*/
public class Timer extends GingerThread
{ {
@Override
public void run() {
for (TickListener listener : tickListeners) for (TickListener listener : tickListeners)
{ listener.onTick(deltaTime); } { listener.onTick(deltaTime); }
} }

View File

@ -2,20 +2,19 @@ package com.github.hydos.ginger.engine.opengl.api;
import org.joml.Vector2f; import org.joml.Vector2f;
import com.github.halotroop.litecraft.Litecraft;
import com.github.halotroop.litecraft.logic.Timer;
import com.github.halotroop.litecraft.logic.Timer.TickListener;
import com.github.halotroop.litecraft.types.entity.PlayerEntity;
import com.github.hydos.ginger.engine.common.api.GingerRegister; import com.github.hydos.ginger.engine.common.api.GingerRegister;
import com.github.hydos.ginger.engine.common.api.game.*; import com.github.hydos.ginger.engine.common.api.game.*;
import com.github.hydos.ginger.engine.common.elements.buttons.TextureButton; import com.github.hydos.ginger.engine.common.elements.buttons.TextureButton;
import com.github.hydos.ginger.engine.common.elements.objects.RenderObject;
import com.github.hydos.ginger.engine.common.font.*; import com.github.hydos.ginger.engine.common.font.*;
import com.github.hydos.ginger.engine.common.io.Window; import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.common.screen.Screen; import com.github.hydos.ginger.engine.common.screen.Screen;
import com.github.hydos.ginger.engine.common.tools.MousePicker; import com.github.hydos.ginger.engine.common.tools.MousePicker;
import com.github.hydos.ginger.engine.common.util.Timer;
import com.github.hydos.ginger.engine.common.util.Timer.TickListener;
import com.github.hydos.ginger.engine.opengl.postprocessing.*; import com.github.hydos.ginger.engine.opengl.postprocessing.*;
import com.github.hydos.ginger.engine.opengl.render.MasterRenderer; import com.github.hydos.ginger.engine.opengl.render.MasterRenderer;
import com.github.hydos.ginger.engine.opengl.utils.GlLoader; import com.github.hydos.ginger.engine.opengl.utils.GLLoader;
public class GingerGL public class GingerGL
{ {
@ -31,8 +30,8 @@ public class GingerGL
@Override @Override
public void onTick(float deltaTime) public void onTick(float deltaTime)
{ {
if (registry.game != null) registry.game.tick(); if (getRegistry().game != null) getRegistry().game.tick();
if (registry.currentScreen != null) registry.currentScreen.tick(); if (getRegistry().currentScreen != null) getRegistry().currentScreen.tick();
}; };
}; };
@ -40,30 +39,30 @@ public class GingerGL
{ {
Window.stop(); Window.stop();
PostProcessing.cleanUp(); PostProcessing.cleanUp();
registry.masterRenderer.cleanUp(); getRegistry().masterRenderer.cleanUp();
TextMaster.cleanUp(); TextMaster.cleanUp();
GlLoader.cleanUp(); GLLoader.cleanUp();
} }
public void openScreen(Screen screen) public void openScreen(Screen screen)
{ {
if (registry.currentScreen != null) registry.currentScreen.cleanup(); if (getRegistry().currentScreen != null) getRegistry().currentScreen.cleanup();
registry.currentScreen = screen; getRegistry().currentScreen = screen;
} }
public void setGingerPlayer(PlayerEntity playerEntity) public void setGingerPlayer(RenderObject player)
{ {
registry.game.data.entities.remove(Litecraft.getInstance().playerEntity); // remove the old player registry.game.data.entities.remove(registry.game.player); // remove the old player
registry.game.data.playerEntity = playerEntity; // set all the player variables registry.game.data.playerObject = player; // set all the player variables
Litecraft.getInstance().playerEntity = playerEntity; registry.game.player = player;
Litecraft.getInstance().getCamera().playerEntity = playerEntity; registry.game.camera.player = player;
registry.game.data.entities.add(playerEntity); // add the new player registry.game.data.entities.add(player); // add the new player
} }
public TextureButton registerButton(String resourceLocation, Vector2f position, Vector2f scale) public TextureButton registerButton(String resourceLocation, Vector2f position, Vector2f scale)
{ {
TextureButton button = new TextureButton(resourceLocation, position, scale); TextureButton button = new TextureButton(resourceLocation, position, scale);
registry.registerButton(button); getRegistry().registerButton(button);
return button; return button;
} }
@ -71,28 +70,17 @@ public class GingerGL
{ {
GUIText text = new GUIText(string, textSize, globalFont, position, maxLineLength, false); GUIText text = new GUIText(string, textSize, globalFont, position, maxLineLength, false);
text.textID = id; text.textID = id;
registry.registerText(text); getRegistry().registerText(text);
return text; return text;
} }
public void renderOverlays(Game game) public void renderOverlays(Game game)
{ {
registry.masterRenderer.renderGuis(game.data.guis); getRegistry().masterRenderer.renderGuis(game.data.guis);
if (registry.currentScreen != null) registry.masterRenderer.renderGuis(registry.currentScreen.elements); if (getRegistry().currentScreen != null) getRegistry().masterRenderer.renderGuis(getRegistry().currentScreen.elements);
TextMaster.render(); TextMaster.render();
} }
public void renderWorld(Litecraft game)
{
GameData data = game.data;
GingerUtils.preRenderScene(registry.masterRenderer);
contrastFbo.bindFBO();
registry.masterRenderer.renderScene(data.entities, data.normalMapEntities, data.lights, data.camera, data.clippingPlane, game.getWorld());
contrastFbo.unbindFBO();
PostProcessing.doPostProcessing(contrastFbo.colorTexture);
if (data.handleGuis) renderOverlays(game);
}
public void setGlobalFont(FontType font) public void setGlobalFont(FontType font)
{ this.globalFont = font; } { this.globalFont = font; }
@ -100,11 +88,11 @@ public class GingerGL
{ {
INSTANCE = this; INSTANCE = this;
registry = new GingerRegister(); registry = new GingerRegister();
registry.registerGame(game); getRegistry().registerGame(game);
timer = new Timer(game.data.tickSpeed); timer = new Timer(game.data.tickSpeed);
timer.addTickListener(gameTickListener); timer.addTickListener(gameTickListener);
contrastFbo = new Fbo(new ContrastChanger()); contrastFbo = new Fbo(new ContrastChanger());
registry.masterRenderer = masterRenderer; getRegistry().masterRenderer = masterRenderer;
picker = new MousePicker(game.data.camera, masterRenderer.getProjectionMatrix()); picker = new MousePicker(game.data.camera, masterRenderer.getProjectionMatrix());
PostProcessing.init(); PostProcessing.init();
} }
@ -113,23 +101,27 @@ public class GingerGL
{ {
while (!Window.closed()) while (!Window.closed())
{ {
update(Litecraft.getInstance().data); // Run this regardless, (so as fast as possible) update(); // Run this regardless, (so as fast as possible)
if (timer.tick()) Litecraft.getInstance().tps += 1; // Run this only [ticklimit] times per second (This invokes gameTickListener.onTick!) timer.tick(); // Run this only [ticklimit] times per second (This invokes gameTickListener.onTick!)
if (Window.shouldRender()) registry.game.render(); // Run this only [framelimit] times per second if (Window.shouldRender()) getRegistry().game.render(); // Run this only [framelimit] times per second
} }
registry.game.exit(); getRegistry().game.exit();
} }
// Things that should be run as often as possible, without limits // Things that should be run as often as possible, without limits
public void update(GameData data) public void update()
{ {
registry.game.update(); getRegistry().game.update();
picker.update(); picker.update();
GingerUtils.update(); GingerUtils.update();
Window.update(); Window.update();
Litecraft.getInstance().ups += 1;
} }
public static GingerGL getInstance() public static GingerGL getInstance()
{ return INSTANCE; } { return INSTANCE; }
public GingerRegister getRegistry()
{
return registry;
}
} }

View File

@ -3,7 +3,7 @@ package com.github.hydos.ginger.engine.opengl.postprocessing;
import org.lwjgl.opengl.*; import org.lwjgl.opengl.*;
import com.github.hydos.ginger.engine.opengl.render.models.RawModel; import com.github.hydos.ginger.engine.opengl.render.models.RawModel;
import com.github.hydos.ginger.engine.opengl.utils.GlLoader; import com.github.hydos.ginger.engine.opengl.utils.GLLoader;
public class PostProcessing public class PostProcessing
{ {
@ -33,7 +33,7 @@ public class PostProcessing
public static void init() public static void init()
{ {
quad = GlLoader.loadToVAO(POSITIONS, 2); quad = GLLoader.loadToVAO(POSITIONS, 2);
contrastChanger = new ContrastChanger(); contrastChanger = new ContrastChanger();
} }

View File

@ -6,8 +6,8 @@ import java.util.*;
import org.joml.*; import org.joml.*;
import org.lwjgl.opengl.*; import org.lwjgl.opengl.*;
import com.github.halotroop.litecraft.world.World; import com.github.halotroop.litecraft.render.BlockRenderer;
import com.github.halotroop.litecraft.world.block.BlockRenderer; import com.github.hydos.ginger.engine.common.api.GingerRegister;
import com.github.hydos.ginger.engine.common.cameras.Camera; import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.common.elements.GuiTexture; import com.github.hydos.ginger.engine.common.elements.GuiTexture;
import com.github.hydos.ginger.engine.common.elements.objects.*; import com.github.hydos.ginger.engine.common.elements.objects.*;
@ -156,12 +156,12 @@ public class MasterRenderer
normalRenderer.render(normalMapEntities, clipPlane, lights, camera); normalRenderer.render(normalMapEntities, clipPlane, lights, camera);
} }
public void renderScene(List<RenderObject> entities, List<RenderObject> normalEntities, List<Light> lights, Camera camera, Vector4f clipPlane, World world) public void renderScene(List<RenderObject> entities, List<RenderObject> normalEntities, List<Light> lights, Camera camera, Vector4f clipPlane)
{ {
prepare(); prepare();
renderEntities(entities, camera, lights); renderEntities(entities, camera, lights);
world.render(blockRenderer);
renderNormalEntities(normalEntities, lights, camera, clipPlane); renderNormalEntities(normalEntities, lights, camera, clipPlane);
GingerRegister.getInstance().game.renderScene();
// skyboxRenderer.render(camera); // skyboxRenderer.render(camera);
} }

View File

@ -10,7 +10,7 @@ import com.github.hydos.ginger.engine.common.math.Maths;
import com.github.hydos.ginger.engine.opengl.render.Renderer; import com.github.hydos.ginger.engine.opengl.render.Renderer;
import com.github.hydos.ginger.engine.opengl.render.models.RawModel; import com.github.hydos.ginger.engine.opengl.render.models.RawModel;
import com.github.hydos.ginger.engine.opengl.render.shaders.GuiShader; import com.github.hydos.ginger.engine.opengl.render.shaders.GuiShader;
import com.github.hydos.ginger.engine.opengl.utils.GlLoader; import com.github.hydos.ginger.engine.opengl.utils.GLLoader;
public class GuiRenderer extends Renderer public class GuiRenderer extends Renderer
{ {
@ -24,7 +24,7 @@ public class GuiRenderer extends Renderer
{ {
-1, 1, -1, -1, 1, 1, 1, -1 -1, 1, -1, -1, 1, 1, 1, -1
}; };
quad = GlLoader.loadToVAO(positions, 2); quad = GLLoader.loadToVAO(positions, 2);
} }
public void cleanUp() public void cleanUp()

View File

@ -7,7 +7,7 @@ import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.opengl.render.Renderer; import com.github.hydos.ginger.engine.opengl.render.Renderer;
import com.github.hydos.ginger.engine.opengl.render.models.RawModel; import com.github.hydos.ginger.engine.opengl.render.models.RawModel;
import com.github.hydos.ginger.engine.opengl.render.shaders.SkyboxShader; import com.github.hydos.ginger.engine.opengl.render.shaders.SkyboxShader;
import com.github.hydos.ginger.engine.opengl.utils.GlLoader; import com.github.hydos.ginger.engine.opengl.utils.GLLoader;
public class SkyboxRenderer extends Renderer public class SkyboxRenderer extends Renderer
{ {
@ -62,8 +62,8 @@ public class SkyboxRenderer extends Renderer
public SkyboxRenderer(Matrix4f projectionMatrix) public SkyboxRenderer(Matrix4f projectionMatrix)
{ {
cube = GlLoader.loadToVAO(VERTICES, 3); cube = GLLoader.loadToVAO(VERTICES, 3);
texture = GlLoader.loadCubeMap(TEXTURE_FILES); texture = GLLoader.loadCubeMap(TEXTURE_FILES);
shader = new SkyboxShader(); shader = new SkyboxShader();
shader.start(); shader.start();
shader.loadProjectionMatrix(projectionMatrix); shader.loadProjectionMatrix(projectionMatrix);

View File

@ -6,12 +6,11 @@ import java.util.*;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.*; import org.lwjgl.opengl.*;
import com.github.halotroop.litecraft.types.block.*;
import com.github.hydos.ginger.engine.common.io.Window; import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.opengl.render.models.RawModel; import com.github.hydos.ginger.engine.opengl.render.models.RawModel;
import com.github.hydos.ginger.engine.opengl.render.texture.*; import com.github.hydos.ginger.engine.opengl.render.texture.*;
public class GlLoader public class GLLoader
{ {
private static List<Integer> vaos = new ArrayList<Integer>(); private static List<Integer> vaos = new ArrayList<Integer>();
private static List<Integer> vbos = new ArrayList<Integer>(); private static List<Integer> vbos = new ArrayList<Integer>();
@ -102,46 +101,6 @@ public class GlLoader
public static int loadTexture(String path) public static int loadTexture(String path)
{ return loadTextureDirectly("/textures/" + path); } { return loadTextureDirectly("/textures/" + path); }
public static int createBlockAtlas()
{
int width = 16;
int height = 16;
//Prepare the atlas texture and gen it
int atlasId = GL40.glGenTextures();
//Bind it to openGL
GL40.glBindTexture(GL40.GL_TEXTURE_2D, atlasId);
//Apply the settings for the texture
GL40.glTexParameteri(GL40.GL_TEXTURE_2D, GL40.GL_TEXTURE_MIN_FILTER, GL40.GL_NEAREST);
GL40.glTexParameteri(GL40.GL_TEXTURE_2D, GL40.GL_TEXTURE_MAG_FILTER, GL40.GL_NEAREST);
//Fill the image with blank image data
GL40.glTexImage2D(GL40.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width*2, height*2, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
long maxX = Math.round(Math.sqrt(Blocks.blocks.size()));
int currentX = 0;
int currentY = 0;
for(Block block: Blocks.blocks) {
//just in case
if(!block.texture.equals("DONTLOAD")) {
System.out.println(block.texture);
block.updateBlockModelData();
if(currentX > maxX) {
currentX = 0;
currentY--;
}
GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0,
currentX*width, currentY*height,
width, height,
GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE,
block.model.getTexture().getTexture().getImage()
);
currentX++;
}
}
return atlasId;
}
public static int loadTextureDirectly(String path) public static int loadTextureDirectly(String path)
{ {
int textureID = GL11.glGenTextures(); int textureID = GL11.glGenTextures();

View File

@ -1,8 +0,0 @@
package com.github.hydos.multithreading;
public abstract class GingerThread extends Thread
{
public boolean finished = false;
public String threadName;
public boolean started = false;
}

View File

@ -1,37 +0,0 @@
package com.github.hydos.multithreading;
import java.util.*;
import com.github.halotroop.litecraft.Litecraft;
import com.github.hydos.ginger.engine.common.io.Window;
public class GingerThreading extends Thread
{
public List<GingerThread> worldChunkThreadWaitlist;
public GingerThreading()
{ worldChunkThreadWaitlist = new ArrayList<>(); }
public void registerChunkThreadToWaitlist(GingerThread thread)
{ worldChunkThreadWaitlist.add(thread); }
@Override
public void run() {
while(!Window.closed()) {
if(worldChunkThreadWaitlist.size() != 0) {
Litecraft.getInstance().threadWaitlist = worldChunkThreadWaitlist.size();
GingerThread yes = worldChunkThreadWaitlist.get(0);
if(yes.finished) {
worldChunkThreadWaitlist.remove(0);
if(worldChunkThreadWaitlist.size() != 0) {
worldChunkThreadWaitlist.get(0).start();
}
}else {
if(!yes.isAlive() && !yes.started) {
yes.start();
}
}
}
}
}
}