mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 03:22:19 +01:00
Implemented helper methods + new biome methods
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
92dc42b3a8
commit
11d2a52689
2 changed files with 66 additions and 29 deletions
|
@ -30,6 +30,7 @@ import org.bukkit.ChunkSnapshot;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.TreeType;
|
import org.bukkit.TreeType;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
|
|
||||||
public class CraftWorld implements World {
|
public class CraftWorld implements World {
|
||||||
|
@ -488,6 +489,56 @@ public class CraftWorld implements World {
|
||||||
return populators;
|
return populators;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Block getHighestBlockAt(int x, int z) {
|
||||||
|
return getBlockAt(x, getHighestBlockYAt(x, z), z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Block getHighestBlockAt(Location location) {
|
||||||
|
return getHighestBlockAt(location.getBlockX(), location.getBlockZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Biome getBiome(int x, int z) {
|
||||||
|
BiomeBase base = getHandle().getWorldChunkManager().getBiome(x, z);
|
||||||
|
|
||||||
|
if (base == BiomeBase.RAINFOREST) {
|
||||||
|
return Biome.RAINFOREST;
|
||||||
|
} else if (base == BiomeBase.SWAMPLAND) {
|
||||||
|
return Biome.SWAMPLAND;
|
||||||
|
} else if (base == BiomeBase.SEASONAL_FOREST) {
|
||||||
|
return Biome.SEASONAL_FOREST;
|
||||||
|
} else if (base == BiomeBase.FOREST) {
|
||||||
|
return Biome.FOREST;
|
||||||
|
} else if (base == BiomeBase.SAVANNA) {
|
||||||
|
return Biome.SAVANNA;
|
||||||
|
} else if (base == BiomeBase.SHRUBLAND) {
|
||||||
|
return Biome.SHRUBLAND;
|
||||||
|
} else if (base == BiomeBase.TAIGA) {
|
||||||
|
return Biome.TAIGA;
|
||||||
|
} else if (base == BiomeBase.DESERT) {
|
||||||
|
return Biome.DESERT;
|
||||||
|
} else if (base == BiomeBase.PLAINS) {
|
||||||
|
return Biome.PLAINS;
|
||||||
|
} else if (base == BiomeBase.ICE_DESERT) {
|
||||||
|
return Biome.ICE_DESERT;
|
||||||
|
} else if (base == BiomeBase.TUNDRA) {
|
||||||
|
return Biome.TUNDRA;
|
||||||
|
} else if (base == BiomeBase.HELL) {
|
||||||
|
return Biome.HELL;
|
||||||
|
} else if (base == BiomeBase.SKY) {
|
||||||
|
return Biome.SKY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getTemperature(int x, int z) {
|
||||||
|
return getHandle().getWorldChunkManager().a((double[])null, x, z, 1, 1)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getHumidity(int x, int z) {
|
||||||
|
return getHandle().getWorldChunkManager().getHumidity(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
private final class ChunkCoordinate {
|
private final class ChunkCoordinate {
|
||||||
public final int x;
|
public final int x;
|
||||||
public final int z;
|
public final int z;
|
||||||
|
|
|
@ -330,37 +330,15 @@ public class CraftBlock implements Block {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Biome getBiome() {
|
public Biome getBiome() {
|
||||||
BiomeBase base = chunk.getHandle().world.getWorldChunkManager().getBiome(x, z);
|
return getWorld().getBiome(x, z);
|
||||||
|
|
||||||
if (base == BiomeBase.RAINFOREST) {
|
|
||||||
return Biome.RAINFOREST;
|
|
||||||
} else if (base == BiomeBase.SWAMPLAND) {
|
|
||||||
return Biome.SWAMPLAND;
|
|
||||||
} else if (base == BiomeBase.SEASONAL_FOREST) {
|
|
||||||
return Biome.SEASONAL_FOREST;
|
|
||||||
} else if (base == BiomeBase.FOREST) {
|
|
||||||
return Biome.FOREST;
|
|
||||||
} else if (base == BiomeBase.SAVANNA) {
|
|
||||||
return Biome.SAVANNA;
|
|
||||||
} else if (base == BiomeBase.SHRUBLAND) {
|
|
||||||
return Biome.SHRUBLAND;
|
|
||||||
} else if (base == BiomeBase.TAIGA) {
|
|
||||||
return Biome.TAIGA;
|
|
||||||
} else if (base == BiomeBase.DESERT) {
|
|
||||||
return Biome.DESERT;
|
|
||||||
} else if (base == BiomeBase.PLAINS) {
|
|
||||||
return Biome.PLAINS;
|
|
||||||
} else if (base == BiomeBase.ICE_DESERT) {
|
|
||||||
return Biome.ICE_DESERT;
|
|
||||||
} else if (base == BiomeBase.TUNDRA) {
|
|
||||||
return Biome.TUNDRA;
|
|
||||||
} else if (base == BiomeBase.HELL) {
|
|
||||||
return Biome.HELL;
|
|
||||||
} else if (base == BiomeBase.SKY) {
|
|
||||||
return Biome.SKY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
public double getTemperature() {
|
||||||
|
return getWorld().getTemperature(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getHumidity() {
|
||||||
|
return getWorld().getHumidity(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBlockPowered() {
|
public boolean isBlockPowered() {
|
||||||
|
@ -400,4 +378,12 @@ public class CraftBlock implements Block {
|
||||||
public int getBlockPower() {
|
public int getBlockPower() {
|
||||||
return getBlockPower(BlockFace.SELF);
|
return getBlockPower(BlockFace.SELF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return getType() == Material.AIR;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLiquid() {
|
||||||
|
return (getType() == Material.WATER) || (getType() == Material.STATIONARY_WATER) || (getType() == Material.LAVA) || (getType() == Material.STATIONARY_LAVA);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue