mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-15 20:04:43 +02:00
Major code reformatting
This commit is contained in:
@ -17,12 +17,13 @@ public class FastChunk_1_8_3 extends PlotChunk<Chunk> {
|
||||
public short[] relight;
|
||||
public int[][] biomes;
|
||||
public Chunk chunk;
|
||||
public FastChunk_1_8_3(final ChunkWrapper chunk) {
|
||||
|
||||
public FastChunk_1_8_3(ChunkWrapper chunk) {
|
||||
super(chunk);
|
||||
ids = new char[16][];
|
||||
count = new short[16];
|
||||
air = new short[16];
|
||||
relight = new short[16];
|
||||
this.ids = new char[16][];
|
||||
this.count = new short[16];
|
||||
this.air = new short[16];
|
||||
this.relight = new short[16];
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -33,17 +34,17 @@ public class FastChunk_1_8_3 extends PlotChunk<Chunk> {
|
||||
|
||||
@Override
|
||||
public Chunk getChunk() {
|
||||
if (chunk == null) {
|
||||
final ChunkWrapper cl = getChunkWrapper();
|
||||
chunk = Bukkit.getWorld(cl.world).getChunkAt(cl.x, cl.z);
|
||||
if (this.chunk == null) {
|
||||
ChunkWrapper cl = getChunkWrapper();
|
||||
this.chunk = Bukkit.getWorld(cl.world).getChunkAt(cl.x, cl.z);
|
||||
}
|
||||
return chunk;
|
||||
return this.chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChunkWrapper(final ChunkWrapper loc) {
|
||||
public void setChunkWrapper(ChunkWrapper loc) {
|
||||
super.setChunkWrapper(loc);
|
||||
chunk = null;
|
||||
this.chunk = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,44 +52,44 @@ public class FastChunk_1_8_3 extends PlotChunk<Chunk> {
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public int getCount(final int i) {
|
||||
return count[i];
|
||||
public int getCount(int i) {
|
||||
return this.count[i];
|
||||
}
|
||||
|
||||
public int getAir(final int i) {
|
||||
return air[i];
|
||||
public int getAir(int i) {
|
||||
return this.air[i];
|
||||
}
|
||||
|
||||
public void setCount(int i, short value) {
|
||||
count[i] = value;
|
||||
this.count[i] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of block changes in a specified section
|
||||
* Get the number of block changes in a specified section.
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public int getRelight(final int i) {
|
||||
return relight[i];
|
||||
public int getRelight(int i) {
|
||||
return this.relight[i];
|
||||
}
|
||||
|
||||
public int getTotalCount() {
|
||||
int total = 0;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
total += count[i];
|
||||
total += this.count[i];
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int getTotalRelight() {
|
||||
if (getTotalCount() == 0) {
|
||||
Arrays.fill(count, (short) 1);
|
||||
Arrays.fill(relight, Short.MAX_VALUE);
|
||||
Arrays.fill(this.count, (short) 1);
|
||||
Arrays.fill(this.relight, Short.MAX_VALUE);
|
||||
return Short.MAX_VALUE;
|
||||
}
|
||||
int total = 0;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
total += relight[i];
|
||||
total += this.relight[i];
|
||||
}
|
||||
return total;
|
||||
}
|
||||
@ -98,24 +99,24 @@ public class FastChunk_1_8_3 extends PlotChunk<Chunk> {
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public char[] getIdArray(final int i) {
|
||||
return ids[i];
|
||||
public char[] getIdArray(int i) {
|
||||
return this.ids[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(final int x, final int y, final int z, final int id, byte data) {
|
||||
final int i = MainUtil.CACHE_I[y][x][z];
|
||||
final int j = MainUtil.CACHE_J[y][x][z];
|
||||
char[] vs = ids[i];
|
||||
public void setBlock(int x, int y, int z, int id, byte data) {
|
||||
int i = MainUtil.CACHE_I[y][x][z];
|
||||
int j = MainUtil.CACHE_J[y][x][z];
|
||||
char[] vs = this.ids[i];
|
||||
if (vs == null) {
|
||||
vs = ids[i] = new char[4096];
|
||||
count[i]++;
|
||||
vs = this.ids[i] = new char[4096];
|
||||
this.count[i]++;
|
||||
} else if (vs[j] == 0) {
|
||||
count[i]++;
|
||||
this.count[i]++;
|
||||
}
|
||||
switch (id) {
|
||||
case 0:
|
||||
air[i]++;
|
||||
this.air[i]++;
|
||||
vs[j] = (char) 1;
|
||||
return;
|
||||
case 10:
|
||||
@ -129,7 +130,7 @@ public class FastChunk_1_8_3 extends PlotChunk<Chunk> {
|
||||
case 124:
|
||||
case 138:
|
||||
case 169:
|
||||
relight[i]++;
|
||||
this.relight[i]++;
|
||||
case 2:
|
||||
case 4:
|
||||
case 13:
|
||||
@ -193,7 +194,7 @@ public class FastChunk_1_8_3 extends PlotChunk<Chunk> {
|
||||
case 130:
|
||||
case 76:
|
||||
case 62:
|
||||
relight[i]++;
|
||||
this.relight[i]++;
|
||||
case 54:
|
||||
case 146:
|
||||
case 61:
|
||||
@ -212,12 +213,12 @@ public class FastChunk_1_8_3 extends PlotChunk<Chunk> {
|
||||
@Override
|
||||
public PlotChunk clone() {
|
||||
FastChunk_1_8_3 toReturn = new FastChunk_1_8_3(getChunkWrapper());
|
||||
toReturn.air = air.clone();
|
||||
toReturn.count = count.clone();
|
||||
toReturn.relight = relight.clone();
|
||||
toReturn.ids = new char[ids.length][];
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
char[] matrix = ids[i];
|
||||
toReturn.air = this.air.clone();
|
||||
toReturn.count = this.count.clone();
|
||||
toReturn.relight = this.relight.clone();
|
||||
toReturn.ids = new char[this.ids.length][];
|
||||
for (int i = 0; i < this.ids.length; i++) {
|
||||
char[] matrix = this.ids[i];
|
||||
if (matrix != null) {
|
||||
toReturn.ids[i] = new char[matrix.length];
|
||||
System.arraycopy(matrix, 0, toReturn.ids[i], 0, matrix.length);
|
||||
@ -229,18 +230,18 @@ public class FastChunk_1_8_3 extends PlotChunk<Chunk> {
|
||||
@Override
|
||||
public PlotChunk shallowClone() {
|
||||
FastChunk_1_8_3 toReturn = new FastChunk_1_8_3(getChunkWrapper());
|
||||
toReturn.air = air;
|
||||
toReturn.count = count;
|
||||
toReturn.relight = relight;
|
||||
toReturn.ids = ids;
|
||||
toReturn.air = this.air;
|
||||
toReturn.count = this.count;
|
||||
toReturn.relight = this.relight;
|
||||
toReturn.ids = this.ids;
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, int biome) {
|
||||
if (biomes == null) {
|
||||
biomes = new int[16][16];
|
||||
if (this.biomes == null) {
|
||||
this.biomes = new int[16][16];
|
||||
}
|
||||
biomes[x][z] = biome;
|
||||
this.biomes[x][z] = biome;
|
||||
}
|
||||
}
|
||||
|
@ -17,12 +17,13 @@ public class FastChunk_1_9 extends PlotChunk<Chunk> {
|
||||
public short[] relight;
|
||||
public int[][] biomes;
|
||||
public Chunk chunk;
|
||||
public FastChunk_1_9(final ChunkWrapper chunk) {
|
||||
|
||||
public FastChunk_1_9(ChunkWrapper chunk) {
|
||||
super(chunk);
|
||||
ids = new int[16][];
|
||||
count = new short[16];
|
||||
air = new short[16];
|
||||
relight = new short[16];
|
||||
this.ids = new int[16][];
|
||||
this.count = new short[16];
|
||||
this.air = new short[16];
|
||||
this.relight = new short[16];
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -33,17 +34,17 @@ public class FastChunk_1_9 extends PlotChunk<Chunk> {
|
||||
|
||||
@Override
|
||||
public Chunk getChunk() {
|
||||
if (chunk == null) {
|
||||
final ChunkWrapper cl = getChunkWrapper();
|
||||
chunk = Bukkit.getWorld(cl.world).getChunkAt(cl.x, cl.z);
|
||||
if (this.chunk == null) {
|
||||
ChunkWrapper cl = getChunkWrapper();
|
||||
this.chunk = Bukkit.getWorld(cl.world).getChunkAt(cl.x, cl.z);
|
||||
}
|
||||
return chunk;
|
||||
return this.chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChunkWrapper(final ChunkWrapper loc) {
|
||||
public void setChunkWrapper(ChunkWrapper loc) {
|
||||
super.setChunkWrapper(loc);
|
||||
chunk = null;
|
||||
this.chunk = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,16 +52,16 @@ public class FastChunk_1_9 extends PlotChunk<Chunk> {
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public int getCount(final int i) {
|
||||
return count[i];
|
||||
public int getCount(int i) {
|
||||
return this.count[i];
|
||||
}
|
||||
|
||||
public int getAir(final int i) {
|
||||
return air[i];
|
||||
public int getAir(int i) {
|
||||
return this.air[i];
|
||||
}
|
||||
|
||||
public void setCount(int i, short value) {
|
||||
count[i] = value;
|
||||
this.count[i] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,27 +69,27 @@ public class FastChunk_1_9 extends PlotChunk<Chunk> {
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public int getRelight(final int i) {
|
||||
return relight[i];
|
||||
public int getRelight(int i) {
|
||||
return this.relight[i];
|
||||
}
|
||||
|
||||
public int getTotalCount() {
|
||||
int total = 0;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
total += count[i];
|
||||
total += this.count[i];
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int getTotalRelight() {
|
||||
if (getTotalCount() == 0) {
|
||||
Arrays.fill(count, (short) 1);
|
||||
Arrays.fill(relight, Short.MAX_VALUE);
|
||||
Arrays.fill(this.count, (short) 1);
|
||||
Arrays.fill(this.relight, Short.MAX_VALUE);
|
||||
return Short.MAX_VALUE;
|
||||
}
|
||||
int total = 0;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
total += relight[i];
|
||||
total += this.relight[i];
|
||||
}
|
||||
return total;
|
||||
}
|
||||
@ -98,28 +99,28 @@ public class FastChunk_1_9 extends PlotChunk<Chunk> {
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public int[] getIdArray(final int i) {
|
||||
return ids[i];
|
||||
public int[] getIdArray(int i) {
|
||||
return this.ids[i];
|
||||
}
|
||||
|
||||
public int[][] getIdArrays() {
|
||||
return ids;
|
||||
return this.ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(final int x, final int y, final int z, final int id, byte data) {
|
||||
final int i = MainUtil.CACHE_I[y][x][z];
|
||||
final int j = MainUtil.CACHE_J[y][x][z];
|
||||
int[] vs = ids[i];
|
||||
public void setBlock(int x, int y, int z, int id, byte data) {
|
||||
int i = MainUtil.CACHE_I[y][x][z];
|
||||
int j = MainUtil.CACHE_J[y][x][z];
|
||||
int[] vs = this.ids[i];
|
||||
if (vs == null) {
|
||||
vs = ids[i] = new int[4096];
|
||||
count[i]++;
|
||||
vs = this.ids[i] = new int[4096];
|
||||
this.count[i]++;
|
||||
} else if (vs[j] == 0) {
|
||||
count[i]++;
|
||||
this.count[i]++;
|
||||
}
|
||||
switch (id) {
|
||||
case 0:
|
||||
air[i]++;
|
||||
this.air[i]++;
|
||||
vs[j] = -1;
|
||||
return;
|
||||
case 10:
|
||||
@ -133,7 +134,7 @@ public class FastChunk_1_9 extends PlotChunk<Chunk> {
|
||||
case 124:
|
||||
case 138:
|
||||
case 169:
|
||||
relight[i]++;
|
||||
this.relight[i]++;
|
||||
case 2:
|
||||
case 4:
|
||||
case 13:
|
||||
@ -192,12 +193,12 @@ public class FastChunk_1_9 extends PlotChunk<Chunk> {
|
||||
case 190:
|
||||
case 191:
|
||||
case 192:
|
||||
vs[j] = (id);
|
||||
vs[j] = id;
|
||||
return;
|
||||
case 130:
|
||||
case 76:
|
||||
case 62:
|
||||
relight[i]++;
|
||||
this.relight[i]++;
|
||||
case 54:
|
||||
case 146:
|
||||
case 61:
|
||||
@ -216,12 +217,12 @@ public class FastChunk_1_9 extends PlotChunk<Chunk> {
|
||||
@Override
|
||||
public PlotChunk clone() {
|
||||
FastChunk_1_9 toReturn = new FastChunk_1_9(getChunkWrapper());
|
||||
toReturn.air = air.clone();
|
||||
toReturn.count = count.clone();
|
||||
toReturn.relight = relight.clone();
|
||||
toReturn.ids = new int[ids.length][];
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
int[] matrix = ids[i];
|
||||
toReturn.air = this.air.clone();
|
||||
toReturn.count = this.count.clone();
|
||||
toReturn.relight = this.relight.clone();
|
||||
toReturn.ids = new int[this.ids.length][];
|
||||
for (int i = 0; i < this.ids.length; i++) {
|
||||
int[] matrix = this.ids[i];
|
||||
if (matrix != null) {
|
||||
toReturn.ids[i] = new int[matrix.length];
|
||||
System.arraycopy(matrix, 0, toReturn.ids[i], 0, matrix.length);
|
||||
@ -233,18 +234,18 @@ public class FastChunk_1_9 extends PlotChunk<Chunk> {
|
||||
@Override
|
||||
public PlotChunk shallowClone() {
|
||||
FastChunk_1_9 toReturn = new FastChunk_1_9(getChunkWrapper());
|
||||
toReturn.air = air;
|
||||
toReturn.count = count;
|
||||
toReturn.relight = relight;
|
||||
toReturn.ids = ids;
|
||||
toReturn.air = this.air;
|
||||
toReturn.count = this.count;
|
||||
toReturn.relight = this.relight;
|
||||
toReturn.ids = this.ids;
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, int biome) {
|
||||
if (biomes == null) {
|
||||
biomes = new int[16][16];
|
||||
if (this.biomes == null) {
|
||||
this.biomes = new int[16][16];
|
||||
}
|
||||
biomes[x][z] = biome;
|
||||
this.biomes[x][z] = biome;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.plotsquared.bukkit.util.block;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
@ -21,8 +23,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
public class FastQueue_1_7 extends SlowQueue {
|
||||
|
||||
private final RefClass classBlock = getRefClass("{nms}.Block");
|
||||
@ -37,24 +37,24 @@ public class FastQueue_1_7 extends SlowQueue {
|
||||
|
||||
private final SendChunk chunksender;
|
||||
|
||||
private HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||
|
||||
public FastQueue_1_7() throws NoSuchMethodException, RuntimeException {
|
||||
methodGetHandle = classCraftWorld.getMethod("getHandle");
|
||||
methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class);
|
||||
methodA = classChunk.getMethod("a", int.class, int.class, int.class, classBlock, int.class);
|
||||
methodGetById = classBlock.getMethod("getById", int.class);
|
||||
methodInitLighting = classChunk.getMethod("initLighting");
|
||||
chunksender = new SendChunk();
|
||||
this.methodGetHandle = this.classCraftWorld.getMethod("getHandle");
|
||||
this.methodGetChunkAt = this.classWorld.getMethod("getChunkAt", int.class, int.class);
|
||||
this.methodA = this.classChunk.getMethod("a", int.class, int.class, int.class, this.classBlock, int.class);
|
||||
this.methodGetById = this.classBlock.getMethod("getById", int.class);
|
||||
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
||||
this.chunksender = new SendChunk();
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (toUpdate.isEmpty()) {
|
||||
if (FastQueue_1_7.this.toUpdate.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
int count = 0;
|
||||
final ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
final Iterator<Entry<ChunkWrapper, Chunk>> i = toUpdate.entrySet().iterator();
|
||||
ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
Iterator<Entry<ChunkWrapper, Chunk>> i = FastQueue_1_7.this.toUpdate.entrySet().iterator();
|
||||
while (i.hasNext() && (count < 128)) {
|
||||
chunks.add(i.next().getValue());
|
||||
i.remove();
|
||||
@ -69,12 +69,12 @@ public class FastQueue_1_7 extends SlowQueue {
|
||||
MainUtil.initCache();
|
||||
}
|
||||
|
||||
public void update(final Collection<Chunk> chunks) {
|
||||
public void update(Collection<Chunk> chunks) {
|
||||
if (chunks.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!MainUtil.canSendChunk) {
|
||||
for (final Chunk chunk : chunks) {
|
||||
for (Chunk chunk : chunks) {
|
||||
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
|
||||
chunk.unload(true, false);
|
||||
chunk.load();
|
||||
@ -82,8 +82,8 @@ public class FastQueue_1_7 extends SlowQueue {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
chunksender.sendChunk(chunks);
|
||||
} catch (final Throwable e) {
|
||||
this.chunksender.sendChunk(chunks);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.canSendChunk = false;
|
||||
}
|
||||
@ -91,36 +91,36 @@ public class FastQueue_1_7 extends SlowQueue {
|
||||
|
||||
/**
|
||||
* This should be overridden by any specialized queues
|
||||
* @param pc
|
||||
* @param plotChunk
|
||||
*/
|
||||
@Override
|
||||
public void execute(PlotChunk<Chunk> pc) {
|
||||
SlowChunk sc = (SlowChunk) pc;
|
||||
Chunk chunk = pc.getChunk();
|
||||
ChunkWrapper wrapper = pc.getChunkWrapper();
|
||||
if (!toUpdate.containsKey(wrapper)) {
|
||||
toUpdate.put(wrapper, chunk);
|
||||
public void execute(PlotChunk<Chunk> plotChunk) {
|
||||
SlowChunk sc = (SlowChunk) plotChunk;
|
||||
Chunk chunk = plotChunk.getChunk();
|
||||
ChunkWrapper wrapper = plotChunk.getChunkWrapper();
|
||||
if (!this.toUpdate.containsKey(wrapper)) {
|
||||
this.toUpdate.put(wrapper, chunk);
|
||||
}
|
||||
chunk.load(true);
|
||||
World world = chunk.getWorld();
|
||||
final Object w = methodGetHandle.of(world).call();
|
||||
final Object c = methodGetChunkAt.of(w).call(wrapper.x, wrapper.z);
|
||||
Object w = this.methodGetHandle.of(world).call();
|
||||
Object c = this.methodGetChunkAt.of(w).call(wrapper.x, wrapper.z);
|
||||
for (int i = 0; i < sc.result.length; i++) {
|
||||
PlotBlock[] result2 = sc.result[i];
|
||||
if (result2 == null) {
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < 4096; j++) {
|
||||
final int x = MainUtil.x_loc[i][j];
|
||||
final int y = MainUtil.y_loc[i][j];
|
||||
final int z = MainUtil.z_loc[i][j];
|
||||
int x = MainUtil.x_loc[i][j];
|
||||
int y = MainUtil.y_loc[i][j];
|
||||
int z = MainUtil.z_loc[i][j];
|
||||
PlotBlock newBlock = result2[j];
|
||||
if (newBlock.id == -1) {
|
||||
chunk.getBlock(x, y, z).setData(newBlock.data, false);
|
||||
continue;
|
||||
}
|
||||
final Object block = methodGetById.call(newBlock.id);
|
||||
methodA.of(c).call(x, y, z, block, newBlock.data);
|
||||
Object block = this.methodGetById.call(newBlock.id);
|
||||
this.methodA.of(c).call(x, y, z, block, newBlock.data);
|
||||
}
|
||||
}
|
||||
int[][] biomes = sc.biomes;
|
||||
@ -152,29 +152,29 @@ public class FastQueue_1_7 extends SlowQueue {
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overriden by any specialized queues
|
||||
* This should be overridden by any specialized queues
|
||||
* @param chunk
|
||||
* @param fixAll
|
||||
*/
|
||||
@Override
|
||||
public boolean fixLighting(PlotChunk<Chunk> chunk, boolean fixAll) {
|
||||
Object c = methodGetHandle.of(chunk.getChunk()).call();
|
||||
methodInitLighting.of(c).call();
|
||||
Object c = this.methodGetHandle.of(chunk.getChunk()).call();
|
||||
this.methodInitLighting.of(c).call();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overridden by any specialized queues
|
||||
* @param world
|
||||
* @param locs
|
||||
* @param locations
|
||||
*/
|
||||
@Override
|
||||
public void sendChunk(String world, Collection<ChunkLoc> locs) {
|
||||
public void sendChunk(String world, Collection<ChunkLoc> locations) {
|
||||
World worldObj = BukkitUtil.getWorld(world);
|
||||
for (ChunkLoc loc : locs) {
|
||||
for (ChunkLoc loc : locations) {
|
||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||
toUpdate.remove(wrapper);
|
||||
this.toUpdate.remove(wrapper);
|
||||
}
|
||||
chunksender.sendChunk(world, locs);
|
||||
this.chunksender.sendChunk(world, locations);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.plotsquared.bukkit.util.block;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
@ -23,8 +25,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
public class FastQueue_1_8 extends SlowQueue {
|
||||
|
||||
private final RefMethod methodInitLighting;
|
||||
@ -34,31 +34,31 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
private final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
private final RefClass classWorld = getRefClass("{nms}.World");
|
||||
private final RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
|
||||
private HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||
private RefMethod methodGetHandle;
|
||||
private RefMethod methodGetChunkAt;
|
||||
private RefMethod methodA;
|
||||
private RefMethod methodGetByCombinedId;
|
||||
private RefConstructor constructorBlockPosition;
|
||||
private SendChunk chunksender;
|
||||
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||
private final RefMethod methodGetHandle;
|
||||
private final RefMethod methodGetChunkAt;
|
||||
private final RefMethod methodA;
|
||||
private final RefMethod methodGetByCombinedId;
|
||||
private final RefConstructor constructorBlockPosition;
|
||||
private final SendChunk chunksender;
|
||||
|
||||
public FastQueue_1_8() throws NoSuchMethodException, RuntimeException {
|
||||
methodInitLighting = classChunk.getMethod("initLighting");
|
||||
constructorBlockPosition = classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||
methodGetByCombinedId = classBlock.getMethod("getByCombinedId", int.class);
|
||||
methodGetHandle = classCraftWorld.getMethod("getHandle");
|
||||
methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class);
|
||||
methodA = classChunk.getMethod("a", classBlockPosition, classIBlockData);
|
||||
chunksender = new SendChunk();
|
||||
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
||||
this.constructorBlockPosition = this.classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||
this.methodGetByCombinedId = this.classBlock.getMethod("getByCombinedId", int.class);
|
||||
this.methodGetHandle = this.classCraftWorld.getMethod("getHandle");
|
||||
this.methodGetChunkAt = this.classWorld.getMethod("getChunkAt", int.class, int.class);
|
||||
this.methodA = this.classChunk.getMethod("a", this.classBlockPosition, this.classIBlockData);
|
||||
this.chunksender = new SendChunk();
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (toUpdate.isEmpty()) {
|
||||
if (FastQueue_1_8.this.toUpdate.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
int count = 0;
|
||||
final ArrayList<Chunk> chunks = new ArrayList<Chunk>();
|
||||
final Iterator<Entry<ChunkWrapper, Chunk>> i = toUpdate.entrySet().iterator();
|
||||
ArrayList<Chunk> chunks = new ArrayList<Chunk>();
|
||||
Iterator<Entry<ChunkWrapper, Chunk>> i = FastQueue_1_8.this.toUpdate.entrySet().iterator();
|
||||
while (i.hasNext() && (count < 128)) {
|
||||
chunks.add(i.next().getValue());
|
||||
i.remove();
|
||||
@ -73,12 +73,12 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
MainUtil.initCache();
|
||||
}
|
||||
|
||||
public void update(final Collection<Chunk> chunks) {
|
||||
public void update(Collection<Chunk> chunks) {
|
||||
if (chunks.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!MainUtil.canSendChunk) {
|
||||
for (final Chunk chunk : chunks) {
|
||||
for (Chunk chunk : chunks) {
|
||||
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
|
||||
chunk.unload(true, false);
|
||||
chunk.load();
|
||||
@ -86,38 +86,38 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
chunksender.sendChunk(chunks);
|
||||
} catch (final Throwable e) {
|
||||
this.chunksender.sendChunk(chunks);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.canSendChunk = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overriden by any specialized queues
|
||||
* @param pc
|
||||
* This should be overridden by any specialized queues.
|
||||
* @param plotChunk
|
||||
*/
|
||||
@Override
|
||||
public void execute(PlotChunk<Chunk> pc) {
|
||||
SlowChunk sc = (SlowChunk) pc;
|
||||
Chunk chunk = pc.getChunk();
|
||||
ChunkWrapper wrapper = pc.getChunkWrapper();
|
||||
if (!toUpdate.containsKey(wrapper)) {
|
||||
toUpdate.put(wrapper, chunk);
|
||||
public void execute(PlotChunk<Chunk> plotChunk) {
|
||||
SlowChunk sc = (SlowChunk) plotChunk;
|
||||
Chunk chunk = plotChunk.getChunk();
|
||||
ChunkWrapper wrapper = plotChunk.getChunkWrapper();
|
||||
if (!this.toUpdate.containsKey(wrapper)) {
|
||||
this.toUpdate.put(wrapper, chunk);
|
||||
}
|
||||
chunk.load(true);
|
||||
World world = chunk.getWorld();
|
||||
final Object w = methodGetHandle.of(world).call();
|
||||
final Object c = methodGetChunkAt.of(w).call(wrapper.x, wrapper.z);
|
||||
Object w = this.methodGetHandle.of(world).call();
|
||||
Object c = this.methodGetChunkAt.of(w).call(wrapper.x, wrapper.z);
|
||||
for (int i = 0; i < sc.result.length; i++) {
|
||||
PlotBlock[] result2 = sc.result[i];
|
||||
if (result2 == null) {
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < 4096; j++) {
|
||||
final int x = MainUtil.x_loc[i][j];
|
||||
final int y = MainUtil.y_loc[i][j];
|
||||
final int z = MainUtil.z_loc[i][j];
|
||||
int x = MainUtil.x_loc[i][j];
|
||||
int y = MainUtil.y_loc[i][j];
|
||||
int z = MainUtil.z_loc[i][j];
|
||||
PlotBlock newBlock = result2[j];
|
||||
if (newBlock.id == -1) {
|
||||
chunk.getBlock(x, y, z).setData(newBlock.data, false);
|
||||
@ -162,7 +162,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
case 33:
|
||||
case 151:
|
||||
case 178: {
|
||||
final Block block = world.getBlockAt(x, y, z);
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
if (block.getData() == newBlock.data) {
|
||||
if (block.getTypeId() != newBlock.id) {
|
||||
block.setTypeId(newBlock.id, false);
|
||||
@ -179,8 +179,8 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
}
|
||||
|
||||
// Start data value shortcut
|
||||
final Block block = world.getBlockAt(x, y, z);
|
||||
final int currentId = block.getTypeId();
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
int currentId = block.getTypeId();
|
||||
if (currentId == newBlock.id) {
|
||||
switch (newBlock.id) {
|
||||
case 0:
|
||||
@ -323,9 +323,9 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
// End blockstate workaround //
|
||||
|
||||
// check sign
|
||||
final Object pos = constructorBlockPosition.create(x, y, z);
|
||||
final Object combined = methodGetByCombinedId.call(newBlock.id + (newBlock.data << 12));
|
||||
methodA.of(chunk).call(pos, combined);
|
||||
Object pos = this.constructorBlockPosition.create(x, y, z);
|
||||
Object combined = this.methodGetByCombinedId.call(newBlock.id + (newBlock.data << 12));
|
||||
this.methodA.of(chunk).call(pos, combined);
|
||||
}
|
||||
}
|
||||
int[][] biomes = sc.biomes;
|
||||
@ -348,7 +348,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overridden by any specialized queues
|
||||
* This should be overridden by any specialized queues.
|
||||
* @param wrap
|
||||
*/
|
||||
@Override
|
||||
@ -357,27 +357,27 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overridden by any specialized queues
|
||||
* This should be overridden by any specialized queues.
|
||||
* @param fixAll
|
||||
*/
|
||||
@Override
|
||||
public boolean fixLighting(PlotChunk<Chunk> chunk, boolean fixAll) {
|
||||
Object c = methodGetHandle.of(chunk.getChunk()).call();
|
||||
methodInitLighting.of(c).call();
|
||||
Object c = this.methodGetHandle.of(chunk.getChunk()).call();
|
||||
this.methodInitLighting.of(c).call();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overridden by any specialized queues
|
||||
* @param locs
|
||||
* This should be overridden by any specialized queues.
|
||||
* @param locations
|
||||
*/
|
||||
@Override
|
||||
public void sendChunk(String world, Collection<ChunkLoc> locs) {
|
||||
public void sendChunk(String world, Collection<ChunkLoc> locations) {
|
||||
World worldObj = BukkitUtil.getWorld(world);
|
||||
for (ChunkLoc loc : locs) {
|
||||
for (ChunkLoc loc : locations) {
|
||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||
toUpdate.remove(wrapper);
|
||||
this.toUpdate.remove(wrapper);
|
||||
}
|
||||
chunksender.sendChunk(world, locs);
|
||||
this.chunksender.sendChunk(world, locations);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,20 @@
|
||||
package com.plotsquared.bukkit.util.block;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.util.SendChunk;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
@ -20,59 +25,57 @@ import org.bukkit.block.Biome;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
import java.util.Set;
|
||||
|
||||
public class FastQueue_1_8_3 extends SlowQueue {
|
||||
|
||||
private final SendChunk chunksender;
|
||||
private final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
|
||||
private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
||||
private final RefClass classPacket = getRefClass("{nms}.Packet");
|
||||
private final RefClass classConnection = getRefClass("{nms}.PlayerConnection");
|
||||
private final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
private final RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer");
|
||||
private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||
private final RefClass classWorld = getRefClass("{nms}.World");
|
||||
private final RefField mustSave = classChunk.getField("mustSave");
|
||||
private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
|
||||
private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
|
||||
private HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||
private RefMethod methodGetHandleChunk;
|
||||
private RefConstructor MapChunk;
|
||||
private RefMethod methodInitLighting;
|
||||
private RefConstructor classBlockPositionConstructor;
|
||||
private RefConstructor classChunkSectionConstructor;
|
||||
private RefMethod methodX;
|
||||
private RefMethod methodAreNeighborsLoaded;
|
||||
private RefField fieldSections;
|
||||
private RefField fieldWorld;
|
||||
private RefMethod methodGetIdArray;
|
||||
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||
private final RefMethod methodGetHandleChunk;
|
||||
private final RefConstructor MapChunk;
|
||||
private final RefMethod methodInitLighting;
|
||||
private final RefConstructor classBlockPositionConstructor;
|
||||
private final RefConstructor classChunkSectionConstructor;
|
||||
private final RefMethod methodX;
|
||||
private final RefMethod methodAreNeighborsLoaded;
|
||||
private final RefField fieldSections;
|
||||
private final RefField fieldWorld;
|
||||
private final RefMethod methodGetIdArray;
|
||||
|
||||
public FastQueue_1_8_3() throws NoSuchMethodException, RuntimeException {
|
||||
methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||
methodInitLighting = classChunk.getMethod("initLighting");
|
||||
MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
||||
classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||
methodX = classWorld.getMethod("x", classBlockPosition.getRealClass());
|
||||
fieldSections = classChunk.getField("sections");
|
||||
fieldWorld = classChunk.getField("world");
|
||||
methodGetIdArray = classChunkSection.getMethod("getIdArray");
|
||||
methodAreNeighborsLoaded = classChunk.getMethod("areNeighborsLoaded", int.class);
|
||||
classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
||||
chunksender = new SendChunk();
|
||||
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||
RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
this.methodInitLighting = classChunk.getMethod("initLighting");
|
||||
RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
||||
this.MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
||||
RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
|
||||
this.classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||
RefClass classWorld = getRefClass("{nms}.World");
|
||||
this.methodX = classWorld.getMethod("x", classBlockPosition.getRealClass());
|
||||
this.fieldSections = classChunk.getField("sections");
|
||||
this.fieldWorld = classChunk.getField("world");
|
||||
RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
|
||||
this.methodGetIdArray = classChunkSection.getMethod("getIdArray");
|
||||
this.methodAreNeighborsLoaded = classChunk.getMethod("areNeighborsLoaded", int.class);
|
||||
this.classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
||||
this.chunksender = new SendChunk();
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (toUpdate.isEmpty()) {
|
||||
if (FastQueue_1_8_3.this.toUpdate.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
int count = 0;
|
||||
final ArrayList<Chunk> chunks = new ArrayList<Chunk>();
|
||||
final Iterator<Entry<ChunkWrapper, Chunk>> i = toUpdate.entrySet().iterator();
|
||||
while (i.hasNext() && (count < 128)) {
|
||||
ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
Iterator<Entry<ChunkWrapper, Chunk>> i = FastQueue_1_8_3.this.toUpdate.entrySet().iterator();
|
||||
while (i.hasNext() && count < 128) {
|
||||
chunks.add(i.next().getValue());
|
||||
i.remove();
|
||||
count++;
|
||||
@ -86,12 +89,12 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
MainUtil.initCache();
|
||||
}
|
||||
|
||||
public void update(final Collection<Chunk> chunks) {
|
||||
public void update(Collection<Chunk> chunks) {
|
||||
if (chunks.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!MainUtil.canSendChunk) {
|
||||
for (final Chunk chunk : chunks) {
|
||||
for (Chunk chunk : chunks) {
|
||||
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
|
||||
chunk.unload(true, false);
|
||||
chunk.load();
|
||||
@ -99,70 +102,70 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
chunksender.sendChunk(chunks);
|
||||
} catch (final Throwable e) {
|
||||
this.chunksender.sendChunk(chunks);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.canSendChunk = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overridden by any specialized queues
|
||||
* @param pc
|
||||
* This should be overridden by any specialized queues.
|
||||
* @param plotChunk
|
||||
*/
|
||||
@Override
|
||||
public void execute(PlotChunk<Chunk> pc) {
|
||||
FastChunk_1_8_3 fs = (FastChunk_1_8_3) pc;
|
||||
Chunk chunk = pc.getChunk();
|
||||
final World world = chunk.getWorld();
|
||||
ChunkWrapper wrapper = pc.getChunkWrapper();
|
||||
if (!toUpdate.containsKey(wrapper)) {
|
||||
toUpdate.put(wrapper, chunk);
|
||||
public void execute(PlotChunk<Chunk> plotChunk) {
|
||||
FastChunk_1_8_3 fs = (FastChunk_1_8_3) plotChunk;
|
||||
Chunk chunk = plotChunk.getChunk();
|
||||
World world = chunk.getWorld();
|
||||
ChunkWrapper wrapper = plotChunk.getChunkWrapper();
|
||||
if (!this.toUpdate.containsKey(wrapper)) {
|
||||
this.toUpdate.put(wrapper, chunk);
|
||||
}
|
||||
chunk.load(true);
|
||||
try {
|
||||
final boolean flag = world.getEnvironment() == Environment.NORMAL;
|
||||
boolean flag = world.getEnvironment() == Environment.NORMAL;
|
||||
|
||||
// Sections
|
||||
final Method getHandele = chunk.getClass().getDeclaredMethod("getHandle");
|
||||
final Object c = getHandele.invoke(chunk);
|
||||
final Class<? extends Object> clazz = c.getClass();
|
||||
final Field sf = clazz.getDeclaredField("sections");
|
||||
sf.setAccessible(true);
|
||||
final Field tf = clazz.getDeclaredField("tileEntities");
|
||||
final Field ef = clazz.getDeclaredField("entitySlices");
|
||||
Method getHandle = chunk.getClass().getDeclaredMethod("getHandle");
|
||||
Object c = getHandle.invoke(chunk);
|
||||
Class<? extends Object> clazz = c.getClass();
|
||||
Field sections1 = clazz.getDeclaredField("sections");
|
||||
sections1.setAccessible(true);
|
||||
Field tileEntities = clazz.getDeclaredField("tileEntities");
|
||||
Field entitySlices = clazz.getDeclaredField("entitySlices");
|
||||
|
||||
final Object[] sections = (Object[]) sf.get(c);
|
||||
final HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c);
|
||||
final List<?>[] entities = (List<?>[]) ef.get(c);
|
||||
Object[] sections = (Object[]) sections1.get(c);
|
||||
HashMap<?, ?> tiles = (HashMap<?, ?>) tileEntities.get(c);
|
||||
List<?>[] entities = (List<?>[]) entitySlices.get(c);
|
||||
|
||||
Method xm = null;
|
||||
Method ym = null;
|
||||
Method zm = null;
|
||||
Method getX = null;
|
||||
Method getY = null;
|
||||
Method getZ = null;
|
||||
|
||||
// Trim tiles
|
||||
final Set<Entry<?, ?>> entryset = (Set<Entry<?, ?>>) (Set<?>) tiles.entrySet();
|
||||
final Iterator<Entry<?, ?>> iter = entryset.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final Entry<?, ?> tile = iter.next();
|
||||
final Object pos = tile.getKey();
|
||||
if (xm == null) {
|
||||
final Class<? extends Object> clazz2 = pos.getClass().getSuperclass();
|
||||
xm = clazz2.getDeclaredMethod("getX");
|
||||
ym = clazz2.getDeclaredMethod("getY");
|
||||
zm = clazz2.getDeclaredMethod("getZ");
|
||||
Set<Entry<?, ?>> entrySet = (Set<Entry<?, ?>>) (Set<?>) tiles.entrySet();
|
||||
Iterator<Entry<?, ?>> iterator = entrySet.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entry<?, ?> tile = iterator.next();
|
||||
Object pos = tile.getKey();
|
||||
if (getX == null) {
|
||||
Class<? extends Object> clazz2 = pos.getClass().getSuperclass();
|
||||
getX = clazz2.getDeclaredMethod("getX");
|
||||
getY = clazz2.getDeclaredMethod("getY");
|
||||
getZ = clazz2.getDeclaredMethod("getZ");
|
||||
}
|
||||
final int lx = (int) xm.invoke(pos) & 15;
|
||||
final int ly = (int) ym.invoke(pos);
|
||||
final int lz = (int) zm.invoke(pos) & 15;
|
||||
final int j = MainUtil.CACHE_I[ly][lx][lz];
|
||||
final int k = MainUtil.CACHE_J[ly][lx][lz];
|
||||
final char[] array = fs.getIdArray(j);
|
||||
int lx = (int) getX.invoke(pos) & 15;
|
||||
int ly = (int) getY.invoke(pos);
|
||||
int lz = (int) getZ.invoke(pos) & 15;
|
||||
int j = MainUtil.CACHE_I[ly][lx][lz];
|
||||
int k = MainUtil.CACHE_J[ly][lx][lz];
|
||||
char[] array = fs.getIdArray(j);
|
||||
if (array == null) {
|
||||
continue;
|
||||
}
|
||||
if (array[k] != 0) {
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,7 +181,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
if (fs.getCount(j) == 0) {
|
||||
continue;
|
||||
}
|
||||
final char[] newArray = fs.getIdArray(j);
|
||||
char[] newArray = fs.getIdArray(j);
|
||||
if (newArray == null) {
|
||||
continue;
|
||||
}
|
||||
@ -187,10 +190,10 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
section = sections[j] = newChunkSection(j << 4, flag, newArray);
|
||||
continue;
|
||||
}
|
||||
final char[] currentArray = getIdArray(section);
|
||||
char[] currentArray = getIdArray(section);
|
||||
boolean fill = true;
|
||||
for (int k = 0; k < newArray.length; k++) {
|
||||
final char n = newArray[k];
|
||||
char n = newArray[k];
|
||||
switch (n) {
|
||||
case 0:
|
||||
fill = false;
|
||||
@ -209,8 +212,8 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
}
|
||||
}
|
||||
// Clear
|
||||
} catch (IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException |
|
||||
NoSuchFieldException e) {
|
||||
} catch (IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException
|
||||
| NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
int[][] biomes = fs.biomes;
|
||||
@ -232,16 +235,16 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
}
|
||||
}
|
||||
|
||||
public Object newChunkSection(final int i, final boolean flag, final char[] ids) {
|
||||
return classChunkSectionConstructor.create(i, flag, ids);
|
||||
public Object newChunkSection(int i, boolean flag, char[] ids) {
|
||||
return this.classChunkSectionConstructor.create(i, flag, ids);
|
||||
}
|
||||
|
||||
public char[] getIdArray(final Object obj) {
|
||||
return (char[]) methodGetIdArray.of(obj).call();
|
||||
public char[] getIdArray(Object obj) {
|
||||
return (char[]) this.methodGetIdArray.of(obj).call();
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overridden by any specialized queues
|
||||
* This should be overridden by any specialized queues.
|
||||
* @param wrap
|
||||
*/
|
||||
@Override
|
||||
@ -251,13 +254,13 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
|
||||
/**
|
||||
* This should be overridden by any specialized queues
|
||||
* @param pc
|
||||
* @param plotChunk
|
||||
*/
|
||||
@Override
|
||||
public boolean fixLighting(PlotChunk<Chunk> pc, boolean fixAll) {
|
||||
public boolean fixLighting(PlotChunk<Chunk> plotChunk, boolean fixAll) {
|
||||
try {
|
||||
FastChunk_1_8_3 bc = (FastChunk_1_8_3) pc;
|
||||
final Chunk chunk = bc.getChunk();
|
||||
FastChunk_1_8_3 bc = (FastChunk_1_8_3) plotChunk;
|
||||
Chunk chunk = bc.getChunk();
|
||||
if (!chunk.isLoaded()) {
|
||||
chunk.load(false);
|
||||
} else {
|
||||
@ -266,12 +269,12 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
}
|
||||
|
||||
// Initialize lighting
|
||||
final Object c = methodGetHandleChunk.of(chunk).call();
|
||||
Object c = this.methodGetHandleChunk.of(chunk).call();
|
||||
|
||||
if (fixAll && !(boolean) methodAreNeighborsLoaded.of(c).call(1)) {
|
||||
if (fixAll && !(boolean) this.methodAreNeighborsLoaded.of(c).call(1)) {
|
||||
World world = chunk.getWorld();
|
||||
ChunkWrapper wrapper = bc.getChunkWrapper();
|
||||
String worldname = wrapper.world;
|
||||
String worldName = wrapper.world;
|
||||
for (int x = wrapper.x - 1; x <= wrapper.x + 1; x++) {
|
||||
for (int z = wrapper.z - 1; z <= wrapper.z + 1; z++) {
|
||||
if (x != 0 && z != 0) {
|
||||
@ -279,44 +282,46 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
while (!other.isLoaded()) {
|
||||
other.load(true);
|
||||
}
|
||||
ChunkManager.manager.loadChunk(worldname, new ChunkLoc(x, z), true);
|
||||
ChunkManager.manager.loadChunk(worldName, new ChunkLoc(x, z), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (!(boolean) methodAreNeighborsLoaded.of(c).call(1)) {
|
||||
// return false;
|
||||
// }
|
||||
/*
|
||||
if (!(boolean) methodAreNeighborsLoaded.of(c).call(1)) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
methodInitLighting.of(c).call();
|
||||
this.methodInitLighting.of(c).call();
|
||||
|
||||
if ((bc.getTotalRelight() == 0 && !fixAll)) {
|
||||
if (bc.getTotalRelight() == 0 && !fixAll) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Object[] sections = (Object[]) fieldSections.of(c).get();
|
||||
final Object w = fieldWorld.of(c).get();
|
||||
Object[] sections = (Object[]) this.fieldSections.of(c).get();
|
||||
Object w = this.fieldWorld.of(c).get();
|
||||
|
||||
final int X = chunk.getX() << 4;
|
||||
final int Z = chunk.getZ() << 4;
|
||||
int X = chunk.getX() << 4;
|
||||
int Z = chunk.getZ() << 4;
|
||||
|
||||
RefExecutor relight = methodX.of(w);
|
||||
RefExecutor relight = this.methodX.of(w);
|
||||
for (int j = 0; j < sections.length; j++) {
|
||||
final Object section = sections[j];
|
||||
Object section = sections[j];
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
if ((bc.getRelight(j) == 0 && !fixAll) || bc.getCount(j) == 0 || (bc.getCount(j) >= 4096 && bc.getAir(j) == 0)) {
|
||||
continue;
|
||||
}
|
||||
final char[] array = getIdArray(section);
|
||||
char[] array = getIdArray(section);
|
||||
int l = PseudoRandom.random.random(2);
|
||||
for (int k = 0; k < array.length; k++) {
|
||||
final int i = array[k];
|
||||
int i = array[k];
|
||||
if (i < 16) {
|
||||
continue;
|
||||
}
|
||||
final short id = (short) (i >> 4);
|
||||
short id = (short) (i >> 4);
|
||||
switch (id) { // Lighting
|
||||
default:
|
||||
if (!fixAll) {
|
||||
@ -341,19 +346,19 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
case 130:
|
||||
case 138:
|
||||
case 169:
|
||||
final int x = MainUtil.x_loc[j][k];
|
||||
final int y = MainUtil.y_loc[j][k];
|
||||
final int z = MainUtil.z_loc[j][k];
|
||||
int x = MainUtil.x_loc[j][k];
|
||||
int y = MainUtil.y_loc[j][k];
|
||||
int z = MainUtil.z_loc[j][k];
|
||||
if (isSurrounded(sections, x, y, z)) {
|
||||
continue;
|
||||
}
|
||||
final Object pos = classBlockPositionConstructor.create(X + x, y, Z + z);
|
||||
Object pos = this.classBlockPositionConstructor.create(X + x, y, Z + z);
|
||||
relight.call(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (final Throwable e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
@ -389,17 +394,16 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overridden by any specialized queues
|
||||
* This should be overridden by any specialized queues.
|
||||
* @param world
|
||||
* @param locs
|
||||
* @param locations
|
||||
*/
|
||||
@Override
|
||||
public void sendChunk(String world, Collection<ChunkLoc> locs) {
|
||||
World worldObj = BukkitUtil.getWorld(world);
|
||||
for (ChunkLoc loc : locs) {
|
||||
public void sendChunk(String world, Collection<ChunkLoc> locations) {
|
||||
for (ChunkLoc loc : locations) {
|
||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||
toUpdate.remove(wrapper);
|
||||
this.toUpdate.remove(wrapper);
|
||||
}
|
||||
chunksender.sendChunk(world, locs);
|
||||
this.chunksender.sendChunk(world, locations);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import java.util.Set;
|
||||
public class FastQueue_1_9 extends SlowQueue {
|
||||
|
||||
private final Object air;
|
||||
private final SendChunk chunksender;
|
||||
private final SendChunk chunkSender;
|
||||
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||
private final RefMethod methodGetHandleChunk;
|
||||
private final RefMethod methodInitLighting;
|
||||
@ -55,36 +55,36 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
|
||||
public FastQueue_1_9() throws RuntimeException {
|
||||
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||
methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||
RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
methodInitLighting = classChunk.getMethod("initLighting");
|
||||
this.methodInitLighting = classChunk.getMethod("initLighting");
|
||||
RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
|
||||
classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||
this.classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||
RefClass classWorld = getRefClass("{nms}.World");
|
||||
methodW = classWorld.getMethod("w", classBlockPosition.getRealClass());
|
||||
fieldSections = classChunk.getField("sections");
|
||||
fieldWorld = classChunk.getField("world");
|
||||
this.methodW = classWorld.getMethod("w", classBlockPosition.getRealClass());
|
||||
this.fieldSections = classChunk.getField("sections");
|
||||
this.fieldWorld = classChunk.getField("world");
|
||||
RefClass classBlock = getRefClass("{nms}.Block");
|
||||
RefClass classIBlockData = getRefClass("{nms}.IBlockData");
|
||||
methodGetCombinedId = classBlock.getMethod("getCombinedId", classIBlockData.getRealClass());
|
||||
methodGetByCombinedId = classBlock.getMethod("getByCombinedId", int.class);
|
||||
this.methodGetCombinedId = classBlock.getMethod("getCombinedId", classIBlockData.getRealClass());
|
||||
this.methodGetByCombinedId = classBlock.getMethod("getByCombinedId", int.class);
|
||||
RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
|
||||
methodGetBlocks = classChunkSection.getMethod("getBlocks");
|
||||
methodGetType = classChunkSection.getMethod("getType", int.class, int.class, int.class);
|
||||
methodSetType = classChunkSection.getMethod("setType", int.class, int.class, int.class, classIBlockData.getRealClass());
|
||||
methodAreNeighborsLoaded = classChunk.getMethod("areNeighborsLoaded", int.class);
|
||||
classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
||||
air = methodGetByCombinedId.call(0);
|
||||
chunksender = new SendChunk();
|
||||
this.methodGetBlocks = classChunkSection.getMethod("getBlocks");
|
||||
this.methodGetType = classChunkSection.getMethod("getType", int.class, int.class, int.class);
|
||||
this.methodSetType = classChunkSection.getMethod("setType", int.class, int.class, int.class, classIBlockData.getRealClass());
|
||||
this.methodAreNeighborsLoaded = classChunk.getMethod("areNeighborsLoaded", int.class);
|
||||
this.classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
||||
this.air = this.methodGetByCombinedId.call(0);
|
||||
this.chunkSender = new SendChunk();
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (toUpdate.isEmpty()) {
|
||||
if (FastQueue_1_9.this.toUpdate.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
int count = 0;
|
||||
final ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
final Iterator<Entry<ChunkWrapper, Chunk>> i = toUpdate.entrySet().iterator();
|
||||
ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
Iterator<Entry<ChunkWrapper, Chunk>> i = FastQueue_1_9.this.toUpdate.entrySet().iterator();
|
||||
while (i.hasNext() && count < 128) {
|
||||
chunks.add(i.next().getValue());
|
||||
i.remove();
|
||||
@ -99,12 +99,12 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
MainUtil.initCache();
|
||||
}
|
||||
|
||||
public void update(final Collection<Chunk> chunks) {
|
||||
public void update(Collection<Chunk> chunks) {
|
||||
if (chunks.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!MainUtil.canSendChunk) {
|
||||
for (final Chunk chunk : chunks) {
|
||||
for (Chunk chunk : chunks) {
|
||||
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
|
||||
chunk.unload(true, true);
|
||||
chunk.load();
|
||||
@ -112,8 +112,8 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
chunksender.sendChunk(chunks);
|
||||
} catch (final Throwable e) {
|
||||
this.chunkSender.sendChunk(chunks);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.canSendChunk = false;
|
||||
}
|
||||
@ -121,60 +121,60 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
|
||||
/**
|
||||
* This should be overridden by any specialized queues
|
||||
* @param pc
|
||||
* @param plotChunk
|
||||
*/
|
||||
@Override
|
||||
public void execute(PlotChunk<Chunk> pc) {
|
||||
FastChunk_1_9 fs = (FastChunk_1_9) pc;
|
||||
Chunk chunk = pc.getChunk();
|
||||
final World world = chunk.getWorld();
|
||||
ChunkWrapper wrapper = pc.getChunkWrapper();
|
||||
if (!toUpdate.containsKey(wrapper)) {
|
||||
toUpdate.put(wrapper, chunk);
|
||||
public void execute(PlotChunk<Chunk> plotChunk) {
|
||||
FastChunk_1_9 fs = (FastChunk_1_9) plotChunk;
|
||||
Chunk chunk = plotChunk.getChunk();
|
||||
World world = chunk.getWorld();
|
||||
ChunkWrapper wrapper = plotChunk.getChunkWrapper();
|
||||
if (!this.toUpdate.containsKey(wrapper)) {
|
||||
this.toUpdate.put(wrapper, chunk);
|
||||
}
|
||||
chunk.load(true);
|
||||
try {
|
||||
final boolean flag = world.getEnvironment() == Environment.NORMAL;
|
||||
boolean flag = world.getEnvironment() == Environment.NORMAL;
|
||||
|
||||
// Sections
|
||||
final Method getHandele = chunk.getClass().getDeclaredMethod("getHandle");
|
||||
final Object c = getHandele.invoke(chunk);
|
||||
final Class<? extends Object> clazz = c.getClass();
|
||||
final Field sf = clazz.getDeclaredField("sections");
|
||||
Method getHandle = chunk.getClass().getDeclaredMethod("getHandle");
|
||||
Object c = getHandle.invoke(chunk);
|
||||
Class<? extends Object> clazz = c.getClass();
|
||||
Field sf = clazz.getDeclaredField("sections");
|
||||
sf.setAccessible(true);
|
||||
final Field tf = clazz.getDeclaredField("tileEntities");
|
||||
final Field entitySlices = clazz.getDeclaredField("entitySlices");
|
||||
Field tf = clazz.getDeclaredField("tileEntities");
|
||||
Field entitySlices = clazz.getDeclaredField("entitySlices");
|
||||
|
||||
final Object[] sections = (Object[]) sf.get(c);
|
||||
final HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c);
|
||||
final Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
|
||||
Object[] sections = (Object[]) sf.get(c);
|
||||
HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c);
|
||||
Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
|
||||
|
||||
Method xm = null;
|
||||
Method ym = null;
|
||||
Method zm = null;
|
||||
// Trim tiles
|
||||
final Set<Entry<?, ?>> entryset = (Set<Entry<?, ?>>) (Set<?>) tiles.entrySet();
|
||||
final Iterator<Entry<?, ?>> iter = entryset.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final Entry<?, ?> tile = iter.next();
|
||||
final Object pos = tile.getKey();
|
||||
Set<Entry<?, ?>> entrySet = (Set<Entry<?, ?>>) (Set<?>) tiles.entrySet();
|
||||
Iterator<Entry<?, ?>> iterator = entrySet.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entry<?, ?> tile = iterator.next();
|
||||
Object pos = tile.getKey();
|
||||
if (xm == null) {
|
||||
final Class<? extends Object> clazz2 = pos.getClass().getSuperclass();
|
||||
Class<? extends Object> clazz2 = pos.getClass().getSuperclass();
|
||||
xm = clazz2.getDeclaredMethod("getX");
|
||||
ym = clazz2.getDeclaredMethod("getY");
|
||||
zm = clazz2.getDeclaredMethod("getZ");
|
||||
}
|
||||
final int lx = (int) xm.invoke(pos) & 15;
|
||||
final int ly = (int) ym.invoke(pos);
|
||||
final int lz = (int) zm.invoke(pos) & 15;
|
||||
final int j = MainUtil.CACHE_I[ly][lx][lz];
|
||||
final int k = MainUtil.CACHE_J[ly][lx][lz];
|
||||
final int[] array = fs.getIdArray(j);
|
||||
int lx = (int) xm.invoke(pos) & 15;
|
||||
int ly = (int) ym.invoke(pos);
|
||||
int lz = (int) zm.invoke(pos) & 15;
|
||||
int j = MainUtil.CACHE_I[ly][lx][lz];
|
||||
int k = MainUtil.CACHE_J[ly][lx][lz];
|
||||
int[] array = fs.getIdArray(j);
|
||||
if (array == null) {
|
||||
continue;
|
||||
}
|
||||
if (array[k] != 0) {
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
if (fs.getCount(j) == 0) {
|
||||
continue;
|
||||
}
|
||||
final int[] newArray = fs.getIdArray(j);
|
||||
int[] newArray = fs.getIdArray(j);
|
||||
if (newArray == null) {
|
||||
continue;
|
||||
}
|
||||
@ -206,11 +206,11 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
section = sections[j] = newChunkSection(j << 4, flag, array);
|
||||
continue;
|
||||
}
|
||||
final Object currentArray = getBlocks(section);
|
||||
RefExecutor setType = methodSetType.of(section);
|
||||
Object currentArray = getBlocks(section);
|
||||
RefExecutor setType = this.methodSetType.of(section);
|
||||
boolean fill = true;
|
||||
for (int k = 0; k < newArray.length; k++) {
|
||||
final int n = newArray[k];
|
||||
int n = newArray[k];
|
||||
switch (n) {
|
||||
case 0:
|
||||
fill = false;
|
||||
@ -220,15 +220,15 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
int x = MainUtil.x_loc[j][k];
|
||||
int y = MainUtil.y_loc[j][k];
|
||||
int z = MainUtil.z_loc[j][k];
|
||||
setType.call(x, y & 15, z, air);
|
||||
setType.call(x, y & 15, z, this.air);
|
||||
continue;
|
||||
}
|
||||
default: {
|
||||
int x = MainUtil.x_loc[j][k];
|
||||
int y = MainUtil.y_loc[j][k];
|
||||
int z = MainUtil.z_loc[j][k];
|
||||
Object iblock = methodGetByCombinedId.call((int) n);
|
||||
setType.call(x, y & 15, z, iblock);
|
||||
Object iBlock = this.methodGetByCombinedId.call((int) n);
|
||||
setType.call(x, y & 15, z, iBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -260,12 +260,12 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
}
|
||||
}
|
||||
|
||||
public Object newChunkSection(final int i, final boolean flag, final char[] ids) {
|
||||
return classChunkSectionConstructor.create(i, flag, ids);
|
||||
public Object newChunkSection(int i, boolean flag, char[] ids) {
|
||||
return this.classChunkSectionConstructor.create(i, flag, ids);
|
||||
}
|
||||
|
||||
public Object getBlocks(final Object obj) {
|
||||
return methodGetBlocks.of(obj).call();
|
||||
public Object getBlocks(Object obj) {
|
||||
return this.methodGetBlocks.of(obj).call();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -285,7 +285,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
public boolean fixLighting(PlotChunk<Chunk> pc, boolean fixAll) {
|
||||
try {
|
||||
FastChunk_1_9 bc = (FastChunk_1_9) pc;
|
||||
final Chunk chunk = bc.getChunk();
|
||||
Chunk chunk = bc.getChunk();
|
||||
if (!chunk.isLoaded()) {
|
||||
chunk.load(false);
|
||||
} else {
|
||||
@ -294,9 +294,9 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
}
|
||||
|
||||
// Initialize lighting
|
||||
final Object c = methodGetHandleChunk.of(chunk).call();
|
||||
Object c = this.methodGetHandleChunk.of(chunk).call();
|
||||
|
||||
if (fixAll && !(boolean) methodAreNeighborsLoaded.of(c).call(1)) {
|
||||
if (fixAll && !(boolean) this.methodAreNeighborsLoaded.of(c).call(1)) {
|
||||
World world = chunk.getWorld();
|
||||
ChunkWrapper wrapper = bc.getChunkWrapper();
|
||||
String worldname = wrapper.world;
|
||||
@ -313,36 +313,36 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
}
|
||||
}
|
||||
|
||||
methodInitLighting.of(c).call();
|
||||
this.methodInitLighting.of(c).call();
|
||||
|
||||
if (bc.getTotalRelight() == 0 && !fixAll) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Object[] sections = (Object[]) fieldSections.of(c).get();
|
||||
final Object w = fieldWorld.of(c).get();
|
||||
Object[] sections = (Object[]) this.fieldSections.of(c).get();
|
||||
Object w = this.fieldWorld.of(c).get();
|
||||
|
||||
final int X = chunk.getX() << 4;
|
||||
final int Z = chunk.getZ() << 4;
|
||||
int X = chunk.getX() << 4;
|
||||
int Z = chunk.getZ() << 4;
|
||||
|
||||
RefExecutor relight = methodW.of(w);
|
||||
RefExecutor relight = this.methodW.of(w);
|
||||
for (int j = 0; j < sections.length; j++) {
|
||||
final Object section = sections[j];
|
||||
Object section = sections[j];
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
if (bc.getRelight(j) == 0 && !fixAll || bc.getCount(j) == 0 || bc.getCount(j) >= 4096 && bc.getAir(j) == 0) {
|
||||
continue;
|
||||
}
|
||||
final int[] array = bc.getIdArray(j);
|
||||
int[] array = bc.getIdArray(j);
|
||||
if (array != null) {
|
||||
int l = PseudoRandom.random.random(2);
|
||||
for (int k = 0; k < array.length; k++) {
|
||||
final int i = array[k];
|
||||
int i = array[k];
|
||||
if (i < 16) {
|
||||
continue;
|
||||
}
|
||||
final short id = (short) (i >> 4);
|
||||
short id = (short) (i >> 4);
|
||||
switch (id) { // Lighting
|
||||
default:
|
||||
if (!fixAll) {
|
||||
@ -367,20 +367,20 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
case 130:
|
||||
case 138:
|
||||
case 169:
|
||||
final int x = MainUtil.x_loc[j][k];
|
||||
final int y = MainUtil.y_loc[j][k];
|
||||
final int z = MainUtil.z_loc[j][k];
|
||||
int x = MainUtil.x_loc[j][k];
|
||||
int y = MainUtil.y_loc[j][k];
|
||||
int z = MainUtil.z_loc[j][k];
|
||||
if (isSurrounded(bc.getIdArrays(), x, y, z)) {
|
||||
continue;
|
||||
}
|
||||
final Object pos = classBlockPositionConstructor.create(X + x, y, Z + z);
|
||||
Object pos = this.classBlockPositionConstructor.create(X + x, y, Z + z);
|
||||
relight.call(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (final Throwable e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
@ -397,7 +397,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
public boolean isSolid(int i) {
|
||||
if (i != 0) {
|
||||
Material material = Material.getMaterial(i);
|
||||
return material != null && Material.getMaterial(i).isOccluding();
|
||||
return material != null && Material.getMaterial(i).isOccluding();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -420,8 +420,8 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
|
||||
public int getId(Object section, int x, int y, int z) {
|
||||
int j = MainUtil.CACHE_J[y][x][z];
|
||||
Object iblock = methodGetType.of(section).call(x, y & 15, z);
|
||||
return (int) methodGetCombinedId.call(iblock);
|
||||
Object iBlock = this.methodGetType.of(section).call(x, y & 15, z);
|
||||
return (int) this.methodGetCombinedId.call(iBlock);
|
||||
}
|
||||
|
||||
public int getId(Object[] sections, int x, int y, int z) {
|
||||
@ -436,26 +436,26 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
if (section == null) {
|
||||
return 0;
|
||||
}
|
||||
// Object array = getBlocks(section);
|
||||
// Object array = getBlocks(section);
|
||||
return getId(section, x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overridden by any specialized queues
|
||||
* @param world
|
||||
* @param locs
|
||||
* @param locations
|
||||
*/
|
||||
@Override
|
||||
public void sendChunk(final String world, final Collection<ChunkLoc> locs) {
|
||||
public void sendChunk(final String world, final Collection<ChunkLoc> locations) {
|
||||
World worldObj = BukkitUtil.getWorld(world);
|
||||
for (ChunkLoc loc : locs) {
|
||||
for (ChunkLoc loc : locations) {
|
||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||
toUpdate.remove(wrapper);
|
||||
this.toUpdate.remove(wrapper);
|
||||
}
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chunksender.sendChunk(world, locs);
|
||||
FastQueue_1_9.this.chunkSender.sendChunk(world, locations);
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
|
@ -33,40 +33,40 @@ public class GenChunk extends PlotChunk<Chunk> {
|
||||
@Override
|
||||
public Chunk getChunkAbs() {
|
||||
ChunkWrapper wrap = getChunkWrapper();
|
||||
if (chunk == null || wrap.x != chunk.getX() || wrap.z != chunk.getZ()) {
|
||||
chunk = BukkitUtil.getWorld(wrap.world).getChunkAt(wrap.x, wrap.z);
|
||||
if (this.chunk == null || wrap.x != this.chunk.getX() || wrap.z != this.chunk.getZ()) {
|
||||
this.chunk = BukkitUtil.getWorld(wrap.world).getChunkAt(wrap.x, wrap.z);
|
||||
}
|
||||
return chunk;
|
||||
return this.chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, int biome) {
|
||||
grid.setBiome(x, z, biomes[biome]);
|
||||
this.grid.setBiome(x, z, this.biomes[biome]);
|
||||
}
|
||||
|
||||
public void setBiome(int x, int z, Biome biome) {
|
||||
if (grid != null) {
|
||||
grid.setBiome(x, z, biome);
|
||||
if (this.grid != null) {
|
||||
this.grid.setBiome(x, z, biome);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, int id, byte data) {
|
||||
if (result == null) {
|
||||
cd.setBlock(x, y, z, id, data);
|
||||
if (this.result == null) {
|
||||
this.cd.setBlock(x, y, z, id, data);
|
||||
return;
|
||||
}
|
||||
int i = MainUtil.CACHE_I[y][x][z];
|
||||
short[] v = result[i];
|
||||
short[] v = this.result[i];
|
||||
if (v == null) {
|
||||
result[i] = v = new short[4096];
|
||||
this.result[i] = v = new short[4096];
|
||||
}
|
||||
int j = MainUtil.CACHE_J[y][x][z];
|
||||
v[j] = (short) id;
|
||||
if (data != 0) {
|
||||
byte[] vd = result_data[i];
|
||||
byte[] vd = this.result_data[i];
|
||||
if (vd == null) {
|
||||
result_data[i] = vd = new byte[4096];
|
||||
this.result_data[i] = vd = new byte[4096];
|
||||
}
|
||||
vd[j] = data;
|
||||
}
|
||||
@ -75,32 +75,32 @@ public class GenChunk extends PlotChunk<Chunk> {
|
||||
@Override
|
||||
public PlotChunk clone() {
|
||||
GenChunk toReturn = new GenChunk(getChunkAbs(), getChunkWrapper());
|
||||
if (result != null) {
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
short[] matrix = result[i];
|
||||
if (this.result != null) {
|
||||
for (int i = 0; i < this.result.length; i++) {
|
||||
short[] matrix = this.result[i];
|
||||
if (matrix != null) {
|
||||
toReturn.result[i] = new short[matrix.length];
|
||||
System.arraycopy(matrix, 0, toReturn.result[i], 0, matrix.length);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < result_data.length; i++) {
|
||||
byte[] matrix = result_data[i];
|
||||
for (int i = 0; i < this.result_data.length; i++) {
|
||||
byte[] matrix = this.result_data[i];
|
||||
if (matrix != null) {
|
||||
toReturn.result_data[i] = new byte[matrix.length];
|
||||
System.arraycopy(matrix, 0, toReturn.result_data[i], 0, matrix.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
toReturn.cd = cd;
|
||||
toReturn.cd = this.cd;
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotChunk shallowClone() {
|
||||
GenChunk toReturn = new GenChunk(getChunkAbs(), getChunkWrapper());
|
||||
toReturn.result = result;
|
||||
toReturn.result_data = result_data;
|
||||
toReturn.cd = cd;
|
||||
toReturn.result = this.result;
|
||||
toReturn.result_data = this.result_data;
|
||||
toReturn.cd = this.cd;
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ public class SlowChunk extends PlotChunk<Chunk> {
|
||||
|
||||
public PlotBlock[][] result = new PlotBlock[16][];
|
||||
public int[][] biomes;
|
||||
|
||||
public SlowChunk(ChunkWrapper chunk) {
|
||||
super(chunk);
|
||||
}
|
||||
@ -23,25 +24,25 @@ public class SlowChunk extends PlotChunk<Chunk> {
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, int biome) {
|
||||
if (biomes == null) {
|
||||
biomes = new int[16][16];
|
||||
if (this.biomes == null) {
|
||||
this.biomes = new int[16][16];
|
||||
}
|
||||
biomes[x][z] = biome;
|
||||
this.biomes[x][z] = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, int id, byte data) {
|
||||
if (result[y >> 4] == null) {
|
||||
result[y >> 4] = new PlotBlock[4096];
|
||||
if (this.result[y >> 4] == null) {
|
||||
this.result[y >> 4] = new PlotBlock[4096];
|
||||
}
|
||||
result[MainUtil.CACHE_I[y][x][z]][MainUtil.CACHE_J[y][x][z]] = new PlotBlock((short) id, data);
|
||||
this.result[MainUtil.CACHE_I[y][x][z]][MainUtil.CACHE_J[y][x][z]] = new PlotBlock((short) id, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotChunk clone() {
|
||||
SlowChunk toReturn = new SlowChunk(getChunkWrapper());
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
PlotBlock[] matrix = result[i];
|
||||
for (int i = 0; i < this.result.length; i++) {
|
||||
PlotBlock[] matrix = this.result[i];
|
||||
if (matrix != null) {
|
||||
toReturn.result[i] = new PlotBlock[matrix.length];
|
||||
System.arraycopy(matrix, 0, toReturn.result[i], 0, matrix.length);
|
||||
@ -53,7 +54,7 @@ public class SlowChunk extends PlotChunk<Chunk> {
|
||||
@Override
|
||||
public PlotChunk shallowClone() {
|
||||
SlowChunk toReturn = new SlowChunk(getChunkWrapper());
|
||||
toReturn.result = result;
|
||||
toReturn.result = this.result;
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
@ -30,18 +30,18 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
||||
if (y > 255 || y < 0) {
|
||||
return false;
|
||||
}
|
||||
final ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(world, x >> 4, z >> 4);
|
||||
ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(world, x >> 4, z >> 4);
|
||||
x = x & 15;
|
||||
z = z & 15;
|
||||
PlotChunk<Chunk> result = blocks.get(wrap);
|
||||
PlotChunk<Chunk> result = this.blocks.get(wrap);
|
||||
if (result == null) {
|
||||
result = getChunk(wrap);
|
||||
result.setBlock(x, y, z, id, data);
|
||||
final PlotChunk<Chunk> previous = blocks.put(wrap, result);
|
||||
PlotChunk<Chunk> previous = this.blocks.put(wrap, result);
|
||||
if (previous == null) {
|
||||
return true;
|
||||
}
|
||||
blocks.put(wrap, previous);
|
||||
this.blocks.put(wrap, previous);
|
||||
result = previous;
|
||||
}
|
||||
result.setBlock(x, y, z, id, data);
|
||||
@ -50,7 +50,7 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
||||
|
||||
@Override
|
||||
public void setChunk(PlotChunk<Chunk> chunk) {
|
||||
blocks.put(chunk.getChunkWrapper(), chunk);
|
||||
this.blocks.put(chunk.getChunkWrapper(), chunk);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,11 +59,11 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
||||
throw new IllegalStateException("Must be called from main thread!");
|
||||
}
|
||||
try {
|
||||
if (blocks.isEmpty()) {
|
||||
if (this.blocks.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
final Iterator<Entry<ChunkWrapper, PlotChunk<Chunk>>> iter = blocks.entrySet().iterator();
|
||||
final PlotChunk<Chunk> toReturn = iter.next().getValue();
|
||||
Iterator<Entry<ChunkWrapper, PlotChunk<Chunk>>> iter = this.blocks.entrySet().iterator();
|
||||
PlotChunk<Chunk> toReturn = iter.next().getValue();
|
||||
if (SetQueue.IMP.isWaiting()) {
|
||||
return null;
|
||||
}
|
||||
@ -71,7 +71,7 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
||||
execute(toReturn);
|
||||
fixLighting(toReturn, true);
|
||||
return toReturn;
|
||||
} catch (final Throwable e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
@ -83,17 +83,17 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
||||
throw new IllegalStateException("Must be called from main thread!");
|
||||
}
|
||||
try {
|
||||
if (blocks.isEmpty()) {
|
||||
if (this.blocks.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
final PlotChunk<Chunk> toReturn = blocks.remove(wrap);
|
||||
PlotChunk<Chunk> toReturn = this.blocks.remove(wrap);
|
||||
if (toReturn == null) {
|
||||
return null;
|
||||
}
|
||||
execute(toReturn);
|
||||
fixLighting(toReturn, fixLighting);
|
||||
return toReturn;
|
||||
} catch (final Throwable e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
@ -101,16 +101,16 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
blocks.clear();
|
||||
this.blocks.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overriden by any specialized queues
|
||||
* @param pc
|
||||
* This should be overridden by any specialized queues.
|
||||
* @param plotChunk
|
||||
*/
|
||||
public void execute(PlotChunk<Chunk> pc) {
|
||||
SlowChunk sc = (SlowChunk) pc;
|
||||
Chunk chunk = pc.getChunk();
|
||||
public void execute(PlotChunk<Chunk> plotChunk) {
|
||||
SlowChunk sc = (SlowChunk) plotChunk;
|
||||
Chunk chunk = plotChunk.getChunk();
|
||||
chunk.load(true);
|
||||
for (int i = 0; i < sc.result.length; i++) {
|
||||
PlotBlock[] result2 = sc.result[i];
|
||||
@ -118,9 +118,9 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < 4096; j++) {
|
||||
final int x = MainUtil.x_loc[i][j];
|
||||
final int y = MainUtil.y_loc[i][j];
|
||||
final int z = MainUtil.z_loc[i][j];
|
||||
int x = MainUtil.x_loc[i][j];
|
||||
int y = MainUtil.y_loc[i][j];
|
||||
int z = MainUtil.z_loc[i][j];
|
||||
Block block = chunk.getBlock(x, y, z);
|
||||
PlotBlock newBlock = result2[j];
|
||||
if (newBlock == null) {
|
||||
@ -252,7 +252,7 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overriden by any specialized queues
|
||||
* This should be overridden by any specialized queues.
|
||||
* @param wrap
|
||||
*/
|
||||
@Override
|
||||
@ -261,7 +261,7 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overriden by any specialized queues
|
||||
* This should be overridden by any specialized queues.
|
||||
* @param fixAll
|
||||
*/
|
||||
@Override
|
||||
@ -271,11 +271,11 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be overriden by any specialized queues
|
||||
* @param locs
|
||||
* This should be overridden by any specialized queues.
|
||||
* @param locations
|
||||
*/
|
||||
@Override
|
||||
public void sendChunk(String world, Collection<ChunkLoc> locs) {
|
||||
public void sendChunk(String world, Collection<ChunkLoc> locations) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user