geforkt von Mirrors/Paper
[Bleeding] Add APIs for editing biome data, fix existing code to use persistent biome data. Addresses BUKKIT-1075
Dieser Commit ist enthalten in:
Ursprung
b5e92871eb
Commit
a029f32ccd
@ -216,7 +216,9 @@ public class CraftChunk implements Chunk {
|
|||||||
|
|
||||||
if (includeBiome) {
|
if (includeBiome) {
|
||||||
biome = new BiomeBase[256];
|
biome = new BiomeBase[256];
|
||||||
wcm.getBiomeBlock(biome, x << 4, z << 4, 16, 16);
|
for (int i = 0; i < 256; i++) {
|
||||||
|
biome[i] = chunk.a(i & 0xF, i >> 4, wcm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeBiomeTempRain) {
|
if (includeBiomeTempRain) {
|
||||||
@ -250,7 +252,9 @@ public class CraftChunk implements Chunk {
|
|||||||
|
|
||||||
if (includeBiome) {
|
if (includeBiome) {
|
||||||
biome = new BiomeBase[256];
|
biome = new BiomeBase[256];
|
||||||
wcm.getBiomeBlock(biome, x << 4, z << 4, 16, 16);
|
for (int i = 0; i < 256; i++) {
|
||||||
|
biome[i] = world.getHandle().getBiome((x << 4) + (i & 0xF), (z << 4) + (i >> 4));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeBiomeTempRain) {
|
if (includeBiomeTempRain) {
|
||||||
|
@ -39,7 +39,6 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.ChunkSnapshot;
|
import org.bukkit.ChunkSnapshot;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.TreeType;
|
import org.bukkit.TreeType;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
@ -48,7 +47,6 @@ import org.bukkit.Difficulty;
|
|||||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
import org.bukkit.plugin.messaging.StandardMessenger;
|
import org.bukkit.plugin.messaging.StandardMessenger;
|
||||||
import org.bukkit.potion.Potion;
|
|
||||||
|
|
||||||
public class CraftWorld implements World {
|
public class CraftWorld implements World {
|
||||||
private final WorldServer world;
|
private final WorldServer world;
|
||||||
@ -491,9 +489,19 @@ public class CraftWorld implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Biome getBiome(int x, int z) {
|
public Biome getBiome(int x, int z) {
|
||||||
BiomeBase base = getHandle().getWorldChunkManager().getBiome(x, z);
|
return CraftBlock.biomeBaseToBiome(this.world.getBiome(x, z));
|
||||||
|
}
|
||||||
|
|
||||||
return CraftBlock.biomeBaseToBiome(base);
|
public void setBiome(int x, int z, Biome bio) {
|
||||||
|
BiomeBase bb = CraftBlock.biomeToBiomeBase(bio);
|
||||||
|
if (this.world.isLoaded(x, 0, z)) {
|
||||||
|
net.minecraft.server.Chunk chunk = this.world.getChunkAtWorldCoords(x, z);
|
||||||
|
|
||||||
|
if (chunk != null) {
|
||||||
|
byte[] biomevals = chunk.l();
|
||||||
|
biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte)bb.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTemperature(int x, int z) {
|
public double getTemperature(int x, int z) {
|
||||||
|
@ -31,6 +31,7 @@ public class CraftBlock implements Block {
|
|||||||
private final int y;
|
private final int y;
|
||||||
private final int z;
|
private final int z;
|
||||||
private static final Biome BIOME_MAPPING[];
|
private static final Biome BIOME_MAPPING[];
|
||||||
|
private static final BiomeBase BIOMEBASE_MAPPING[];
|
||||||
|
|
||||||
public CraftBlock(CraftChunk chunk, int x, int y, int z) {
|
public CraftBlock(CraftChunk chunk, int x, int y, int z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
@ -248,6 +249,10 @@ public class CraftBlock implements Block {
|
|||||||
return getWorld().getBiome(x, z);
|
return getWorld().getBiome(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBiome(Biome bio) {
|
||||||
|
getWorld().setBiome(x, z, bio);
|
||||||
|
}
|
||||||
|
|
||||||
public static Biome biomeBaseToBiome(BiomeBase base) {
|
public static Biome biomeBaseToBiome(BiomeBase base) {
|
||||||
if (base == null) {
|
if (base == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -256,6 +261,13 @@ public class CraftBlock implements Block {
|
|||||||
return BIOME_MAPPING[base.id];
|
return BIOME_MAPPING[base.id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BiomeBase biomeToBiomeBase(Biome bio) {
|
||||||
|
if (bio == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return BIOMEBASE_MAPPING[bio.ordinal()];
|
||||||
|
}
|
||||||
|
|
||||||
public double getTemperature() {
|
public double getTemperature() {
|
||||||
return getWorld().getTemperature(x, z);
|
return getWorld().getTemperature(x, z);
|
||||||
}
|
}
|
||||||
@ -378,6 +390,7 @@ public class CraftBlock implements Block {
|
|||||||
/* Build biome index based lookup table for BiomeBase to Biome mapping */
|
/* Build biome index based lookup table for BiomeBase to Biome mapping */
|
||||||
static {
|
static {
|
||||||
BIOME_MAPPING = new Biome[BiomeBase.biomes.length];
|
BIOME_MAPPING = new Biome[BiomeBase.biomes.length];
|
||||||
|
BIOMEBASE_MAPPING = new BiomeBase[Biome.values().length];
|
||||||
BIOME_MAPPING[BiomeBase.SWAMPLAND.id] = Biome.SWAMPLAND;
|
BIOME_MAPPING[BiomeBase.SWAMPLAND.id] = Biome.SWAMPLAND;
|
||||||
BIOME_MAPPING[BiomeBase.FOREST.id] = Biome.FOREST;
|
BIOME_MAPPING[BiomeBase.FOREST.id] = Biome.FOREST;
|
||||||
BIOME_MAPPING[BiomeBase.TAIGA.id] = Biome.TAIGA;
|
BIOME_MAPPING[BiomeBase.TAIGA.id] = Biome.TAIGA;
|
||||||
@ -407,6 +420,9 @@ public class CraftBlock implements Block {
|
|||||||
if ((BiomeBase.biomes[i] != null) && (BIOME_MAPPING[i] == null)) {
|
if ((BiomeBase.biomes[i] != null) && (BIOME_MAPPING[i] == null)) {
|
||||||
throw new IllegalArgumentException("Missing Biome mapping for BiomeBase[" + i + "]");
|
throw new IllegalArgumentException("Missing Biome mapping for BiomeBase[" + i + "]");
|
||||||
}
|
}
|
||||||
|
if (BIOME_MAPPING[i] != null) { /* Build reverse mapping for setBiome */
|
||||||
|
BIOMEBASE_MAPPING[BIOME_MAPPING[i].ordinal()] = BiomeBase.biomes[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren