q
This commit is contained in:
parent
e53b56f460
commit
d6b9d09d50
6 changed files with 263 additions and 161 deletions
|
@ -7,78 +7,86 @@ import main.*;
|
||||||
import math.*;
|
import math.*;
|
||||||
|
|
||||||
public class Camera {
|
public class Camera {
|
||||||
|
|
||||||
private static Vector3f position = new Vector3f(0,4,0);
|
private static Vector3f position = new Vector3f(0, 4, 0);
|
||||||
private static Vector2f rotation = new Vector2f(0,120);
|
private static Vector2f rotation = new Vector2f(0, 120);
|
||||||
private static PlayerRayCast playerRaycast;
|
private static PlayerRayCast playerRaycast;
|
||||||
private static final float HEIGHT = (float) (1.5f - (Block.getSize()/2.0f));
|
private static final float HEIGHT = (float) (1.5f - (Block.getSize() / 2.0f));
|
||||||
public static boolean gravity = true;
|
public static boolean gravity = true;
|
||||||
public static float gravityFactor = 0;
|
public static float gravityFactor = 0;
|
||||||
public static boolean grounded = false;
|
public static boolean grounded = false;
|
||||||
public static boolean noClip = false;
|
public static boolean noClip = false;
|
||||||
|
|
||||||
public static void initCamera(){
|
public static void initCamera() {
|
||||||
playerRaycast = new PlayerRayCast();
|
playerRaycast = new PlayerRayCast();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderCamera(){
|
public static void renderCamera() {
|
||||||
|
if (position.getY() < (int)((new Noise(Main.getGame().getWorld().seed, Main
|
||||||
|
.getGame().getWorld().octave,
|
||||||
|
Main.getGame().getWorld().amplitude).getNoise(position.getX(),
|
||||||
|
position.getZ())) + 1)) {
|
||||||
|
|
||||||
|
position.setY((int)((new Noise(Main.getGame().getWorld().seed, Main
|
||||||
|
.getGame().getWorld().octave,
|
||||||
|
Main.getGame().getWorld().amplitude).getNoise(position.getX(),
|
||||||
|
position.getZ())) + 2));
|
||||||
|
}
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glRotatef(rotation.getX(), 1, 0, 0);
|
glRotatef(rotation.getX(), 1, 0, 0);
|
||||||
glRotatef(rotation.getY(), 0, 1, 0);
|
glRotatef(rotation.getY(), 0, 1, 0);
|
||||||
glTranslatef(-position.getX(), -(position.getY()+getHeight()), -position.getZ());
|
glTranslatef(-position.getX(), -(position.getY() + getHeight()),
|
||||||
|
-position.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void move(float xa,float ya,float za){
|
public static void move(float xa, float ya, float za) {
|
||||||
if(true){
|
gravityFactor += World.GRAVITY * 0.01f;
|
||||||
gravityFactor += World.GRAVITY * 0.01f;
|
if (grounded)
|
||||||
if(grounded) gravityFactor = 0;
|
|
||||||
ya -= gravityFactor;
|
|
||||||
}else{
|
|
||||||
gravityFactor = 0;
|
gravityFactor = 0;
|
||||||
}
|
ya -= gravityFactor;
|
||||||
int xStep = (int)Math.abs(xa * 100);
|
int xStep = (int) Math.abs(xa * 100);
|
||||||
for(int i = 0; i < xStep; i++){
|
for (int i = 0; i < xStep; i++) {
|
||||||
if(!isColliding(xa/xStep, 0, 0) || noClip){
|
if (!isColliding(xa / xStep, 0, 0) || noClip) {
|
||||||
position.x += xa/xStep;
|
position.x += xa / xStep;
|
||||||
}else{
|
} else {
|
||||||
xa = 0;
|
xa = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int yStep = (int)Math.abs(ya * 100);
|
int yStep = (int) Math.abs(ya * 100);
|
||||||
for(int i = 0; i < yStep; i++){
|
for (int i = 0; i < yStep; i++) {
|
||||||
if(!isColliding(0, ya/yStep, 0) || noClip){
|
if (!isColliding(0, ya / yStep, 0) || noClip) {
|
||||||
position.y += ya/yStep;
|
position.y += ya / yStep;
|
||||||
}else{
|
} else {
|
||||||
ya = 0;
|
ya = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int zStep = (int)Math.abs(za * 100);
|
int zStep = (int) Math.abs(za * 100);
|
||||||
for(int i = 0; i < zStep; i++){
|
for (int i = 0; i < zStep; i++) {
|
||||||
if(!isColliding(0, 0, za/zStep) || noClip){
|
if (!isColliding(0, 0, za / zStep) || noClip) {
|
||||||
position.z += za/zStep;
|
position.z += za / zStep;
|
||||||
}else{
|
} else {
|
||||||
za = 0;
|
za = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3f getDirection(){
|
public static Vector3f getDirection() {
|
||||||
Vector3f r = new Vector3f();
|
Vector3f r = new Vector3f();
|
||||||
|
|
||||||
float cosY = (float)Math.cos(Math.toRadians(rotation.getY() - 90));
|
float cosY = (float) Math.cos(Math.toRadians(rotation.getY() - 90));
|
||||||
float sinY = (float)Math.sin(Math.toRadians(rotation.getY() - 90));
|
float sinY = (float) Math.sin(Math.toRadians(rotation.getY() - 90));
|
||||||
float cosP = (float)Math.cos(Math.toRadians(-rotation.getX()));
|
float cosP = (float) Math.cos(Math.toRadians(-rotation.getX()));
|
||||||
float sinP = (float)Math.sin(Math.toRadians(-rotation.getX()));
|
float sinP = (float) Math.sin(Math.toRadians(-rotation.getX()));
|
||||||
|
|
||||||
r.setX(cosY * cosP);
|
r.setX(cosY * cosP);
|
||||||
r.setY(sinP);
|
r.setY(sinP);
|
||||||
r.setZ(sinY * cosP);
|
r.setZ(sinY * cosP);
|
||||||
|
|
||||||
r.normalize();
|
r.normalize();
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3f getPosition() {
|
public static Vector3f getPosition() {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
@ -106,86 +114,175 @@ public class Camera {
|
||||||
public static void setPlayerRaycast(PlayerRayCast playerRaycast) {
|
public static void setPlayerRaycast(PlayerRayCast playerRaycast) {
|
||||||
Camera.playerRaycast = playerRaycast;
|
Camera.playerRaycast = playerRaycast;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isColliding(float xa,float ya, float za){
|
public static boolean isColliding(float xa, float ya, float za) {
|
||||||
World world = Main.getGame().getWorld();
|
World world = Main.getGame().getWorld();
|
||||||
float r = 0.3f;
|
float r = 0.3f;
|
||||||
|
|
||||||
boolean nx = false, ny = false, nz = false;
|
boolean nx = false, ny = false, nz = false;
|
||||||
|
|
||||||
int x0 = (int)(position.x + xa - r);
|
int x0 = (int) (position.x + xa - r);
|
||||||
int x1 = (int)(position.x + xa + r);
|
int x1 = (int) (position.x + xa + r);
|
||||||
|
|
||||||
int y0 = (int)(position.y + ya - r);
|
int y0 = (int) (position.y + ya - r);
|
||||||
int y1 = (int)(position.y + ya + r);
|
int y1 = (int) (position.y + ya + r);
|
||||||
|
|
||||||
int z0 = (int)(position.z + za - r);
|
int z0 = (int) (position.z + za - r);
|
||||||
int z1 = (int)(position.z + za + r);
|
int z1 = (int) (position.z + za + r);
|
||||||
|
|
||||||
int xmid = (int)(position.x + xa);
|
int xmid = (int) (position.x + xa);
|
||||||
int yb = (int)(position.y + ya - r - 0.01f);
|
int yb = (int) (position.y + ya - r - 0.01f);
|
||||||
int zmid = (int)(position.z + za);
|
int zmid = (int) (position.z + za);
|
||||||
|
|
||||||
if(xmid < 0)nx = true;else nx = false;
|
if (xmid < 0)
|
||||||
if(yb < 0)ny = true;else ny = false;
|
nx = true;
|
||||||
if(zmid < 0)nz = true;else nz = false;
|
else
|
||||||
if(world.getBlock(xmid, yb, zmid,nx,ny,nz) != null ){
|
nx = false;
|
||||||
|
if (yb < 0)
|
||||||
|
ny = true;
|
||||||
|
else
|
||||||
|
ny = false;
|
||||||
|
if (zmid < 0)
|
||||||
|
nz = true;
|
||||||
|
else
|
||||||
|
nz = false;
|
||||||
|
if (world.getBlock(xmid, yb, zmid, nx, ny, nz) != null) {
|
||||||
grounded = true;
|
grounded = true;
|
||||||
}else{
|
} else {
|
||||||
grounded = false;
|
grounded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(x0 < 0)nx = true;else nx = false;
|
if (x0 < 0)
|
||||||
if(y0 < 0)ny = true;else ny = false;
|
nx = true;
|
||||||
if(z0 < 0)nz = true;else nz = false;
|
else
|
||||||
if(world.getBlock(x0, y0, z0,nx,ny,nz) != null) return true;
|
nx = false;
|
||||||
|
if (y0 < 0)
|
||||||
if(x1 < 0)nx = true;else nx = false;
|
ny = true;
|
||||||
if(y0 < 0)ny = true;else ny = false;
|
else
|
||||||
if(z0 < 0)nz = true;else nz = false;
|
ny = false;
|
||||||
if(world.getBlock(x1, y0, z0,nx,ny,nz) != null) return true;
|
if (z0 < 0)
|
||||||
|
nz = true;
|
||||||
if(x1 < 0)nx = true;else nx = false;
|
else
|
||||||
if(y1 < 0)ny = true;else ny = false;
|
nz = false;
|
||||||
if(z0 < 0)nz = true;else nz = false;
|
if (world.getBlock(x0, y0, z0, nx, ny, nz) != null)
|
||||||
if(world.getBlock(x1, y1, z0,nx,ny,nz) != null) return true;
|
return true;
|
||||||
|
|
||||||
if(x0 < 0)nx = true;else nx = false;
|
if (x1 < 0)
|
||||||
if(y1 < 0)ny = true;else ny = false;
|
nx = true;
|
||||||
if(z0 < 0)nz = true;else nz = false;
|
else
|
||||||
if(world.getBlock(x0, y1, z0,nx,ny,nz) != null) return true;
|
nx = false;
|
||||||
|
if (y0 < 0)
|
||||||
if(x0 < 0)nx = true;else nx = false;
|
ny = true;
|
||||||
if(y0 < 0)ny = true;else ny = false;
|
else
|
||||||
if(z1 < 0)nz = true;else nz = false;
|
ny = false;
|
||||||
if(world.getBlock(x0, y0, z1,nx,ny,nz) != null) return true;
|
if (z0 < 0)
|
||||||
|
nz = true;
|
||||||
if(x1 < 0)nx = true;else nx = false;
|
else
|
||||||
if(y0 < 0)ny = true;else ny = false;
|
nz = false;
|
||||||
if(z1 < 0)nz = true;else nz = false;
|
if (world.getBlock(x1, y0, z0, nx, ny, nz) != null)
|
||||||
if(world.getBlock(x1, y0, z1,nx,ny,nz) != null) return true;
|
return true;
|
||||||
|
|
||||||
if(x1 < 0)nx = true;else nx = false;
|
if (x1 < 0)
|
||||||
if(y1 < 0)ny = true;else ny = false;
|
nx = true;
|
||||||
if(z1 < 0)nz = true;else nz = false;
|
else
|
||||||
if(world.getBlock(x1, y1, z1,nx,ny,nz) != null) return true;
|
nx = false;
|
||||||
|
if (y1 < 0)
|
||||||
if(x0 < 0)nx = true;else nx = false;
|
ny = true;
|
||||||
if(y1 < 0)ny = true;else ny = false;
|
else
|
||||||
if(z1 < 0)nz = true;else nz = false;
|
ny = false;
|
||||||
if(world.getBlock(x0, y1, z1,nx,ny,nz) != null) return true;
|
if (z0 < 0)
|
||||||
|
nz = true;
|
||||||
// if(world.getBlock(x0, y0+1, z0) != null) return true;
|
else
|
||||||
// if(world.getBlock(x1, y0+1, z0) != null) return true;
|
nz = false;
|
||||||
// if(world.getBlock(x1, y1+1, z0) != null) return true;
|
if (world.getBlock(x1, y1, z0, nx, ny, nz) != null)
|
||||||
// if(world.getBlock(x0, y1+1, z0) != null) return true;
|
return true;
|
||||||
//
|
|
||||||
// if(world.getBlock(x0, y0+1, z1) != null) return true;
|
if (x0 < 0)
|
||||||
// if(world.getBlock(x1, y0+1, z1) != null) return true;
|
nx = true;
|
||||||
// if(world.getBlock(x1, y1+1, z1) != null) return true;
|
else
|
||||||
// if(world.getBlock(x0, y1+1, z1) != null) return true;
|
nx = false;
|
||||||
|
if (y1 < 0)
|
||||||
|
ny = true;
|
||||||
|
else
|
||||||
|
ny = false;
|
||||||
|
if (z0 < 0)
|
||||||
|
nz = true;
|
||||||
|
else
|
||||||
|
nz = false;
|
||||||
|
if (world.getBlock(x0, y1, z0, nx, ny, nz) != null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (x0 < 0)
|
||||||
|
nx = true;
|
||||||
|
else
|
||||||
|
nx = false;
|
||||||
|
if (y0 < 0)
|
||||||
|
ny = true;
|
||||||
|
else
|
||||||
|
ny = false;
|
||||||
|
if (z1 < 0)
|
||||||
|
nz = true;
|
||||||
|
else
|
||||||
|
nz = false;
|
||||||
|
if (world.getBlock(x0, y0, z1, nx, ny, nz) != null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (x1 < 0)
|
||||||
|
nx = true;
|
||||||
|
else
|
||||||
|
nx = false;
|
||||||
|
if (y0 < 0)
|
||||||
|
ny = true;
|
||||||
|
else
|
||||||
|
ny = false;
|
||||||
|
if (z1 < 0)
|
||||||
|
nz = true;
|
||||||
|
else
|
||||||
|
nz = false;
|
||||||
|
if (world.getBlock(x1, y0, z1, nx, ny, nz) != null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (x1 < 0)
|
||||||
|
nx = true;
|
||||||
|
else
|
||||||
|
nx = false;
|
||||||
|
if (y1 < 0)
|
||||||
|
ny = true;
|
||||||
|
else
|
||||||
|
ny = false;
|
||||||
|
if (z1 < 0)
|
||||||
|
nz = true;
|
||||||
|
else
|
||||||
|
nz = false;
|
||||||
|
if (world.getBlock(x1, y1, z1, nx, ny, nz) != null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (x0 < 0)
|
||||||
|
nx = true;
|
||||||
|
else
|
||||||
|
nx = false;
|
||||||
|
if (y1 < 0)
|
||||||
|
ny = true;
|
||||||
|
else
|
||||||
|
ny = false;
|
||||||
|
if (z1 < 0)
|
||||||
|
nz = true;
|
||||||
|
else
|
||||||
|
nz = false;
|
||||||
|
if (world.getBlock(x0, y1, z1, nx, ny, nz) != null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// if(world.getBlock(x0, y0+1, z0) != null) return true;
|
||||||
|
// if(world.getBlock(x1, y0+1, z0) != null) return true;
|
||||||
|
// if(world.getBlock(x1, y1+1, z0) != null) return true;
|
||||||
|
// if(world.getBlock(x0, y1+1, z0) != null) return true;
|
||||||
|
//
|
||||||
|
// if(world.getBlock(x0, y0+1, z1) != null) return true;
|
||||||
|
// if(world.getBlock(x1, y0+1, z1) != null) return true;
|
||||||
|
// if(world.getBlock(x1, y1+1, z1) != null) return true;
|
||||||
|
// if(world.getBlock(x0, y1+1, z1) != null) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ public class Game {
|
||||||
private int update = 0;
|
private int update = 0;
|
||||||
|
|
||||||
public Game(){
|
public Game(){
|
||||||
world= new World(0);
|
world= new World(0,120,50);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(){
|
public void update(){
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package main;
|
package main;
|
||||||
|
|
||||||
import rendering.*;
|
|
||||||
import game.*;
|
import game.*;
|
||||||
|
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
@ -8,9 +7,6 @@ import java.util.concurrent.*;
|
||||||
import org.lwjgl.input.*;
|
import org.lwjgl.input.*;
|
||||||
import org.lwjgl.opengl.*;
|
import org.lwjgl.opengl.*;
|
||||||
|
|
||||||
import rendering.*;
|
|
||||||
import vanilla.java.affinity.*;
|
|
||||||
import vanilla.java.affinity.impl.*;
|
|
||||||
import world.*;
|
import world.*;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
@ -100,10 +96,6 @@ public class Main {
|
||||||
if (elapsedInfo >= 1000) {
|
if (elapsedInfo >= 1000) {
|
||||||
LAST_FPS = FPS;
|
LAST_FPS = FPS;
|
||||||
LAST_TICKS = TICKS;
|
LAST_TICKS = TICKS;
|
||||||
boolean nx = false, ny = false, nz = false;
|
|
||||||
if(Camera.getPosition().getX() < 0)nx = true;
|
|
||||||
if(Camera.getPosition().getY() < 0)ny = true;
|
|
||||||
if(Camera.getPosition().getZ() < 0)nz = true;
|
|
||||||
Display.setTitle(TITLE + " | FPS:" + (int)(1000000000.0f/timeFps) + " TICKS:"
|
Display.setTitle(TITLE + " | FPS:" + (int)(1000000000.0f/timeFps) + " TICKS:"
|
||||||
+ LAST_TICKS + " timeFps:" + timeFps + "ns timeTicks:"
|
+ LAST_TICKS + " timeFps:" + timeFps + "ns timeTicks:"
|
||||||
+ timeTicks + "ns" + " | PX:"
|
+ timeTicks + "ns" + " | PX:"
|
||||||
|
|
|
@ -22,14 +22,12 @@ public class Chunk {
|
||||||
private boolean IsGenerated = false;
|
private boolean IsGenerated = false;
|
||||||
private boolean IsCurrentGenerate = false;
|
private boolean IsCurrentGenerate = false;
|
||||||
private boolean IsDestroy = false;
|
private boolean IsDestroy = false;
|
||||||
private WorldNoise worldNoise;
|
|
||||||
|
|
||||||
public Chunk(int x, int y, int z, World world,WorldNoise worldNoise) {
|
public Chunk(int x, int y, int z, World world) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.worldNoise = worldNoise;
|
|
||||||
this.blocks = new Block[SIZE][SIZE][SIZE];
|
this.blocks = new Block[SIZE][SIZE][SIZE];
|
||||||
vbo = new VBO();
|
vbo = new VBO();
|
||||||
}
|
}
|
||||||
|
@ -297,14 +295,6 @@ public class Chunk {
|
||||||
public boolean isDestroy() {
|
public boolean isDestroy() {
|
||||||
return IsDestroy;
|
return IsDestroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldNoise getWorldNoise() {
|
|
||||||
return worldNoise;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWorldNoise(WorldNoise worldNoise) {
|
|
||||||
this.worldNoise = worldNoise;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -336,9 +326,9 @@ class Generate implements Runnable {
|
||||||
long current = System.currentTimeMillis();
|
long current = System.currentTimeMillis();
|
||||||
long elapsed1 = 0;
|
long elapsed1 = 0;
|
||||||
boolean IsError = true;
|
boolean IsError = true;
|
||||||
Noise noise = new Noise(world.seed, 50, 16);
|
Noise noise = new Noise(world.seed, world.octave, world.amplitude);;
|
||||||
Random random = new Random(world.seed);
|
Random random = new Random(world.seed);
|
||||||
Noise colorVariationNoise = new Noise(world.seed,50,2);
|
Noise colorVariationNoise = new Noise(world.seed,world.octave,2);
|
||||||
for (int x = 0; x < chunk.SIZE; x++) {
|
for (int x = 0; x < chunk.SIZE; x++) {
|
||||||
for (int z = 0; z < chunk.SIZE; z++) {
|
for (int z = 0; z < chunk.SIZE; z++) {
|
||||||
int xa = (int)((Camera.getPosition().getX()-((float)Chunk.SIZE/2.0f))/(float)Chunk.SIZE) - World.VIEW_CHUNK;
|
int xa = (int)((Camera.getPosition().getX()-((float)Chunk.SIZE/2.0f))/(float)Chunk.SIZE) - World.VIEW_CHUNK;
|
||||||
|
|
|
@ -5,27 +5,27 @@ import game.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import main.*;
|
|
||||||
import math.*;
|
import math.*;
|
||||||
import blocks.*;
|
import blocks.*;
|
||||||
|
|
||||||
public class World {
|
public class World {
|
||||||
|
|
||||||
public long seed;
|
public long seed;
|
||||||
|
public int octave,amplitude;
|
||||||
public final int SIZE = 1,HEIGHT = 1;
|
public final int SIZE = 1,HEIGHT = 1;
|
||||||
public static final float GRAVITY = 1;
|
public static final float GRAVITY = 1;
|
||||||
public static final int VIEW_CHUNK = 2;
|
public static final int VIEW_CHUNK = 2;
|
||||||
public static WorldNoise worldNoise;
|
|
||||||
|
|
||||||
public ArrayList<Chunk> chunks = new ArrayList<Chunk>();
|
public ArrayList<Chunk> chunks = new ArrayList<Chunk>();
|
||||||
|
|
||||||
public World(long seed){
|
public World(long seed,int octave,int amplitude){
|
||||||
this.seed= seed;
|
this.seed= seed;
|
||||||
this.worldNoise = new WorldNoise(seed);
|
this.octave = octave;
|
||||||
|
this.amplitude = amplitude;
|
||||||
for(int x = 0;x < SIZE;x++){
|
for(int x = 0;x < SIZE;x++){
|
||||||
for(int y = 0;y < HEIGHT;y++){
|
for(int y = 0;y < HEIGHT;y++){
|
||||||
for(int z = 0;z < SIZE;z++){
|
for(int z = 0;z < SIZE;z++){
|
||||||
Chunk ch = new Chunk(x,y,z,this,worldNoise);
|
Chunk ch = new Chunk(x,y,z,this);
|
||||||
chunks.add(ch);
|
chunks.add(ch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class World {
|
||||||
for(int k = 0;k <= delta_z;k++){
|
for(int k = 0;k <= delta_z;k++){
|
||||||
// for(int j = 0; j < HEIGHT; j++){
|
// for(int j = 0; j < HEIGHT; j++){
|
||||||
if(getChunk((xa + i), 0, (za + k)) != null)continue;
|
if(getChunk((xa + i), 0, (za + k)) != null)continue;
|
||||||
Chunk ch = new Chunk((xa + i),0,(za + k),this,worldNoise);
|
Chunk ch = new Chunk((xa + i),0,(za + k),this);
|
||||||
chunks.add(ch);
|
chunks.add(ch);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
@ -172,6 +172,46 @@ public class World {
|
||||||
|
|
||||||
return chunk.getBlock(xb, yb, zb);
|
return chunk.getBlock(xb, yb, zb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getSeed() {
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSeed(long seed) {
|
||||||
|
this.seed = seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Chunk> getChunks() {
|
||||||
|
return chunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChunks(ArrayList<Chunk> chunks) {
|
||||||
|
this.chunks = chunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getUpdateWorldTime() {
|
||||||
|
return updateWorldTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setUpdateWorldTime(long updateWorldTime) {
|
||||||
|
World.updateWorldTime = updateWorldTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSIZE() {
|
||||||
|
return SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHEIGHT() {
|
||||||
|
return HEIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getGravity() {
|
||||||
|
return GRAVITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getViewChunk() {
|
||||||
|
return VIEW_CHUNK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
package world;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class WorldNoise {
|
|
||||||
|
|
||||||
public Noise noise;
|
|
||||||
public Noise colorVariationNoise;
|
|
||||||
public Random random;
|
|
||||||
|
|
||||||
public WorldNoise(long seed){
|
|
||||||
noise = new Noise(seed, 20, 5);
|
|
||||||
colorVariationNoise = new Noise(seed, 40, 2);
|
|
||||||
random = new Random(seed);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Reference in a new issue