Try to handle TerrainControl biomes

This commit is contained in:
Mike Primm 2016-04-01 23:55:53 -05:00
parent b10a1585f4
commit 27dc1d4a0b
3 changed files with 23 additions and 62 deletions

View File

@ -103,7 +103,7 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
/** n.m.s.Chunk */
nmschunk = getNMSClass("net.minecraft.server.Chunk");
nmsc_tileentities = getField(nmschunk, new String[] { "tileEntities" }, Map.class);
nmsc_inhabitedticks = getFieldNoFail(nmschunk, new String[] { "s", "q", "u", "v" }, long.class);
nmsc_inhabitedticks = getPrivateFieldNoFail(nmschunk, new String[] { "s", "q", "u", "v" }, long.class);
if (nmsc_inhabitedticks == null) {
Log.info("inhabitedTicks field not found - inhabited shader not functional");
}
@ -288,8 +288,8 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
public Object[] getBiomeBaseList() {
if (getbiomebyid != null) {
if (biomelist == null) {
biomelist = new Object[256];
for (int i = 0; i < 256; i++) {
biomelist = new Object[1024];
for (int i = 0; i < 1024; i++) {
try {
biomelist[i] = getbiomebyid.invoke(biomebase, i);
} catch (IllegalAccessException x) {

View File

@ -110,6 +110,7 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
cw_gethandle = getMethod(craftworld, new String[] { "getHandle" }, new Class[0]);
/* CraftChunkSnapshot */
craftchunksnapshot = getOBCClass("org.bukkit.craftbukkit.CraftChunkSnapshot");
biomebasearray = getNMSClass("[Lnet.minecraft.server.BiomeBase;");
ccss_biome = getPrivateField(craftchunksnapshot, new String[] { "biome" }, biomebasearray);
/* CraftChunk */
craftchunk = getOBCClass("org.bukkit.craftbukkit.CraftChunk");
@ -235,9 +236,14 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
try {
return field.get(obj);
} catch (IllegalArgumentException e) {
System.out.println(String.format("IllegalArgExc(%s,%s)", obj.toString(), field.toString()));
} catch (IllegalAccessException e) {
System.out.println(String.format("IllegalAccessExc(%s,%s)", obj.toString(), field.toString()));
}
}
else {
System.out.println(String.format("NullArg(%s,%s)", (obj != null)?obj.toString():"null", (field != null)?field.toString():"null"));
}
return def;
}
/**

View File

@ -48,6 +48,7 @@ public class NewMapChunkCache extends MapChunkCache {
private BiomeMap[][] biomemap;
private boolean[][] isSectionNotEmpty; /* Indexed by snapshot index, then by section index */
private long[] inhabitedTicks; /* Index = (x-x_min) + ((z-z_min)*x_dim) */
private static final BiomeMap[] nullBiomeMap = { BiomeMap.NULL };
private static BukkitVersionHelper helper = BukkitVersionHelper.getHelper();
@ -145,8 +146,8 @@ public class NewMapChunkCache extends MapChunkCache {
sameneighborbiomecnt[i] = new byte[z_size];
biomemap[i] = new BiomeMap[z_size];
}
ChunkSnapshot last_css = null;
Object[] biomebase = null;
ChunkSnapshot biome_css = null;
for(int i = 0; i < x_size; i++) {
for(int j = 0; j < z_size; j++) {
BiomeMap bm;
@ -156,15 +157,19 @@ public class NewMapChunkCache extends MapChunkCache {
else {
stepPosition(BlockStep.Z_PLUS);
}
if(snap != biome_css) {
biomebase = null;
biome_css = snap;
if (biome_css instanceof SpoutChunkSnapshot) {
biome_css = ((SpoutChunkSnapshot)biome_css).chunk;
if (last_css != snap) {
if ((snap instanceof EmptyChunk) || (snap instanceof PlainChunk)) {
biomebase = nullBiomeMap;
}
biomebase = helper.getBiomeBaseFromSnapshot(biome_css);
else {
biomebase = helper.getBiomeBaseFromSnapshot(snap);
}
last_css = snap;
}
if(biomebase != null) {
if (biomebase == nullBiomeMap) {
bm = BiomeMap.NULL;
}
else if(biomebase != null) {
bm = BiomeMap.byBiomeID(helper.getBiomeBaseID(biomebase[bz << 4 | bx]));
}
else {
@ -675,56 +680,6 @@ public class NewMapChunkCache extends MapChunkCache {
return (sy < 4);
}
}
private static class SpoutChunkSnapshot implements ChunkSnapshot {
private ChunkSnapshot chunk;
private short[] customids;
private final int shiftx;
private final int shiftz;
SpoutChunkSnapshot(ChunkSnapshot chunk, short[] customids, int height) {
this.chunk = chunk;
this.customids = customids.clone();
int sx = 11;
int sz = 7; /* 128 high values */
while(height > 128) {
sx++;
sz++;
height = (height >> 1);
}
shiftx = sx;
shiftz = sz;
}
/* Need these for interface, but not used */
public final int getX() { return chunk.getX(); }
public final int getZ() { return chunk.getZ(); }
public final String getWorldName() { return chunk.getWorldName(); }
public final Biome getBiome(int x, int z) { return chunk.getBiome(x, z); }
public final double getRawBiomeTemperature(int x, int z) { return chunk.getRawBiomeTemperature(x, z); }
public final double getRawBiomeRainfall(int x, int z) { return chunk.getRawBiomeRainfall(x, z); }
public final long getCaptureFullTime() { return chunk.getCaptureFullTime(); }
public final int getBlockTypeId(int x, int y, int z) {
int id = customids[(x << shiftx) | (z << shiftz) | y];
if(id != 0) return id;
return chunk.getBlockTypeId(x, y, z);
}
public final int getBlockData(int x, int y, int z) {
return chunk.getBlockData(x, y, z);
}
public final int getBlockSkyLight(int x, int y, int z) {
return chunk.getBlockSkyLight(x, y, z);
}
public final int getBlockEmittedLight(int x, int y, int z) {
return chunk.getBlockEmittedLight(x, y, z);
}
public final int getHighestBlockYAt(int x, int z) {
return chunk.getHighestBlockYAt(x, z);
}
public boolean isSectionEmpty(int sy) {
return chunk.isSectionEmpty(sy);
}
}
private static final EmptyChunk EMPTY = new EmptyChunk();
private static final PlainChunk STONE = new PlainChunk(1);
@ -1056,7 +1011,7 @@ public class NewMapChunkCache extends MapChunkCache {
static {
Biome[] b = Biome.values();
BiomeMap[] bm = BiomeMap.values();
biome_to_bmap = new BiomeMap[256];
biome_to_bmap = new BiomeMap[1024];
for(int i = 0; i < biome_to_bmap.length; i++) {
biome_to_bmap[i] = BiomeMap.NULL;
}