Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-26 02:50:06 +01:00
some anvil fixes
Dieser Commit ist enthalten in:
Ursprung
0ef97ccf28
Commit
c519c5ec38
@ -308,18 +308,6 @@ public class AnvilCommands {
|
|||||||
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
|
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = {"debugfixair", },
|
|
||||||
desc = "debug - do not use"
|
|
||||||
)
|
|
||||||
@CommandPermissions("worldedit.anvil.debugfixair")
|
|
||||||
public void debugfixair(Player player, String folder) throws WorldEditException {
|
|
||||||
DebugFixAir filter = new DebugFixAir();
|
|
||||||
DebugFixAir result = runWithWorld(player, folder, filter, true, true);
|
|
||||||
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"debugfixroads", },
|
aliases = {"debugfixroads", },
|
||||||
desc = "debug - do not use"
|
desc = "debug - do not use"
|
||||||
|
@ -32,8 +32,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
// modified: boolean
|
// modified: boolean
|
||||||
// deleted: boolean
|
// deleted: boolean
|
||||||
|
|
||||||
public byte[][] ids;
|
public int[][] ids;
|
||||||
public byte[][] data;
|
|
||||||
public byte[][] skyLight;
|
public byte[][] skyLight;
|
||||||
public byte[][] blockLight;
|
public byte[][] blockLight;
|
||||||
public byte[] biomes;
|
public byte[] biomes;
|
||||||
@ -48,8 +47,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
|
|
||||||
public MCAChunk(FaweQueue queue, int x, int z) {
|
public MCAChunk(FaweQueue queue, int x, int z) {
|
||||||
super(queue, x, z);
|
super(queue, x, z);
|
||||||
this.ids = new byte[16][];
|
this.ids = new int[16][];
|
||||||
this.data = new byte[16][];
|
|
||||||
this.skyLight = new byte[16][];
|
this.skyLight = new byte[16][];
|
||||||
this.blockLight = new byte[16][];
|
this.blockLight = new byte[16][];
|
||||||
this.biomes = new byte[256];
|
this.biomes = new byte[256];
|
||||||
@ -64,7 +62,6 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
super(parent.getParent(), parent.getX(), parent.getZ());
|
super(parent.getParent(), parent.getX(), parent.getZ());
|
||||||
if (shallow) {
|
if (shallow) {
|
||||||
this.ids = parent.ids;
|
this.ids = parent.ids;
|
||||||
this.data = parent.data;
|
|
||||||
this.skyLight = parent.skyLight;
|
this.skyLight = parent.skyLight;
|
||||||
this.blockLight = parent.blockLight;
|
this.blockLight = parent.blockLight;
|
||||||
this.biomes = parent.biomes;
|
this.biomes = parent.biomes;
|
||||||
@ -76,8 +73,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
this.modified = parent.modified;
|
this.modified = parent.modified;
|
||||||
this.deleted = parent.deleted;
|
this.deleted = parent.deleted;
|
||||||
} else {
|
} else {
|
||||||
this.ids = (byte[][]) MainUtil.copyNd(parent.ids);
|
this.ids = (int[][]) MainUtil.copyNd(parent.ids);
|
||||||
this.data = (byte[][]) MainUtil.copyNd(parent.data);
|
|
||||||
this.skyLight = (byte[][]) MainUtil.copyNd(parent.skyLight);
|
this.skyLight = (byte[][]) MainUtil.copyNd(parent.skyLight);
|
||||||
this.blockLight = (byte[][]) MainUtil.copyNd(parent.blockLight);
|
this.blockLight = (byte[][]) MainUtil.copyNd(parent.blockLight);
|
||||||
this.biomes = parent.biomes.clone();
|
this.biomes = parent.biomes.clone();
|
||||||
@ -124,7 +120,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
}
|
}
|
||||||
nbtOut.getOutputStream().writeInt(len);
|
nbtOut.getOutputStream().writeInt(len);
|
||||||
for (int layer = 0; layer < ids.length; layer++) {
|
for (int layer = 0; layer < ids.length; layer++) {
|
||||||
byte[] idLayer = ids[layer];
|
int[] idLayer = ids[layer];
|
||||||
if (idLayer == null) {
|
if (idLayer == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -132,7 +128,6 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
out.writeNamedTag("BlockLight", blockLight[layer]);
|
out.writeNamedTag("BlockLight", blockLight[layer]);
|
||||||
out.writeNamedTag("SkyLight", skyLight[layer]);
|
out.writeNamedTag("SkyLight", skyLight[layer]);
|
||||||
out.writeNamedTag("Blocks", idLayer);
|
out.writeNamedTag("Blocks", idLayer);
|
||||||
out.writeNamedTag("Data", data[layer]);
|
|
||||||
out.writeEndTag();
|
out.writeEndTag();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -180,50 +175,43 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
for (int otherY = minY, thisY = minY + offsetY; otherY <= maxY; otherY++, thisY++) {
|
for (int otherY = minY, thisY = minY + offsetY; otherY <= maxY; otherY++, thisY++) {
|
||||||
int thisLayer = thisY >> 4;
|
int thisLayer = thisY >> 4;
|
||||||
int otherLayer = otherY >> 4;
|
int otherLayer = otherY >> 4;
|
||||||
byte[] thisIds = ids[thisLayer];
|
int[] thisIds = ids[thisLayer];
|
||||||
byte[] otherIds = other.ids[otherLayer];
|
int[] otherIds = other.ids[otherLayer];
|
||||||
if (otherIds == null) {
|
if (otherIds == null) {
|
||||||
if (thisIds != null) {
|
if (thisIds != null) {
|
||||||
int indexY = (thisY & 15) << 8;
|
int indexY = (thisY & 15) << 8;
|
||||||
byte[] thisData = data[thisLayer];
|
|
||||||
byte[] thisSkyLight = skyLight[thisLayer];
|
byte[] thisSkyLight = skyLight[thisLayer];
|
||||||
byte[] thisBlockLight = blockLight[thisLayer];
|
byte[] thisBlockLight = blockLight[thisLayer];
|
||||||
for (int otherZ = minZ, thisZ = minZ + offsetZ; otherZ <= maxZ; otherZ++, thisZ++) {
|
for (int otherZ = minZ, thisZ = minZ + offsetZ; otherZ <= maxZ; otherZ++, thisZ++) {
|
||||||
int startIndex = indexY + (thisZ << 4) + minX + offsetX;
|
int startIndex = indexY + (thisZ << 4) + minX + offsetX;
|
||||||
int endIndex = startIndex + maxX - minX;
|
int endIndex = startIndex + maxX - minX;
|
||||||
ArrayUtil.fill(thisIds, startIndex, endIndex + 1, (byte) 0);
|
Arrays.fill(thisIds, startIndex, endIndex + 1, 0);
|
||||||
int startIndexShift = startIndex >> 1;
|
int startIndexShift = startIndex >> 1;
|
||||||
int endIndexShift = endIndex >> 1;
|
int endIndexShift = endIndex >> 1;
|
||||||
if ((startIndex & 1) != 0) {
|
if ((startIndex & 1) != 0) {
|
||||||
startIndexShift++;
|
startIndexShift++;
|
||||||
setNibble(startIndex, thisData, (byte) 0);
|
|
||||||
setNibble(startIndex, thisSkyLight, (byte) 0);
|
setNibble(startIndex, thisSkyLight, (byte) 0);
|
||||||
setNibble(startIndex, thisBlockLight, (byte) 0);
|
setNibble(startIndex, thisBlockLight, (byte) 0);
|
||||||
}
|
}
|
||||||
if ((endIndex & 1) != 1) {
|
if ((endIndex & 1) != 1) {
|
||||||
endIndexShift--;
|
endIndexShift--;
|
||||||
setNibble(endIndex, thisData, (byte) 0);
|
|
||||||
setNibble(endIndex, thisSkyLight, (byte) 0);
|
setNibble(endIndex, thisSkyLight, (byte) 0);
|
||||||
setNibble(endIndex, thisBlockLight, (byte) 0);
|
setNibble(endIndex, thisBlockLight, (byte) 0);
|
||||||
}
|
}
|
||||||
ArrayUtil.fill(thisData, startIndexShift, endIndexShift + 1, (byte) 0);
|
|
||||||
ArrayUtil.fill(thisSkyLight, startIndexShift, endIndexShift + 1, (byte) 0);
|
ArrayUtil.fill(thisSkyLight, startIndexShift, endIndexShift + 1, (byte) 0);
|
||||||
ArrayUtil.fill(thisBlockLight, startIndexShift, endIndexShift + 1, (byte) 0);
|
ArrayUtil.fill(thisBlockLight, startIndexShift, endIndexShift + 1, (byte) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
} else if (thisIds == null) {
|
} else if (thisIds == null) {
|
||||||
ids[thisLayer] = thisIds = new byte[4096];
|
ids[thisLayer] = thisIds = new int[4096];
|
||||||
data[thisLayer] = new byte[2048];
|
|
||||||
skyLight[thisLayer] = new byte[2048];
|
skyLight[thisLayer] = new byte[2048];
|
||||||
blockLight[thisLayer] = new byte[2048];
|
blockLight[thisLayer] = new byte[2048];
|
||||||
}
|
}
|
||||||
int indexY = (thisY & 15) << 8;
|
int indexY = (thisY & 15) << 8;
|
||||||
int otherIndexY = (otherY & 15) << 8;
|
int otherIndexY = (otherY & 15) << 8;
|
||||||
byte[] thisData = data[thisLayer];
|
|
||||||
byte[] thisSkyLight = skyLight[thisLayer];
|
byte[] thisSkyLight = skyLight[thisLayer];
|
||||||
byte[] thisBlockLight = blockLight[thisLayer];
|
byte[] thisBlockLight = blockLight[thisLayer];
|
||||||
byte[] otherData = other.data[otherLayer];
|
|
||||||
byte[] otherSkyLight = other.skyLight[otherLayer];
|
byte[] otherSkyLight = other.skyLight[otherLayer];
|
||||||
byte[] otherBlockLight = other.blockLight[otherLayer];
|
byte[] otherBlockLight = other.blockLight[otherLayer];
|
||||||
for (int otherZ = minZ, thisZ = minZ + offsetZ; otherZ <= maxZ; otherZ++, thisZ++) {
|
for (int otherZ = minZ, thisZ = minZ + offsetZ; otherZ <= maxZ; otherZ++, thisZ++) {
|
||||||
@ -240,23 +228,19 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
if ((startIndex & 1) != 0) {
|
if ((startIndex & 1) != 0) {
|
||||||
startIndexShift++;
|
startIndexShift++;
|
||||||
otherStartIndexShift++;
|
otherStartIndexShift++;
|
||||||
setNibble(startIndex, thisData, getNibble(otherStartIndex, otherData));
|
|
||||||
setNibble(startIndex, thisSkyLight, getNibble(otherStartIndex, otherSkyLight));
|
setNibble(startIndex, thisSkyLight, getNibble(otherStartIndex, otherSkyLight));
|
||||||
setNibble(startIndex, thisBlockLight, getNibble(otherStartIndex, otherBlockLight));
|
setNibble(startIndex, thisBlockLight, getNibble(otherStartIndex, otherBlockLight));
|
||||||
}
|
}
|
||||||
if ((endIndex & 1) != 1) {
|
if ((endIndex & 1) != 1) {
|
||||||
endIndexShift--;
|
endIndexShift--;
|
||||||
otherEndIndexShift--;
|
otherEndIndexShift--;
|
||||||
setNibble(endIndex, thisData, getNibble(otherEndIndex, otherData));
|
|
||||||
setNibble(endIndex, thisSkyLight, getNibble(otherEndIndex, otherSkyLight));
|
setNibble(endIndex, thisSkyLight, getNibble(otherEndIndex, otherSkyLight));
|
||||||
setNibble(endIndex, thisBlockLight, getNibble(otherEndIndex, otherBlockLight));
|
setNibble(endIndex, thisBlockLight, getNibble(otherEndIndex, otherBlockLight));
|
||||||
}
|
}
|
||||||
System.arraycopy(otherData, otherStartIndexShift, thisData, startIndexShift, endIndexShift - startIndexShift + 1);
|
|
||||||
System.arraycopy(otherSkyLight, otherStartIndexShift, thisSkyLight, startIndexShift, endIndexShift - startIndexShift + 1);
|
System.arraycopy(otherSkyLight, otherStartIndexShift, thisSkyLight, startIndexShift, endIndexShift - startIndexShift + 1);
|
||||||
System.arraycopy(otherBlockLight, otherStartIndexShift, thisBlockLight, startIndexShift, endIndexShift - startIndexShift + 1);
|
System.arraycopy(otherBlockLight, otherStartIndexShift, thisBlockLight, startIndexShift, endIndexShift - startIndexShift + 1);
|
||||||
} else {
|
} else {
|
||||||
for (int thisIndex = startIndex, otherIndex = otherStartIndex; thisIndex <= endIndex; thisIndex++, otherIndex++) {
|
for (int thisIndex = startIndex, otherIndex = otherStartIndex; thisIndex <= endIndex; thisIndex++, otherIndex++) {
|
||||||
setNibble(thisIndex, thisData, getNibble(otherIndex, otherData));
|
|
||||||
setNibble(thisIndex, thisSkyLight, getNibble(otherIndex, otherSkyLight));
|
setNibble(thisIndex, thisSkyLight, getNibble(otherIndex, otherSkyLight));
|
||||||
setNibble(thisIndex, thisBlockLight, getNibble(otherIndex, otherBlockLight));
|
setNibble(thisIndex, thisBlockLight, getNibble(otherIndex, otherBlockLight));
|
||||||
}
|
}
|
||||||
@ -295,14 +279,13 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
int startLayer = minY >> 4;
|
int startLayer = minY >> 4;
|
||||||
int endLayer = maxY >> 4;
|
int endLayer = maxY >> 4;
|
||||||
for (int thisLayer = startLayer + offsetLayer, otherLayer = startLayer; thisLayer <= endLayer; thisLayer++, otherLayer++) {
|
for (int thisLayer = startLayer + offsetLayer, otherLayer = startLayer; thisLayer <= endLayer; thisLayer++, otherLayer++) {
|
||||||
byte[] otherIds = other.ids[otherLayer];
|
int[] otherIds = other.ids[otherLayer];
|
||||||
byte[] currentIds = ids[thisLayer];
|
int[] currentIds = ids[thisLayer];
|
||||||
int by = otherLayer << 4;
|
int by = otherLayer << 4;
|
||||||
int ty = by + 15;
|
int ty = by + 15;
|
||||||
if (by >= minY && ty <= maxY) {
|
if (by >= minY && ty <= maxY) {
|
||||||
if (otherIds != null) {
|
if (otherIds != null) {
|
||||||
ids[thisLayer] = otherIds;
|
ids[thisLayer] = otherIds;
|
||||||
data[thisLayer] = other.data[otherLayer];
|
|
||||||
skyLight[thisLayer] = other.skyLight[otherLayer];
|
skyLight[thisLayer] = other.skyLight[otherLayer];
|
||||||
blockLight[thisLayer] = other.blockLight[otherLayer];
|
blockLight[thisLayer] = other.blockLight[otherLayer];
|
||||||
} else {
|
} else {
|
||||||
@ -317,20 +300,17 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
int indexEndShift = indexEnd >> 1;
|
int indexEndShift = indexEnd >> 1;
|
||||||
if (otherIds == null) {
|
if (otherIds == null) {
|
||||||
if (currentIds != null) {
|
if (currentIds != null) {
|
||||||
ArrayUtil.fill(currentIds, indexStart, indexEnd, (byte) 0);
|
Arrays.fill(currentIds, indexStart, indexEnd, 0);
|
||||||
ArrayUtil.fill(data[thisLayer], indexStartShift, indexEndShift, (byte) 0);
|
|
||||||
ArrayUtil.fill(skyLight[thisLayer], indexStartShift, indexEndShift, (byte) 0);
|
ArrayUtil.fill(skyLight[thisLayer], indexStartShift, indexEndShift, (byte) 0);
|
||||||
ArrayUtil.fill(blockLight[thisLayer], indexStartShift, indexEndShift, (byte) 0);
|
ArrayUtil.fill(blockLight[thisLayer], indexStartShift, indexEndShift, (byte) 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (currentIds == null) {
|
if (currentIds == null) {
|
||||||
currentIds = this.ids[thisLayer] = new byte[4096];
|
currentIds = this.ids[thisLayer] = new int[4096];
|
||||||
this.data[thisLayer] = new byte[2048];
|
|
||||||
this.skyLight[thisLayer] = new byte[2048];
|
this.skyLight[thisLayer] = new byte[2048];
|
||||||
this.blockLight[thisLayer] = new byte[2048];
|
this.blockLight[thisLayer] = new byte[2048];
|
||||||
}
|
}
|
||||||
System.arraycopy(other.ids[otherLayer], indexStart, currentIds, indexStart, indexEnd - indexStart);
|
System.arraycopy(other.ids[otherLayer], indexStart, currentIds, indexStart, indexEnd - indexStart);
|
||||||
System.arraycopy(other.data[otherLayer], indexStartShift, data[thisLayer], indexStartShift, indexEndShift - indexStartShift);
|
|
||||||
System.arraycopy(other.skyLight[otherLayer], indexStartShift, skyLight[thisLayer], indexStartShift, indexEndShift - indexStartShift);
|
System.arraycopy(other.skyLight[otherLayer], indexStartShift, skyLight[thisLayer], indexStartShift, indexEndShift - indexStartShift);
|
||||||
System.arraycopy(other.blockLight[otherLayer], indexStartShift, blockLight[thisLayer], indexStartShift, indexEndShift - indexStartShift);
|
System.arraycopy(other.blockLight[otherLayer], indexStartShift, blockLight[thisLayer], indexStartShift, indexEndShift - indexStartShift);
|
||||||
}
|
}
|
||||||
@ -340,29 +320,26 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
for (int otherY = minY, thisY = minY + offsetY; otherY <= maxY; otherY++, thisY++) {
|
for (int otherY = minY, thisY = minY + offsetY; otherY <= maxY; otherY++, thisY++) {
|
||||||
int otherLayer = otherY >> 4;
|
int otherLayer = otherY >> 4;
|
||||||
int thisLayer = thisY >> 4;
|
int thisLayer = thisY >> 4;
|
||||||
byte[] thisIds = this.ids[thisLayer];
|
int[] thisIds = this.ids[thisLayer];
|
||||||
byte[] otherIds = other.ids[otherLayer];
|
int[] otherIds = other.ids[otherLayer];
|
||||||
int thisStartIndex = (thisY & 15) << 8;
|
int thisStartIndex = (thisY & 15) << 8;
|
||||||
int thisStartIndexShift = thisStartIndex >> 1;
|
int thisStartIndexShift = thisStartIndex >> 1;
|
||||||
if (otherIds == null) {
|
if (otherIds == null) {
|
||||||
if (thisIds == null) {
|
if (thisIds == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ArrayUtil.fill(thisIds, thisStartIndex, thisStartIndex + 256, (byte) 0);
|
Arrays.fill(thisIds, thisStartIndex, thisStartIndex + 256, 0);
|
||||||
ArrayUtil.fill(this.data[thisLayer], thisStartIndexShift, thisStartIndexShift + 128, (byte) 0);
|
|
||||||
ArrayUtil.fill(this.skyLight[thisLayer], thisStartIndexShift, thisStartIndexShift + 128, (byte) 0);
|
ArrayUtil.fill(this.skyLight[thisLayer], thisStartIndexShift, thisStartIndexShift + 128, (byte) 0);
|
||||||
ArrayUtil.fill(this.blockLight[thisLayer], thisStartIndexShift, thisStartIndexShift + 128, (byte) 0);
|
ArrayUtil.fill(this.blockLight[thisLayer], thisStartIndexShift, thisStartIndexShift + 128, (byte) 0);
|
||||||
continue;
|
continue;
|
||||||
} else if (thisIds == null) {
|
} else if (thisIds == null) {
|
||||||
ids[thisLayer] = thisIds = new byte[4096];
|
ids[thisLayer] = thisIds = new int[4096];
|
||||||
data[thisLayer] = new byte[2048];
|
|
||||||
skyLight[thisLayer] = new byte[2048];
|
skyLight[thisLayer] = new byte[2048];
|
||||||
blockLight[thisLayer] = new byte[2048];
|
blockLight[thisLayer] = new byte[2048];
|
||||||
}
|
}
|
||||||
int otherStartIndex = (otherY & 15) << 8;
|
int otherStartIndex = (otherY & 15) << 8;
|
||||||
int otherStartIndexShift = otherStartIndex >> 1;
|
int otherStartIndexShift = otherStartIndex >> 1;
|
||||||
System.arraycopy(other.ids[otherLayer], otherStartIndex, thisIds, thisStartIndex, 256);
|
System.arraycopy(other.ids[otherLayer], otherStartIndex, thisIds, thisStartIndex, 256);
|
||||||
System.arraycopy(other.data[otherLayer], otherStartIndexShift, data[thisLayer], thisStartIndexShift, 128);
|
|
||||||
System.arraycopy(other.skyLight[otherLayer], otherStartIndexShift, skyLight[thisLayer], thisStartIndexShift, 128);
|
System.arraycopy(other.skyLight[otherLayer], otherStartIndexShift, skyLight[thisLayer], thisStartIndexShift, 128);
|
||||||
System.arraycopy(other.blockLight[otherLayer], otherStartIndexShift, blockLight[thisLayer], thisStartIndexShift, 128);
|
System.arraycopy(other.blockLight[otherLayer], otherStartIndexShift, blockLight[thisLayer], thisStartIndexShift, 128);
|
||||||
}
|
}
|
||||||
@ -438,7 +415,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
level.put("HeightMap", heightMap);
|
level.put("HeightMap", heightMap);
|
||||||
ArrayList<HashMap<String, Object>> sections = new ArrayList<>();
|
ArrayList<HashMap<String, Object>> sections = new ArrayList<>();
|
||||||
for (int layer = 0; layer < ids.length; layer++) {
|
for (int layer = 0; layer < ids.length; layer++) {
|
||||||
byte[] idLayer = ids[layer];
|
int[] idLayer = ids[layer];
|
||||||
if (idLayer == null) {
|
if (idLayer == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -447,7 +424,6 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
map.put("BlockLight", blockLight[layer]);
|
map.put("BlockLight", blockLight[layer]);
|
||||||
map.put("SkyLight", skyLight[layer]);
|
map.put("SkyLight", skyLight[layer]);
|
||||||
map.put("Blocks", idLayer);
|
map.put("Blocks", idLayer);
|
||||||
map.put("Data", data[layer]);
|
|
||||||
sections.add(map);
|
sections.add(map);
|
||||||
}
|
}
|
||||||
level.put("Sections", sections);
|
level.put("Sections", sections);
|
||||||
@ -458,8 +434,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
|
|
||||||
public MCAChunk(NBTInputStream nis, FaweQueue parent, int x, int z, boolean readPos) throws IOException {
|
public MCAChunk(NBTInputStream nis, FaweQueue parent, int x, int z, boolean readPos) throws IOException {
|
||||||
super(parent, x, z);
|
super(parent, x, z);
|
||||||
ids = new byte[16][];
|
ids = new int[16][];
|
||||||
data = new byte[16][];
|
|
||||||
skyLight = new byte[16][];
|
skyLight = new byte[16][];
|
||||||
blockLight = new byte[16][];
|
blockLight = new byte[16][];
|
||||||
NBTStreamer streamer = new NBTStreamer(nis);
|
NBTStreamer streamer = new NBTStreamer(nis);
|
||||||
@ -469,8 +444,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
(BiConsumer<Integer, Long>) (index, value) -> lastUpdate = value);
|
(BiConsumer<Integer, Long>) (index, value) -> lastUpdate = value);
|
||||||
streamer.addReader(".Level.Sections.#", (BiConsumer<Integer, CompoundTag>) (index, tag) -> {
|
streamer.addReader(".Level.Sections.#", (BiConsumer<Integer, CompoundTag>) (index, tag) -> {
|
||||||
int layer = tag.getByte("Y");
|
int layer = tag.getByte("Y");
|
||||||
ids[layer] = tag.getByteArray("Blocks");
|
ids[layer] = tag.getIntArray("Blocks");
|
||||||
data[layer] = tag.getByteArray("Data");
|
|
||||||
skyLight[layer] = tag.getByteArray("SkyLight");
|
skyLight[layer] = tag.getByteArray("SkyLight");
|
||||||
blockLight[layer] = tag.getByteArray("BlockLight");
|
blockLight[layer] = tag.getByteArray("BlockLight");
|
||||||
});
|
});
|
||||||
@ -783,7 +757,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
entities.remove(uuid);
|
entities.remove(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final boolean idsEqual(byte[] a, byte[] b) {
|
private final boolean idsEqual(int[] a, int[] b) {
|
||||||
// Assumes both are null, or none are (idsEqual - 2d array)
|
// Assumes both are null, or none are (idsEqual - 2d array)
|
||||||
// Assumes length is 4096
|
// Assumes length is 4096
|
||||||
if (a == b) return true;
|
if (a == b) return true;
|
||||||
@ -793,17 +767,17 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final boolean idsEqual(byte[][] a, byte[][] b, boolean matchNullToAir) {
|
private final boolean idsEqual(int[][] a, int[][] b, boolean matchNullToAir) {
|
||||||
// Assumes length is 16
|
// Assumes length is 16
|
||||||
for (byte i = 0; i < 16; i++) {
|
for (byte i = 0; i < 16; i++) {
|
||||||
if ((a[i] == null) != (b[i] == null)) {
|
if ((a[i] == null) != (b[i] == null)) {
|
||||||
if (matchNullToAir) {
|
if (matchNullToAir) {
|
||||||
if (b[i] != null) {
|
if (b[i] != null) {
|
||||||
for (byte c : b[i]) {
|
for (int c : b[i]) {
|
||||||
if (c != 0) return false;
|
if (c != 0) return false;
|
||||||
}
|
}
|
||||||
} else if (a[i] != null) {
|
} else if (a[i] != null) {
|
||||||
for (byte c : a[i]) {
|
for (int c : a[i]) {
|
||||||
if (c != 0) return false;
|
if (c != 0) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,7 @@ import javax.annotation.Nullable;
|
|||||||
public class MutableMCABackedBaseBlock extends BaseBlock {
|
public class MutableMCABackedBaseBlock extends BaseBlock {
|
||||||
|
|
||||||
private MCAChunk chunk;
|
private MCAChunk chunk;
|
||||||
private byte[] data;
|
private int[] ids;
|
||||||
private byte[] ids;
|
|
||||||
private int index;
|
private int index;
|
||||||
private int x;
|
private int x;
|
||||||
private int y;
|
private int y;
|
||||||
@ -29,7 +28,6 @@ public class MutableMCABackedBaseBlock extends BaseBlock {
|
|||||||
|
|
||||||
public void setArrays(int layer) {
|
public void setArrays(int layer) {
|
||||||
ids = chunk.ids[layer];
|
ids = chunk.ids[layer];
|
||||||
data = chunk.data[layer];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MCAChunk getChunk() {
|
public MCAChunk getChunk() {
|
||||||
@ -79,11 +77,7 @@ public class MutableMCABackedBaseBlock extends BaseBlock {
|
|||||||
return chunk.getTile(x, y, z);
|
return chunk.getTile(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void setId(int id) {
|
|
||||||
// ids[index] = (byte) id;
|
|
||||||
// chunk.setModified();
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
// @Override
|
// @Override
|
||||||
// public void setData(int value) {
|
// public void setData(int value) {
|
||||||
|
@ -29,10 +29,10 @@ public class CountIdFilter extends MCAFilterCounter {
|
|||||||
public MCAChunk applyChunk(MCAChunk chunk, MutableLong count) {
|
public MCAChunk applyChunk(MCAChunk chunk, MutableLong count) {
|
||||||
// TODO FIXME
|
// TODO FIXME
|
||||||
for (int layer = 0; layer < chunk.ids.length; layer++) {
|
for (int layer = 0; layer < chunk.ids.length; layer++) {
|
||||||
byte[] ids = chunk.ids[layer];
|
int[] ids = chunk.ids[layer];
|
||||||
if (ids != null) {
|
if (ids != null) {
|
||||||
for (byte i : ids) {
|
for (int i : ids) {
|
||||||
if (allowedId[i & 0xFF]) {
|
if (allowedId[BlockTypes.getFromStateId(i).getInternalId()]) {
|
||||||
count.increment();
|
count.increment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,85 +0,0 @@
|
|||||||
package com.boydti.fawe.jnbt.anvil.filters;
|
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
|
||||||
import com.boydti.fawe.jnbt.anvil.MCAChunk;
|
|
||||||
import com.boydti.fawe.jnbt.anvil.MCAFile;
|
|
||||||
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
|
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
|
||||||
import com.boydti.fawe.object.number.MutableLong;
|
|
||||||
|
|
||||||
// TODO FIXME
|
|
||||||
public class DebugFixAir extends MCAFilterCounter {
|
|
||||||
@Override
|
|
||||||
public MCAChunk applyChunk(MCAChunk chunk, MutableLong cache) {
|
|
||||||
none:
|
|
||||||
{
|
|
||||||
some:
|
|
||||||
{
|
|
||||||
for (int layer = 0; layer < chunk.ids.length; layer++) {
|
|
||||||
byte[] idLayer = chunk.ids[layer];
|
|
||||||
if (idLayer == null) continue;
|
|
||||||
for (int i = 0; i < 4096; i++) {
|
|
||||||
if (idLayer[i] != 0) {
|
|
||||||
if (layer != 0) break some;
|
|
||||||
break none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{ // Possibly dead code depending on the generator
|
|
||||||
chunk.ids[layer] = null;
|
|
||||||
chunk.data[layer] = null;
|
|
||||||
chunk.setModified();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cache.add(Character.MAX_VALUE);
|
|
||||||
chunk.setDeleted(true);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
if (chunk.ids[i] == null) return null;
|
|
||||||
}
|
|
||||||
// // layer 0
|
|
||||||
// boolean modified = false;
|
|
||||||
// byte[] ids0 = chunk.ids[0];
|
|
||||||
// for (int i = 0; i < 256; i++) {
|
|
||||||
// if (ids0[i] == 0) {
|
|
||||||
// if (!modified) {
|
|
||||||
// modified = true;
|
|
||||||
// }
|
|
||||||
// for (int layer = 0; layer < 4; layer++) {
|
|
||||||
// byte[] arr = chunk.ids[layer];
|
|
||||||
// for (int y = i; y < 4096; y += 256) {
|
|
||||||
// arr[y] = BlockTypes.DIRT;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// ids0[i] = BlockTypes.BEDROCK;
|
|
||||||
// if (chunk.ids[4][i] == 0) chunk.ids[4][i] = BlockTypes.GRASS;
|
|
||||||
// cache.add(256);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (modified) {
|
|
||||||
// Arrays.fill(chunk.skyLight[4], (byte) 255);
|
|
||||||
// chunk.setModified();
|
|
||||||
// }
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void finishFile(MCAFile file, MutableLong cache) {
|
|
||||||
Fawe.debug(" - apply " + file.getFile());
|
|
||||||
boolean[] deleteFile = { true };
|
|
||||||
file.forEachCachedChunk(new RunnableVal<MCAChunk>() {
|
|
||||||
@Override
|
|
||||||
public void run(MCAChunk value) {
|
|
||||||
if (!value.isDeleted()) {
|
|
||||||
deleteFile[0] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (deleteFile[0]) {
|
|
||||||
file.setDeleted(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -167,10 +167,10 @@ public class PlotTrimFilter extends DeleteUninhabitedFilter {
|
|||||||
}
|
}
|
||||||
if (referenceIsVoid) {
|
if (referenceIsVoid) {
|
||||||
for (int i = 0; i < chunk.ids.length; i++) {
|
for (int i = 0; i < chunk.ids.length; i++) {
|
||||||
byte[] arr = chunk.ids[i];
|
int[] arr = chunk.ids[i];
|
||||||
if (arr != null) {
|
if (arr != null) {
|
||||||
for (byte b : arr) {
|
for (int b : arr) {
|
||||||
if (b != 0) return;
|
if (!BlockTypes.getFromStateId(b).getMaterial().isAir()) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,9 @@ import com.boydti.fawe.jnbt.anvil.MCAChunk;
|
|||||||
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
|
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
|
||||||
import com.boydti.fawe.object.number.MutableLong;
|
import com.boydti.fawe.object.number.MutableLong;
|
||||||
import com.boydti.fawe.util.ArrayUtil;
|
import com.boydti.fawe.util.ArrayUtil;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class RemoveLayerFilter extends MCAFilterCounter {
|
public class RemoveLayerFilter extends MCAFilterCounter {
|
||||||
private final int startLayer;
|
private final int startLayer;
|
||||||
@ -23,7 +26,7 @@ public class RemoveLayerFilter extends MCAFilterCounter {
|
|||||||
@Override
|
@Override
|
||||||
public MCAChunk applyChunk(MCAChunk chunk, MutableLong cache) {
|
public MCAChunk applyChunk(MCAChunk chunk, MutableLong cache) {
|
||||||
for (int layer = startLayer; layer <= endLayer; layer++) {
|
for (int layer = startLayer; layer <= endLayer; layer++) {
|
||||||
byte[] ids = chunk.ids[layer];
|
int[] ids = chunk.ids[layer];
|
||||||
if (ids == null) {
|
if (ids == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -41,7 +44,7 @@ public class RemoveLayerFilter extends MCAFilterCounter {
|
|||||||
for (int y = startY; y <= endY; y++) {
|
for (int y = startY; y <= endY; y++) {
|
||||||
int indexStart = y << 8;
|
int indexStart = y << 8;
|
||||||
int indexEnd = indexStart + 255;
|
int indexEnd = indexStart + 255;
|
||||||
ArrayUtil.fill(ids, indexStart, indexEnd + 1, (byte) 0);
|
Arrays.fill(ids, indexStart, indexEnd + 1, BlockTypes.AIR.getInternalId());
|
||||||
}
|
}
|
||||||
chunk.setModified();
|
chunk.setModified();
|
||||||
}
|
}
|
||||||
|
@ -5,21 +5,21 @@ import com.boydti.fawe.jnbt.anvil.MCAFile;
|
|||||||
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
|
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.boydti.fawe.object.number.MutableLong;
|
import com.boydti.fawe.object.number.MutableLong;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
public class TrimAirFilter extends MCAFilterCounter {
|
public class TrimAirFilter extends MCAFilterCounter {
|
||||||
@Override
|
@Override
|
||||||
public MCAChunk applyChunk(MCAChunk chunk, MutableLong cache) {
|
public MCAChunk applyChunk(MCAChunk chunk, MutableLong cache) {
|
||||||
for (int layer = 0; layer < chunk.ids.length; layer++) {
|
for (int layer = 0; layer < chunk.ids.length; layer++) {
|
||||||
byte[] idLayer = chunk.ids[layer];
|
int[] idLayer = chunk.ids[layer];
|
||||||
if (idLayer == null) continue;
|
if (idLayer == null) continue;
|
||||||
for (int i = 0; i < 4096; i++) {
|
for (int i = 0; i < 4096; i++) {
|
||||||
if (idLayer[i] != 0) {
|
if (!BlockTypes.getFromStateId(idLayer[i]).getMaterial().isAir()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{ // Possibly dead code depending on the generator
|
{ // Possibly dead code depending on the generator
|
||||||
chunk.ids[layer] = null;
|
chunk.ids[layer] = null;
|
||||||
chunk.data[layer] = null;
|
|
||||||
chunk.setModified();
|
chunk.setModified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,12 +283,11 @@ public class SchemVis extends ImmutableVirtualWorld {
|
|||||||
*/
|
*/
|
||||||
private void select(MCAChunk chunk) {
|
private void select(MCAChunk chunk) {
|
||||||
for (int layer = 0; layer < 16; layer++) {
|
for (int layer = 0; layer < 16; layer++) {
|
||||||
byte[] ids = chunk.ids[layer];
|
int[] ids = chunk.ids[layer];
|
||||||
if (ids != null) {
|
if (ids != null) {
|
||||||
for (int i = 0; i < ids.length; i++) {
|
for (int i = 0; i < ids.length; i++) {
|
||||||
// TODO FIXME update to 1.13
|
// TODO FIXME update to 1.13
|
||||||
if (ids[i] != 0) ids[i] = (byte) BlockTypes.WHITE_STAINED_GLASS.getInternalId();
|
if (ids[i] != 0) ids[i] = (byte) BlockTypes.WHITE_STAINED_GLASS.getInternalId();
|
||||||
Arrays.fill(chunk.data[layer], (byte) 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -34,7 +36,7 @@ public class PlotTrim {
|
|||||||
private final MCAQueue originalQueue;
|
private final MCAQueue originalQueue;
|
||||||
private final File root;
|
private final File root;
|
||||||
private final File originalRoot;
|
private final File originalRoot;
|
||||||
private byte[][] ids;
|
private int[][] ids;
|
||||||
private boolean deleteUnowned = true;
|
private boolean deleteUnowned = true;
|
||||||
|
|
||||||
public PlotTrim(PlotPlayer player, PlotArea area, String worldName, boolean deleteUnowned) {
|
public PlotTrim(PlotPlayer player, PlotArea area, String worldName, boolean deleteUnowned) {
|
||||||
@ -49,7 +51,7 @@ public class PlotTrim {
|
|||||||
this.deleteUnowned = deleteUnowned;
|
this.deleteUnowned = deleteUnowned;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChunk(byte[][] ids) {
|
public void setChunk(int[][] ids) {
|
||||||
checkNotNull(ids);
|
checkNotNull(ids);
|
||||||
this.ids = ids;
|
this.ids = ids;
|
||||||
}
|
}
|
||||||
@ -182,7 +184,7 @@ public class PlotTrim {
|
|||||||
|
|
||||||
private int count = 0;
|
private int count = 0;
|
||||||
|
|
||||||
private boolean isEqual(byte[] a, byte[] b) {
|
private boolean isEqual(int[] a, int[] b) {
|
||||||
if (a == b) {
|
if (a == b) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -195,9 +197,9 @@ public class PlotTrim {
|
|||||||
return isEmpty(b);
|
return isEmpty(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isEmpty(byte[] a) {
|
private boolean isEmpty(int[] a) {
|
||||||
for (byte b : a) {
|
for (int b : a) {
|
||||||
if (b != 0) {
|
if (!BlockTypes.getFromStateId(b).getMaterial().isAir()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren