mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 11:44:19 +01:00
Added ChunkSnapshot for efficient, thread-safe copies of Chunk data. Thanks mikeprimm!
By: EvilSeph <evilseph@unaligned.org>
This commit is contained in:
parent
516d253953
commit
c6821f93c4
2 changed files with 90 additions and 0 deletions
|
@ -40,6 +40,12 @@ public interface Chunk {
|
||||||
*/
|
*/
|
||||||
Block getBlock(int x, int y, int z);
|
Block getBlock(int x, int y, int z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capture thread-safe read-only snapshot of chunk data
|
||||||
|
* @return ChunkSnapshot
|
||||||
|
*/
|
||||||
|
ChunkSnapshot getChunkSnapshot();
|
||||||
|
|
||||||
Entity[] getEntities();
|
Entity[] getEntities();
|
||||||
|
|
||||||
BlockState[] getTileEntities();
|
BlockState[] getTileEntities();
|
||||||
|
|
84
paper-api/src/main/java/org/bukkit/ChunkSnapshot.java
Normal file
84
paper-api/src/main/java/org/bukkit/ChunkSnapshot.java
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
package org.bukkit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a static, thread-safe snapshot of chunk of blocks
|
||||||
|
* Purpose is to allow clean, efficient copy of a chunk data to be made, and then handed off for processing in another thread (e.g. map rendering)
|
||||||
|
*/
|
||||||
|
public interface ChunkSnapshot {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the X-coordinate of this chunk
|
||||||
|
*
|
||||||
|
* @return X-coordinate
|
||||||
|
*/
|
||||||
|
int getX();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the Z-coordinate of this chunk
|
||||||
|
*
|
||||||
|
* @return Z-coordinate
|
||||||
|
*/
|
||||||
|
int getZ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets name of the world containing this chunk
|
||||||
|
*
|
||||||
|
* @return Parent World Name
|
||||||
|
*/
|
||||||
|
String getWorldName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get block type for block at corresponding coordinate in the chunk
|
||||||
|
*
|
||||||
|
* @param x 0-15
|
||||||
|
* @param y 0-127
|
||||||
|
* @param z 0-15
|
||||||
|
* @return 0-255
|
||||||
|
*/
|
||||||
|
int getBlockTypeId(int x, int y, int z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get block data for block at corresponding coordinate in the chunk
|
||||||
|
*
|
||||||
|
* @param x 0-15
|
||||||
|
* @param y 0-127
|
||||||
|
* @param z 0-15
|
||||||
|
* @return 0-15
|
||||||
|
*/
|
||||||
|
int getBlockData(int x, int y, int z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get sky light level for block at corresponding coordinate in the chunk
|
||||||
|
*
|
||||||
|
* @param x 0-15
|
||||||
|
* @param y 0-127
|
||||||
|
* @param z 0-15
|
||||||
|
* @return 0-15
|
||||||
|
*/
|
||||||
|
int getBlockSkyLight(int x, int y, int z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get light level emitted by block at corresponding coordinate in the chunk
|
||||||
|
*
|
||||||
|
* @param x 0-15
|
||||||
|
* @param y 0-127
|
||||||
|
* @param z 0-15
|
||||||
|
* @return 0-15
|
||||||
|
*/
|
||||||
|
int getBlockEmittedLight(int x, int y, int z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the highest non-air coordinate at the given coordinates
|
||||||
|
*
|
||||||
|
* @param x X-coordinate of the blocks
|
||||||
|
* @param z Z-coordinate of the blocks
|
||||||
|
* @return Y-coordinate of the highest non-air block
|
||||||
|
*/
|
||||||
|
int getHighestBlockYAt(int x, int z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get world full time when chunk snapshot was captured
|
||||||
|
* @return time in ticks
|
||||||
|
*/
|
||||||
|
long getCaptureFullTime();
|
||||||
|
}
|
Loading…
Reference in a new issue