refactory Location's
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
package mc.world.flat;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import mc.core.EntityLocation;
|
||||
import mc.core.world.World;
|
||||
@@ -16,6 +17,7 @@ import mc.core.world.chunk.ChunkSection;
|
||||
public class FlatWorld implements World {
|
||||
@Getter
|
||||
private final WorldType worldType = WorldType.FLAT;
|
||||
@Setter
|
||||
private EntityLocation spawn;
|
||||
private ChunkSection chunkSection = new SimpleChunkSection();
|
||||
|
||||
@@ -23,18 +25,12 @@ public class FlatWorld implements World {
|
||||
public EntityLocation getSpawn() {
|
||||
if (this.spawn == null) {
|
||||
log.warn("Spawn is not defined! Set spawn [0, 6, 0]");
|
||||
this.spawn = new EntityLocation(0d, 6d, 0d, 0f, 0f, this);
|
||||
this.spawn = new EntityLocation(0d, 6d, 0d, 0f, 0f);
|
||||
}
|
||||
|
||||
return this.spawn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpawn(EntityLocation location) {
|
||||
this.spawn = location;
|
||||
this.spawn.setWorld(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getChunk(int x, int z) {
|
||||
Chunk chunk = new SimpleChunk(x, z, this);
|
||||
|
||||
@@ -9,12 +9,8 @@ import mc.core.world.World;
|
||||
import mc.core.world.block.Block;
|
||||
import mc.core.world.block.BlockFactory;
|
||||
import mc.core.world.block.BlockType;
|
||||
import mc.core.world.chunk.Chunk;
|
||||
import mc.core.world.chunk.ChunkSection;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class SimpleChunkSection implements ChunkSection {
|
||||
@Override
|
||||
public int getSkyLight(int x, int y, int z) {
|
||||
@@ -63,10 +59,10 @@ public class SimpleChunkSection implements ChunkSection {
|
||||
public Block getBlock(int x, int y, int z) {
|
||||
BlockFactory blockFactory = new BlockFactory();
|
||||
|
||||
if (y == 0) return blockFactory.create(BlockType.BEDROCK, x, y, z, getWorld());
|
||||
else if (y >= 1 && y <= 2) return blockFactory.create(BlockType.DIRT, x, y, z, getWorld());
|
||||
else if (y == 3) return blockFactory.create(BlockType.GRASS, x, y, z, getWorld());
|
||||
else return blockFactory.create(BlockType.AIR, x, y, z, getWorld());
|
||||
if (y == 0) return blockFactory.create(BlockType.BEDROCK, x, y, z);
|
||||
else if (y >= 1 && y <= 2) return blockFactory.create(BlockType.DIRT, x, y, z);
|
||||
else if (y == 3) return blockFactory.create(BlockType.GRASS, x, y, z);
|
||||
else return blockFactory.create(BlockType.AIR, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user