Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 10:30:04 +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()));
|
||||
}
|
||||
|
||||
|
||||
@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(
|
||||
aliases = {"debugfixroads", },
|
||||
desc = "debug - do not use"
|
||||
|
@ -32,8 +32,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
// modified: boolean
|
||||
// deleted: boolean
|
||||
|
||||
public byte[][] ids;
|
||||
public byte[][] data;
|
||||
public int[][] ids;
|
||||
public byte[][] skyLight;
|
||||
public byte[][] blockLight;
|
||||
public byte[] biomes;
|
||||
@ -48,8 +47,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
|
||||
public MCAChunk(FaweQueue queue, int x, int z) {
|
||||
super(queue, x, z);
|
||||
this.ids = new byte[16][];
|
||||
this.data = new byte[16][];
|
||||
this.ids = new int[16][];
|
||||
this.skyLight = new byte[16][];
|
||||
this.blockLight = new byte[16][];
|
||||
this.biomes = new byte[256];
|
||||
@ -64,7 +62,6 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
super(parent.getParent(), parent.getX(), parent.getZ());
|
||||
if (shallow) {
|
||||
this.ids = parent.ids;
|
||||
this.data = parent.data;
|
||||
this.skyLight = parent.skyLight;
|
||||
this.blockLight = parent.blockLight;
|
||||
this.biomes = parent.biomes;
|
||||
@ -76,8 +73,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
this.modified = parent.modified;
|
||||
this.deleted = parent.deleted;
|
||||
} else {
|
||||
this.ids = (byte[][]) MainUtil.copyNd(parent.ids);
|
||||
this.data = (byte[][]) MainUtil.copyNd(parent.data);
|
||||
this.ids = (int[][]) MainUtil.copyNd(parent.ids);
|
||||
this.skyLight = (byte[][]) MainUtil.copyNd(parent.skyLight);
|
||||
this.blockLight = (byte[][]) MainUtil.copyNd(parent.blockLight);
|
||||
this.biomes = parent.biomes.clone();
|
||||
@ -124,7 +120,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
}
|
||||
nbtOut.getOutputStream().writeInt(len);
|
||||
for (int layer = 0; layer < ids.length; layer++) {
|
||||
byte[] idLayer = ids[layer];
|
||||
int[] idLayer = ids[layer];
|
||||
if (idLayer == null) {
|
||||
continue;
|
||||
}
|
||||
@ -132,7 +128,6 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
out.writeNamedTag("BlockLight", blockLight[layer]);
|
||||
out.writeNamedTag("SkyLight", skyLight[layer]);
|
||||
out.writeNamedTag("Blocks", idLayer);
|
||||
out.writeNamedTag("Data", data[layer]);
|
||||
out.writeEndTag();
|
||||
}
|
||||
});
|
||||
@ -180,50 +175,43 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
for (int otherY = minY, thisY = minY + offsetY; otherY <= maxY; otherY++, thisY++) {
|
||||
int thisLayer = thisY >> 4;
|
||||
int otherLayer = otherY >> 4;
|
||||
byte[] thisIds = ids[thisLayer];
|
||||
byte[] otherIds = other.ids[otherLayer];
|
||||
int[] thisIds = ids[thisLayer];
|
||||
int[] otherIds = other.ids[otherLayer];
|
||||
if (otherIds == null) {
|
||||
if (thisIds != null) {
|
||||
int indexY = (thisY & 15) << 8;
|
||||
byte[] thisData = data[thisLayer];
|
||||
byte[] thisSkyLight = skyLight[thisLayer];
|
||||
byte[] thisBlockLight = blockLight[thisLayer];
|
||||
for (int otherZ = minZ, thisZ = minZ + offsetZ; otherZ <= maxZ; otherZ++, thisZ++) {
|
||||
int startIndex = indexY + (thisZ << 4) + minX + offsetX;
|
||||
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 endIndexShift = endIndex >> 1;
|
||||
if ((startIndex & 1) != 0) {
|
||||
startIndexShift++;
|
||||
setNibble(startIndex, thisData, (byte) 0);
|
||||
setNibble(startIndex, thisSkyLight, (byte) 0);
|
||||
setNibble(startIndex, thisBlockLight, (byte) 0);
|
||||
}
|
||||
if ((endIndex & 1) != 1) {
|
||||
endIndexShift--;
|
||||
setNibble(endIndex, thisData, (byte) 0);
|
||||
setNibble(endIndex, thisSkyLight, (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(thisBlockLight, startIndexShift, endIndexShift + 1, (byte) 0);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
} else if (thisIds == null) {
|
||||
ids[thisLayer] = thisIds = new byte[4096];
|
||||
data[thisLayer] = new byte[2048];
|
||||
ids[thisLayer] = thisIds = new int[4096];
|
||||
skyLight[thisLayer] = new byte[2048];
|
||||
blockLight[thisLayer] = new byte[2048];
|
||||
}
|
||||
int indexY = (thisY & 15) << 8;
|
||||
int otherIndexY = (otherY & 15) << 8;
|
||||
byte[] thisData = data[thisLayer];
|
||||
byte[] thisSkyLight = skyLight[thisLayer];
|
||||
byte[] thisBlockLight = blockLight[thisLayer];
|
||||
byte[] otherData = other.data[otherLayer];
|
||||
byte[] otherSkyLight = other.skyLight[otherLayer];
|
||||
byte[] otherBlockLight = other.blockLight[otherLayer];
|
||||
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) {
|
||||
startIndexShift++;
|
||||
otherStartIndexShift++;
|
||||
setNibble(startIndex, thisData, getNibble(otherStartIndex, otherData));
|
||||
setNibble(startIndex, thisSkyLight, getNibble(otherStartIndex, otherSkyLight));
|
||||
setNibble(startIndex, thisBlockLight, getNibble(otherStartIndex, otherBlockLight));
|
||||
}
|
||||
if ((endIndex & 1) != 1) {
|
||||
endIndexShift--;
|
||||
otherEndIndexShift--;
|
||||
setNibble(endIndex, thisData, getNibble(otherEndIndex, otherData));
|
||||
setNibble(endIndex, thisSkyLight, getNibble(otherEndIndex, otherSkyLight));
|
||||
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(otherBlockLight, otherStartIndexShift, thisBlockLight, startIndexShift, endIndexShift - startIndexShift + 1);
|
||||
} else {
|
||||
for (int thisIndex = startIndex, otherIndex = otherStartIndex; thisIndex <= endIndex; thisIndex++, otherIndex++) {
|
||||
setNibble(thisIndex, thisData, getNibble(otherIndex, otherData));
|
||||
setNibble(thisIndex, thisSkyLight, getNibble(otherIndex, otherSkyLight));
|
||||
setNibble(thisIndex, thisBlockLight, getNibble(otherIndex, otherBlockLight));
|
||||
}
|
||||
@ -295,14 +279,13 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
int startLayer = minY >> 4;
|
||||
int endLayer = maxY >> 4;
|
||||
for (int thisLayer = startLayer + offsetLayer, otherLayer = startLayer; thisLayer <= endLayer; thisLayer++, otherLayer++) {
|
||||
byte[] otherIds = other.ids[otherLayer];
|
||||
byte[] currentIds = ids[thisLayer];
|
||||
int[] otherIds = other.ids[otherLayer];
|
||||
int[] currentIds = ids[thisLayer];
|
||||
int by = otherLayer << 4;
|
||||
int ty = by + 15;
|
||||
if (by >= minY && ty <= maxY) {
|
||||
if (otherIds != null) {
|
||||
ids[thisLayer] = otherIds;
|
||||
data[thisLayer] = other.data[otherLayer];
|
||||
skyLight[thisLayer] = other.skyLight[otherLayer];
|
||||
blockLight[thisLayer] = other.blockLight[otherLayer];
|
||||
} else {
|
||||
@ -317,20 +300,17 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
int indexEndShift = indexEnd >> 1;
|
||||
if (otherIds == null) {
|
||||
if (currentIds != null) {
|
||||
ArrayUtil.fill(currentIds, indexStart, indexEnd, (byte) 0);
|
||||
ArrayUtil.fill(data[thisLayer], indexStartShift, indexEndShift, (byte) 0);
|
||||
Arrays.fill(currentIds, indexStart, indexEnd, 0);
|
||||
ArrayUtil.fill(skyLight[thisLayer], indexStartShift, indexEndShift, (byte) 0);
|
||||
ArrayUtil.fill(blockLight[thisLayer], indexStartShift, indexEndShift, (byte) 0);
|
||||
}
|
||||
} else {
|
||||
if (currentIds == null) {
|
||||
currentIds = this.ids[thisLayer] = new byte[4096];
|
||||
this.data[thisLayer] = new byte[2048];
|
||||
currentIds = this.ids[thisLayer] = new int[4096];
|
||||
this.skyLight[thisLayer] = new byte[2048];
|
||||
this.blockLight[thisLayer] = new byte[2048];
|
||||
}
|
||||
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.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++) {
|
||||
int otherLayer = otherY >> 4;
|
||||
int thisLayer = thisY >> 4;
|
||||
byte[] thisIds = this.ids[thisLayer];
|
||||
byte[] otherIds = other.ids[otherLayer];
|
||||
int[] thisIds = this.ids[thisLayer];
|
||||
int[] otherIds = other.ids[otherLayer];
|
||||
int thisStartIndex = (thisY & 15) << 8;
|
||||
int thisStartIndexShift = thisStartIndex >> 1;
|
||||
if (otherIds == null) {
|
||||
if (thisIds == null) {
|
||||
continue;
|
||||
}
|
||||
ArrayUtil.fill(thisIds, thisStartIndex, thisStartIndex + 256, (byte) 0);
|
||||
ArrayUtil.fill(this.data[thisLayer], thisStartIndexShift, thisStartIndexShift + 128, (byte) 0);
|
||||
Arrays.fill(thisIds, thisStartIndex, thisStartIndex + 256, 0);
|
||||
ArrayUtil.fill(this.skyLight[thisLayer], thisStartIndexShift, thisStartIndexShift + 128, (byte) 0);
|
||||
ArrayUtil.fill(this.blockLight[thisLayer], thisStartIndexShift, thisStartIndexShift + 128, (byte) 0);
|
||||
continue;
|
||||
} else if (thisIds == null) {
|
||||
ids[thisLayer] = thisIds = new byte[4096];
|
||||
data[thisLayer] = new byte[2048];
|
||||
ids[thisLayer] = thisIds = new int[4096];
|
||||
skyLight[thisLayer] = new byte[2048];
|
||||
blockLight[thisLayer] = new byte[2048];
|
||||
}
|
||||
int otherStartIndex = (otherY & 15) << 8;
|
||||
int otherStartIndexShift = otherStartIndex >> 1;
|
||||
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.blockLight[otherLayer], otherStartIndexShift, blockLight[thisLayer], thisStartIndexShift, 128);
|
||||
}
|
||||
@ -438,7 +415,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
level.put("HeightMap", heightMap);
|
||||
ArrayList<HashMap<String, Object>> sections = new ArrayList<>();
|
||||
for (int layer = 0; layer < ids.length; layer++) {
|
||||
byte[] idLayer = ids[layer];
|
||||
int[] idLayer = ids[layer];
|
||||
if (idLayer == null) {
|
||||
continue;
|
||||
}
|
||||
@ -447,7 +424,6 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
map.put("BlockLight", blockLight[layer]);
|
||||
map.put("SkyLight", skyLight[layer]);
|
||||
map.put("Blocks", idLayer);
|
||||
map.put("Data", data[layer]);
|
||||
sections.add(map);
|
||||
}
|
||||
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 {
|
||||
super(parent, x, z);
|
||||
ids = new byte[16][];
|
||||
data = new byte[16][];
|
||||
ids = new int[16][];
|
||||
skyLight = new byte[16][];
|
||||
blockLight = new byte[16][];
|
||||
NBTStreamer streamer = new NBTStreamer(nis);
|
||||
@ -469,8 +444,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
(BiConsumer<Integer, Long>) (index, value) -> lastUpdate = value);
|
||||
streamer.addReader(".Level.Sections.#", (BiConsumer<Integer, CompoundTag>) (index, tag) -> {
|
||||
int layer = tag.getByte("Y");
|
||||
ids[layer] = tag.getByteArray("Blocks");
|
||||
data[layer] = tag.getByteArray("Data");
|
||||
ids[layer] = tag.getIntArray("Blocks");
|
||||
skyLight[layer] = tag.getByteArray("SkyLight");
|
||||
blockLight[layer] = tag.getByteArray("BlockLight");
|
||||
});
|
||||
@ -783,7 +757,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
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 length is 4096
|
||||
if (a == b) return true;
|
||||
@ -793,17 +767,17 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
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
|
||||
for (byte i = 0; i < 16; i++) {
|
||||
if ((a[i] == null) != (b[i] == null)) {
|
||||
if (matchNullToAir) {
|
||||
if (b[i] != null) {
|
||||
for (byte c : b[i]) {
|
||||
for (int c : b[i]) {
|
||||
if (c != 0) return false;
|
||||
}
|
||||
} else if (a[i] != null) {
|
||||
for (byte c : a[i]) {
|
||||
for (int c : a[i]) {
|
||||
if (c != 0) return false;
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,7 @@ import javax.annotation.Nullable;
|
||||
public class MutableMCABackedBaseBlock extends BaseBlock {
|
||||
|
||||
private MCAChunk chunk;
|
||||
private byte[] data;
|
||||
private byte[] ids;
|
||||
private int[] ids;
|
||||
private int index;
|
||||
private int x;
|
||||
private int y;
|
||||
@ -29,7 +28,6 @@ public class MutableMCABackedBaseBlock extends BaseBlock {
|
||||
|
||||
public void setArrays(int layer) {
|
||||
ids = chunk.ids[layer];
|
||||
data = chunk.data[layer];
|
||||
}
|
||||
|
||||
public MCAChunk getChunk() {
|
||||
@ -79,11 +77,7 @@ public class MutableMCABackedBaseBlock extends BaseBlock {
|
||||
return chunk.getTile(x, y, z);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void setId(int id) {
|
||||
// ids[index] = (byte) id;
|
||||
// chunk.setModified();
|
||||
// }
|
||||
|
||||
//
|
||||
// @Override
|
||||
// public void setData(int value) {
|
||||
|
@ -29,10 +29,10 @@ public class CountIdFilter extends MCAFilterCounter {
|
||||
public MCAChunk applyChunk(MCAChunk chunk, MutableLong count) {
|
||||
// TODO FIXME
|
||||
for (int layer = 0; layer < chunk.ids.length; layer++) {
|
||||
byte[] ids = chunk.ids[layer];
|
||||
int[] ids = chunk.ids[layer];
|
||||
if (ids != null) {
|
||||
for (byte i : ids) {
|
||||
if (allowedId[i & 0xFF]) {
|
||||
for (int i : ids) {
|
||||
if (allowedId[BlockTypes.getFromStateId(i).getInternalId()]) {
|
||||
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) {
|
||||
for (int i = 0; i < chunk.ids.length; i++) {
|
||||
byte[] arr = chunk.ids[i];
|
||||
int[] arr = chunk.ids[i];
|
||||
if (arr != null) {
|
||||
for (byte b : arr) {
|
||||
if (b != 0) return;
|
||||
for (int b : arr) {
|
||||
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.object.number.MutableLong;
|
||||
import com.boydti.fawe.util.ArrayUtil;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class RemoveLayerFilter extends MCAFilterCounter {
|
||||
private final int startLayer;
|
||||
@ -23,7 +26,7 @@ public class RemoveLayerFilter extends MCAFilterCounter {
|
||||
@Override
|
||||
public MCAChunk applyChunk(MCAChunk chunk, MutableLong cache) {
|
||||
for (int layer = startLayer; layer <= endLayer; layer++) {
|
||||
byte[] ids = chunk.ids[layer];
|
||||
int[] ids = chunk.ids[layer];
|
||||
if (ids == null) {
|
||||
return null;
|
||||
}
|
||||
@ -41,7 +44,7 @@ public class RemoveLayerFilter extends MCAFilterCounter {
|
||||
for (int y = startY; y <= endY; y++) {
|
||||
int indexStart = y << 8;
|
||||
int indexEnd = indexStart + 255;
|
||||
ArrayUtil.fill(ids, indexStart, indexEnd + 1, (byte) 0);
|
||||
Arrays.fill(ids, indexStart, indexEnd + 1, BlockTypes.AIR.getInternalId());
|
||||
}
|
||||
chunk.setModified();
|
||||
}
|
||||
|
@ -5,21 +5,21 @@ 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;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class TrimAirFilter extends MCAFilterCounter {
|
||||
@Override
|
||||
public MCAChunk applyChunk(MCAChunk chunk, MutableLong cache) {
|
||||
for (int layer = 0; layer < chunk.ids.length; layer++) {
|
||||
byte[] idLayer = chunk.ids[layer];
|
||||
int[] idLayer = chunk.ids[layer];
|
||||
if (idLayer == null) continue;
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
if (idLayer[i] != 0) {
|
||||
if (!BlockTypes.getFromStateId(idLayer[i]).getMaterial().isAir()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
{ // Possibly dead code depending on the generator
|
||||
chunk.ids[layer] = null;
|
||||
chunk.data[layer] = null;
|
||||
chunk.setModified();
|
||||
}
|
||||
}
|
||||
|
@ -283,12 +283,11 @@ public class SchemVis extends ImmutableVirtualWorld {
|
||||
*/
|
||||
private void select(MCAChunk chunk) {
|
||||
for (int layer = 0; layer < 16; layer++) {
|
||||
byte[] ids = chunk.ids[layer];
|
||||
int[] ids = chunk.ids[layer];
|
||||
if (ids != null) {
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
// TODO FIXME update to 1.13
|
||||
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.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -34,7 +36,7 @@ public class PlotTrim {
|
||||
private final MCAQueue originalQueue;
|
||||
private final File root;
|
||||
private final File originalRoot;
|
||||
private byte[][] ids;
|
||||
private int[][] ids;
|
||||
private boolean deleteUnowned = true;
|
||||
|
||||
public PlotTrim(PlotPlayer player, PlotArea area, String worldName, boolean deleteUnowned) {
|
||||
@ -49,7 +51,7 @@ public class PlotTrim {
|
||||
this.deleteUnowned = deleteUnowned;
|
||||
}
|
||||
|
||||
public void setChunk(byte[][] ids) {
|
||||
public void setChunk(int[][] ids) {
|
||||
checkNotNull(ids);
|
||||
this.ids = ids;
|
||||
}
|
||||
@ -182,7 +184,7 @@ public class PlotTrim {
|
||||
|
||||
private int count = 0;
|
||||
|
||||
private boolean isEqual(byte[] a, byte[] b) {
|
||||
private boolean isEqual(int[] a, int[] b) {
|
||||
if (a == b) {
|
||||
return true;
|
||||
}
|
||||
@ -195,9 +197,9 @@ public class PlotTrim {
|
||||
return isEmpty(b);
|
||||
}
|
||||
|
||||
private boolean isEmpty(byte[] a) {
|
||||
for (byte b : a) {
|
||||
if (b != 0) {
|
||||
private boolean isEmpty(int[] a) {
|
||||
for (int b : a) {
|
||||
if (!BlockTypes.getFromStateId(b).getMaterial().isAir()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren