minor reflection fix

This commit is contained in:
Jesse Boyd 2016-05-02 15:40:29 +10:00
parent c599e75fa6
commit 7d9043da51
2 changed files with 20 additions and 17 deletions

View File

@ -56,7 +56,7 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk> {
if (!(currentPalette instanceof DataPaletteGlobal)) {
current.a(128, null);
}
DataPaletteBlock paletteBlock = new DataPaletteBlock();
DataPaletteBlock paletteBlock = newDataPaletteBlock();
currentPalette = (DataPalette) fieldPalette.get(current);
if (!(currentPalette instanceof DataPaletteGlobal)) {
throw new RuntimeException("Palette must be global!");
@ -85,6 +85,19 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk> {
return value;
}
public DataPaletteBlock newDataPaletteBlock() {
try {
return new DataPaletteBlock();
} catch (Throwable e) {
try {
Constructor<DataPaletteBlock> constructor = DataPaletteBlock.class.getDeclaredConstructor(IBlockData[].class);
return constructor.newInstance((Object) null);
} catch (Throwable e2) {
throw new RuntimeException(e2);
}
}
}
public void optimize() {
if (sectionPalettes != null) {
return;
@ -97,17 +110,7 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk> {
if (sectionPalettes == null) {
sectionPalettes = new DataPaletteBlock[16];
}
DataPaletteBlock palette;
try {
palette = sectionPalettes[layer] = new DataPaletteBlock();
} catch (Throwable e) {
try {
Constructor<DataPaletteBlock> constructor = DataPaletteBlock.class.getDeclaredConstructor(IBlockData[].class);
palette = sectionPalettes[layer] = constructor.newInstance(null);
} catch (Throwable e2) {
throw new RuntimeException(e2);
}
}
DataPaletteBlock palette = newDataPaletteBlock();
char[] blocks = getIdArray(layer);
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {

View File

@ -236,10 +236,10 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
try {
if (array == null) {
Constructor<ChunkSection> constructor = ChunkSection.class.getDeclaredConstructor(int.class, boolean.class, IBlockData[].class);
return constructor.newInstance(y2, flag, null);
return constructor.newInstance(y2, flag, (IBlockData[]) null);
} else {
Constructor<ChunkSection> constructor = ChunkSection.class.getDeclaredConstructor(int.class, boolean.class, char[].class, IBlockData[].class);
return constructor.newInstance(y2, flag, array, null);
return constructor.newInstance(y2, flag, array, (IBlockData[]) null);
}
} catch (Throwable e2) {
throw new RuntimeException(e2);
@ -311,12 +311,12 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
ChunkSection section = sections[j];
if (section == null) {
if (fs.sectionPalettes != null && fs.sectionPalettes[j] != null) {
section = sections[j] = new ChunkSection(j << 4, flag);
section = sections[j] = newChunkSection(j << 4, flag, null);
setPalette(section, fs.sectionPalettes[j]);
setCount(0, count - fs.getAir(j), section);
continue;
} else {
sections[j] = new ChunkSection(j << 4, flag, array);
sections[j] = newChunkSection(j << 4, flag, array);
}
continue;
} else if (count >= 4096) {
@ -325,7 +325,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
setCount(0, count - fs.getAir(j), section);
continue;
} else {
sections[j] = new ChunkSection(j << 4, flag, array);
sections[j] = newChunkSection(j << 4, flag, array);
}
continue;
}