Fix my stupid mistake of using lamdas not creating nested classes when creating schematics. "this" doesn't work like that. Cheers Java.

This commit is contained in:
dordsor21 2020-06-27 20:38:55 +01:00
parent 9c3d2cfb02
commit 02f3c3ef50
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -130,8 +130,7 @@ public abstract class SchematicHandler {
name = name =
plot.getId().x + ";" + plot.getId().y + ',' + plot.getArea() + ',' + owner; plot.getId().x + ";" + plot.getId().y + ',' + plot.getArea() + ',' + owner;
} else { } else {
name = namingScheme name = namingScheme.replaceAll("%id%", plot.getId().toString())
.replaceAll("%id%", plot.getId().toString())
.replaceAll("%idx%", plot.getId().x + "") .replaceAll("%idx%", plot.getId().x + "")
.replaceAll("%idy%", plot.getId().y + "") .replaceAll("%idy%", plot.getId().y + "")
.replaceAll("%world%", plot.getArea().toString()); .replaceAll("%world%", plot.getArea().toString());
@ -566,100 +565,114 @@ public abstract class SchematicHandler {
final int p2z = pos2.getZ(); final int p2z = pos2.getZ();
final int ey = pos2.getY(); final int ey = pos2.getY();
Iterator<Integer> yiter = IntStream.range(sy, ey + 1).iterator(); Iterator<Integer> yiter = IntStream.range(sy, ey + 1).iterator();
final Runnable yTask = () -> { final Runnable yTask = new Runnable() {
long ystart = System.currentTimeMillis(); @Override public void run() {
while (yiter.hasNext() && System.currentTimeMillis() - ystart < 20) { long ystart = System.currentTimeMillis();
final int y = yiter.next(); while (yiter.hasNext() && System.currentTimeMillis() - ystart < 20) {
Iterator<Integer> ziter = IntStream.range(p1z, p2z + 1).iterator(); final int y = yiter.next();
final Runnable zTask = () -> { Iterator<Integer> ziter = IntStream.range(p1z, p2z + 1).iterator();
long zstart = System.currentTimeMillis(); final Runnable zTask = new Runnable() {
while (ziter.hasNext() @Override public void run() {
&& System.currentTimeMillis() - zstart < 20) { long zstart = System.currentTimeMillis();
final int z = ziter.next(); while (ziter.hasNext()
Iterator<Integer> xiter = && System.currentTimeMillis() - zstart < 20) {
IntStream.range(p1x, p2x + 1).iterator(); final int z = ziter.next();
final Runnable xTask = () -> { Iterator<Integer> xiter =
long xstart = System.currentTimeMillis(); IntStream.range(p1x, p2x + 1).iterator();
final int ry = y - sy; final Runnable xTask = new Runnable() {
final int rz = z - p1z; @Override public void run() {
while (xiter.hasNext() long xstart = System.currentTimeMillis();
&& System.currentTimeMillis() - xstart < 20) { final int ry = y - sy;
final int x = xiter.next(); final int rz = z - p1z;
final int rx = x - p1x; while (xiter.hasNext()
BlockVector3 point = BlockVector3.at(x, y, z); && System.currentTimeMillis() - xstart
BaseBlock block = < 20) {
cuboidRegion.getWorld().getFullBlock(point); final int x = xiter.next();
if (block.getNbtData() != null) { final int rx = x - p1x;
Map<String, Tag> values = new HashMap<>(); BlockVector3 point =
for (Map.Entry<String, Tag> entry : block BlockVector3.at(x, y, z);
.getNbtData().getValue().entrySet()) { BaseBlock block = cuboidRegion.getWorld()
values.put(entry.getKey(), entry.getValue()); .getFullBlock(point);
if (block.getNbtData() != null) {
Map<String, Tag> values =
new HashMap<>();
for (Map.Entry<String, Tag> entry : block
.getNbtData().getValue()
.entrySet()) {
values.put(entry.getKey(),
entry.getValue());
}
// Remove 'id' if it exists. We want 'Id'
values.remove("id");
// Positions are kept in NBT, we don't want that.
values.remove("x");
values.remove("y");
values.remove("z");
values.put("Id",
new StringTag(block.getNbtId()));
values.put("Pos", new IntArrayTag(
new int[] {rx, ry, rz}));
tileEntities
.add(new CompoundTag(values));
}
String blockKey =
block.toImmutableState().getAsString();
int blockId;
if (palette.containsKey(blockKey)) {
blockId = palette.get(blockKey);
} else {
blockId = palette.size();
palette.put(blockKey, palette.size());
}
while ((blockId & -128) != 0) {
buffer.write(blockId & 127 | 128);
blockId >>>= 7;
}
buffer.write(blockId);
if (ry > 0) {
continue;
}
BlockVector2 pt = BlockVector2.at(x, z);
BiomeType biome =
cuboidRegion.getWorld().getBiome(pt);
String biomeStr = biome.getId();
int biomeId;
if (biomePalette.containsKey(biomeStr)) {
biomeId = biomePalette.get(biomeStr);
} else {
biomeId = biomePalette.size();
biomePalette.put(biomeStr, biomeId);
}
while ((biomeId & -128) != 0) {
biomeBuffer.write(biomeId & 127 | 128);
biomeId >>>= 7;
}
biomeBuffer.write(biomeId);
}
if (xiter.hasNext()) {
this.run();
}
} }
// Remove 'id' if it exists. We want 'Id' };
values.remove("id"); xTask.run();
// Positions are kept in NBT, we don't want that.
values.remove("x");
values.remove("y");
values.remove("z");
values.put("Id", new StringTag(block.getNbtId()));
values.put("Pos",
new IntArrayTag(new int[] {rx, ry, rz}));
tileEntities.add(new CompoundTag(values));
}
String blockKey =
block.toImmutableState().getAsString();
int blockId;
if (palette.containsKey(blockKey)) {
blockId = palette.get(blockKey);
} else {
blockId = palette.size();
palette.put(blockKey, palette.size());
}
while ((blockId & -128) != 0) {
buffer.write(blockId & 127 | 128);
blockId >>>= 7;
}
buffer.write(blockId);
if (ry > 0) {
continue;
}
BlockVector2 pt = BlockVector2.at(x, z);
BiomeType biome = cuboidRegion.getWorld().getBiome(pt);
String biomeStr = biome.getId();
int biomeId;
if (biomePalette.containsKey(biomeStr)) {
biomeId = biomePalette.get(biomeStr);
} else {
biomeId = biomePalette.size();
biomePalette.put(biomeStr, biomeId);
}
while ((biomeId & -128) != 0) {
biomeBuffer.write(biomeId & 127 | 128);
biomeId >>>= 7;
}
biomeBuffer.write(biomeId);
} }
if (xiter.hasNext()) { if (ziter.hasNext()) {
this.run(); this.run();
} }
}; }
xTask.run(); };
} zTask.run();
if (ziter.hasNext()) { }
this.run(); if (yiter.hasNext()) {
} TaskManager.runTaskLater(this, 1);
}; } else {
zTask.run(); regionTask.run();
} }
if (yiter.hasNext()) {
TaskManager.runTaskLater(this, 1);
} else {
regionTask.run();
} }
}; };
yTask.run(); yTask.run();