Optimizations to schematic loading / pasting -> ~10,000,000 bps

The downside is it completely ignores entities and such, so WorldEdit is
the way to go if you need precision but don't care for large sizes or
speed.
This commit is contained in:
boy0001
2015-07-23 02:33:22 +10:00
parent 5ec4c244d2
commit d09dbee3c7
9 changed files with 296 additions and 174 deletions

View File

@ -83,7 +83,7 @@ public class HybridPlotManager extends ClassicPlotManager {
Location bot = getPlotBottomLocAbs(hpw, id2);
Location top = getPlotTopLocAbs(hpw, id);
Location pos1 = new Location(plot.world, top.getX() + 1, 0, bot.getZ());
Location pos2 = new Location(plot.world, bot.getX(), 256, top.getZ() + 1);
Location pos2 = new Location(plot.world, bot.getX(), 255, top.getZ() + 1);
createSchemAbs(hpw, pos1, pos2, hpw.ROAD_HEIGHT, true);
return true;
}
@ -139,7 +139,7 @@ public class HybridPlotManager extends ClassicPlotManager {
Location bot = getPlotBottomLocAbs(hpw, id2);
Location top = getPlotTopLocAbs(hpw, id);
Location pos1 = new Location(plot.world, bot.getX(), 0, top.getZ() + 1);
Location pos2 = new Location(plot.world, top.getX() + 1, 256, bot.getZ());
Location pos2 = new Location(plot.world, top.getX() + 1, 255, bot.getZ());
createSchemAbs(hpw, pos1, pos2, hpw.ROAD_HEIGHT, true);
return true;
}

View File

@ -89,7 +89,8 @@ public class HybridPlotWorld extends ClassicPlotWorld {
}
if (schem3 != null) {
this.PLOT_SCHEMATIC = true;
final DataCollection[] blocks3 = schem3.getBlockCollection();
byte[] ids = schem3.getIds();
byte[] datas = schem3.getDatas();
final Dimension d3 = schem3.getSchematicDimension();
final short w3 = (short) d3.getX();
final short l3 = (short) d3.getZ();
@ -106,8 +107,8 @@ public class HybridPlotWorld extends ClassicPlotWorld {
for (short z = 0; z < l3; z++) {
for (short y = 0; y < h3; y++) {
final int index = (y * w3 * l3) + (z * w3) + x;
final short id = blocks3[index].getBlock();
final byte data = blocks3[index].getData();
final short id = ids[index];
final byte data = ids[index];
if (id != 0) {
addOverlayBlock((short) (x + shift + oddshift + center_shift_x), (y), (short) (z + shift + oddshift + center_shift_z), id, data, false);
}
@ -139,8 +140,13 @@ public class HybridPlotWorld extends ClassicPlotWorld {
this.ROAD_SCHEMATIC_ENABLED = true;
// Do not populate road if using schematic population
this.ROAD_BLOCK = new PlotBlock(this.ROAD_BLOCK.id, (byte) 0);
final DataCollection[] blocks1 = schem1.getBlockCollection();
final DataCollection[] blocks2 = schem2.getBlockCollection();
byte[] ids1 = schem1.getIds();
byte[] datas1 = schem1.getDatas();
byte[] ids2 = schem2.getIds();
byte[] datas2 = schem2.getDatas();
final Dimension d1 = schem1.getSchematicDimension();
final short w1 = (short) d1.getX();
final short l1 = (short) d1.getZ();
@ -154,8 +160,8 @@ public class HybridPlotWorld extends ClassicPlotWorld {
for (short z = 0; z < l1; z++) {
for (short y = 0; y < h1; y++) {
final int index = (y * w1 * l1) + (z * w1) + x;
final short id = blocks1[index].getBlock();
final byte data = blocks1[index].getData();
final short id = ids1[index];
final byte data = datas1[index];
if (id != 0) {
addOverlayBlock((short) (x - (shift)), (y), (short) (z + shift + oddshift), id, data, false);
addOverlayBlock((short) (z + shift + oddshift), (y), (short) (x - shift), id, data, true);
@ -167,8 +173,8 @@ public class HybridPlotWorld extends ClassicPlotWorld {
for (short z = 0; z < l2; z++) {
for (short y = 0; y < h2; y++) {
final int index = (y * w2 * l2) + (z * w2) + x;
final short id = blocks2[index].getBlock();
final byte data = blocks2[index].getData();
final short id = ids2[index];
final byte data = datas2[index];
if (id != 0) {
addOverlayBlock((short) (x - shift), (y), (short) (z - shift), id, data, false);
}

View File

@ -28,7 +28,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
final int pz = plotid.y;
final int x = dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
final int z = dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
return new Location(plotworld.worldname, x, 256, z);
return new Location(plotworld.worldname, x, 255, z);
}
@Override