mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-02 11:22:01 +01:00
Implemented CHUNK_LOADED
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
596035458a
commit
37bc03b43a
@ -21,8 +21,8 @@ import org.bukkit.Vector;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
public class CraftWorld implements World {
|
public class CraftWorld implements World {
|
||||||
private final Map<ChunkCoordinate, Chunk> chunkCache = new HashMap<ChunkCoordinate, Chunk>();
|
private final Map<ChunkCoordinate, CraftChunk> chunkCache = new HashMap<ChunkCoordinate, CraftChunk>();
|
||||||
private final Map<BlockCoordinate, Block> blockCache = new HashMap<BlockCoordinate, Block>();
|
private final Map<BlockCoordinate, CraftBlock> blockCache = new HashMap<BlockCoordinate, CraftBlock>();
|
||||||
private final WorldServer world;
|
private final WorldServer world;
|
||||||
|
|
||||||
private static final Random rand = new Random();
|
private static final Random rand = new Random();
|
||||||
@ -33,7 +33,7 @@ public class CraftWorld implements World {
|
|||||||
|
|
||||||
public Block getBlockAt(int x, int y, int z) {
|
public Block getBlockAt(int x, int y, int z) {
|
||||||
BlockCoordinate loc = new BlockCoordinate(x, y, z);
|
BlockCoordinate loc = new BlockCoordinate(x, y, z);
|
||||||
Block block = blockCache.get(loc);
|
CraftBlock block = blockCache.get(loc);
|
||||||
|
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
block = new CraftBlock(this, x, y, z, world.a(x, y, z), (byte)world.b(x, y, z));
|
block = new CraftBlock(this, x, y, z, world.a(x, y, z), (byte)world.b(x, y, z));
|
||||||
@ -49,7 +49,7 @@ public class CraftWorld implements World {
|
|||||||
|
|
||||||
public Chunk getChunkAt(int x, int z) {
|
public Chunk getChunkAt(int x, int z) {
|
||||||
ChunkCoordinate loc = new ChunkCoordinate(x, z);
|
ChunkCoordinate loc = new ChunkCoordinate(x, z);
|
||||||
Chunk chunk = chunkCache.get(loc);
|
CraftChunk chunk = chunkCache.get(loc);
|
||||||
|
|
||||||
if (chunk == null) {
|
if (chunk == null) {
|
||||||
chunk = new CraftChunk(this, x, z);
|
chunk = new CraftChunk(this, x, z);
|
||||||
@ -84,6 +84,20 @@ public class CraftWorld implements World {
|
|||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CraftChunk updateChunk(int x, int z) {
|
||||||
|
ChunkCoordinate loc = new ChunkCoordinate(x, z);
|
||||||
|
CraftChunk chunk = chunkCache.get(loc);
|
||||||
|
|
||||||
|
if (chunk == null) {
|
||||||
|
chunk = new CraftChunk(this, x, z);
|
||||||
|
chunkCache.put(loc, chunk);
|
||||||
|
} else {
|
||||||
|
// TODO: Chunk stuff
|
||||||
|
}
|
||||||
|
|
||||||
|
return chunk;
|
||||||
|
}
|
||||||
|
|
||||||
public WorldServer getHandle() {
|
public WorldServer getHandle() {
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user