Fix unable to locate sign issue.

This commit is contained in:
boy0001 2015-02-26 18:53:37 +11:00
parent 63888827aa
commit 98a4a9889e
3 changed files with 94 additions and 30 deletions

View File

@ -27,11 +27,14 @@ import java.util.HashSet;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.commands.Template;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.FileBytes;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
@ -103,29 +106,6 @@ public class HybridPlotManager extends ClassicPlotManager {
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
if ((pos2.getX() - pos1.getX()) < 48) {
MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), 0, pos1.getZ()), new Location(world, pos2.getX() + 1, 1, pos2.getZ() + 1), new PlotBlock((short) 7, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT + 1, pos1.getZ()), new Location(world, pos2.getX() + 1, maxy + 1, pos2.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, pos1.getX(), 1, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT, pos2.getZ() + 1), filling);
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), plotfloor);
TaskManager.runTask(whenDone);
}
}, 5);
}
}, 5);
}
}, 5);
return;
}
final int startX = (pos1.getX() / 16) * 16;
final int startZ = (pos1.getZ() / 16) * 16;
final int chunkX = 16 + pos2.getX();
@ -166,7 +146,14 @@ public class HybridPlotManager extends ClassicPlotManager {
} else if ((mx.getZ() < (j + 15)) || (mx.getX() < (i + 15))) {
mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ));
}
BukkitUtil.regenerateChunk(world, i / 16, j / 16);
final int I = i;
final int J = j;
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
BukkitUtil.regenerateChunk(world, I / 16, J / 16);
}
}, PseudoRandom.random(40));
}
}
final Location max = mx;

View File

@ -157,11 +157,13 @@ public class MainUtil {
public static void update(final Location loc) {
final String world = loc.getWorld();
int ox = loc.getX() >> 4;
int oz = loc.getX() >> 4;
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
final int distance = BukkitUtil.getViewDistance();
for (int cx = -distance; cx < distance; cx++) {
for (int cz = -distance; cz < distance; cz++) {
final ChunkLoc chunk = new ChunkLoc(cx, cz);
for (int cx = -distance; cx <= distance; cx++) {
for (int cz = -distance; cz <= distance; cz++) {
final ChunkLoc chunk = new ChunkLoc(ox + cx, oz + cz);
chunks.add(chunk);
}
}

View File

@ -28,6 +28,7 @@ import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Block;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
@ -64,6 +65,8 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
methodA = classChunk.getMethod("a", classBlockPosition, classIBlockData);
}
private ChunkLoc lastLoc = null;
/**
* Set the block at the location
*
@ -76,16 +79,28 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
*
* @return true
*/
@SuppressWarnings("deprecation")
@Override
public void set(final World world, final int x, final int y, final int z, final int id, final byte data) {
// Start blockstate workaround //
switch (id) {
case 54:
case 130:
case 146:
case 142:
case 27:
case 137:
case 52:
case 154:
case 84:
case 25:
case 144:
case 138:
case 176:
case 177:
case 63:
case 68:
case 313:
case 323:
case 117:
case 28:
case 66:
case 157:
@ -114,13 +129,73 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
return;
}
}
int currentId = world.getBlockAt(x, y, z).getTypeId();
if (currentId == id) {
return;
}
switch(currentId) {
case 54:
case 130:
case 142:
case 27:
case 137:
case 52:
case 154:
case 84:
case 25:
case 144:
case 138:
case 176:
case 177:
case 63:
case 68:
case 323:
case 117:
case 28:
case 66:
case 157:
case 61:
case 62:
case 158:
case 23:
case 123:
case 124:
case 29:
case 33:
case 151:
case 178: {
final Block block = world.getBlockAt(x, y, z);
if (block.getData() == data) {
if (block.getTypeId() != id) {
block.setTypeId(id, false);
}
} else {
if (block.getTypeId() == id) {
block.setData(data, false);
} else {
block.setTypeIdAndData(id, data, false);
}
}
return;
}
}
// End blockstate workaround //
int X = x >> 4;
int Z = z >> 4;
ChunkLoc loc = new ChunkLoc(X, Z);
if (!loc.equals(lastLoc)) {
world.loadChunk(X, Z, false);
lastLoc = loc;
}
// check sign
final Object w = methodGetHandle.of(world).call();
final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4);
final Object pos = constructorBlockPosition.create(x & 0x0f, y, z & 0x0f);
final Object combined = methodGetByCombinedId.of(null).call(id + (data << 12));
methodA.of(chunk).call(pos, combined);
}
/**
* Update chunks
*