From 05163fbadcbcb807e54c035eb7e843217fa99212 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 17 Jun 2011 09:21:56 -0400 Subject: [PATCH] Added ChunkSnapShot improvements. Thanks mikeprimm! Added support for biome data to chunk snapshot Added method for returning empty chunk snapshot (for ungenerated chunks) By: EvilSeph --- paper-api/src/main/java/org/bukkit/Chunk.java | 9 ++++++ .../main/java/org/bukkit/ChunkSnapshot.java | 28 +++++++++++++++++++ paper-api/src/main/java/org/bukkit/World.java | 10 +++++++ 3 files changed, 47 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/Chunk.java b/paper-api/src/main/java/org/bukkit/Chunk.java index 637a3faca4..91cb8a4f86 100644 --- a/paper-api/src/main/java/org/bukkit/Chunk.java +++ b/paper-api/src/main/java/org/bukkit/Chunk.java @@ -46,6 +46,15 @@ public interface Chunk { */ ChunkSnapshot getChunkSnapshot(); + /** + * Capture thread-safe read-only snapshot of chunk data + * @param includeMaxblocky - if true, snapshot includes per-coordinate maximum Y values + * @param includeBiome - if true, snapshot includes per-coordinate biome type + * @param includeBiomeTempRain - if true, snapshot includes per-coordinate raw biome temperature and rainfall + * @return ChunkSnapshot + */ + ChunkSnapshot getChunkSnapshot(boolean includeMaxblocky, boolean includeBiome, boolean includeBiomeTempRain); + Entity[] getEntities(); BlockState[] getTileEntities(); diff --git a/paper-api/src/main/java/org/bukkit/ChunkSnapshot.java b/paper-api/src/main/java/org/bukkit/ChunkSnapshot.java index 6d7252449c..e54b5e6b72 100644 --- a/paper-api/src/main/java/org/bukkit/ChunkSnapshot.java +++ b/paper-api/src/main/java/org/bukkit/ChunkSnapshot.java @@ -1,5 +1,6 @@ package org.bukkit; +import org.bukkit.block.Biome; /** * 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) @@ -76,6 +77,33 @@ public interface ChunkSnapshot { */ int getHighestBlockYAt(int x, int z); + /** + * Get biome at given coordinates + * + * @param x X-coordinate + * @param z Z-coordinate + * @return Biome at given coordinate + */ + Biome getBiome(int x, int z); + + /** + * Get raw biome temperature (0.0-1.0) at given coordinate + * + * @param x X-coordinate + * @param z Z-coordinate + * @return temperature at given coordinate + */ + double getRawBiomeTemperature(int x, int z); + + /** + * Get raw biome rainfall (0.0-1.0) at given coordinate + * + * @param x X-coordinate + * @param z Z-coordinate + * @return rainfall at given coordinate + */ + double getRawBiomeRainfall(int x, int z); + /** * Get world full time when chunk snapshot was captured * @return time in ticks diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java index d979d643d5..e814fa9400 100644 --- a/paper-api/src/main/java/org/bukkit/World.java +++ b/paper-api/src/main/java/org/bukkit/World.java @@ -608,6 +608,16 @@ public interface World { */ public void playEffect(Location location, Effect effect, int data, int radius); + /** + * Get empty chunk snapshot (equivalent to all air blocks), optionally including valid biome + * data. Used for representing an ungenerated chunk, or for fetching only biome data without loading a chunk. + * @param x - chunk x coordinate + * @param z - chunk z coordinate + * @param includeBiome - if true, snapshot includes per-coordinate biome type + * @param includeBiomeTempRain - if true, snapshot includes per-coordinate raw biome temperature and rainfall + */ + public ChunkSnapshot getEmptyChunkSnapshot(int x, int z, boolean includeBiome, boolean includeBiomeTempRain); + /** * Represents various map environment types that a world may be */