mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-12-03 16:13:34 +01:00
debug fix air
This commit is contained in:
parent
65939fa878
commit
789c923106
@ -68,6 +68,12 @@ public class AnvilCommands {
|
||||
*/
|
||||
@Deprecated
|
||||
public static <G, T extends MCAFilter<G>> T runWithWorld(Player player, String folder, T filter, boolean force) {
|
||||
return runWithWorld(player, folder, filter, force, false);
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public static <G, T extends MCAFilter<G>> T runWithWorld(Player player, String folder, T filter, boolean force, boolean unsafe) {
|
||||
boolean copy = false;
|
||||
if (FaweAPI.getWorld(folder) != null) {
|
||||
if (!force) {
|
||||
@ -78,7 +84,7 @@ public class AnvilCommands {
|
||||
}
|
||||
FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false);
|
||||
MCAQueue queue = new MCAQueue(defaultQueue);
|
||||
if (copy) {
|
||||
if (copy && !unsafe) {
|
||||
return queue.filterCopy(filter, RegionWrapper.GLOBAL());
|
||||
} else {
|
||||
return queue.filterWorld(filter);
|
||||
@ -284,9 +290,21 @@ public class AnvilCommands {
|
||||
desc = "Trim all air in the world"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.trimallair")
|
||||
public void trimAllAir(Player player, String folder) throws WorldEditException {
|
||||
public void trimAllAir(Player player, String folder, @Switch('u') boolean unsafe) throws WorldEditException {
|
||||
TrimAirFilter filter = new TrimAirFilter();
|
||||
TrimAirFilter result = runWithWorld(player, folder, filter, true);
|
||||
TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe);
|
||||
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = {"debugfixair", },
|
||||
desc = "debug"
|
||||
)
|
||||
@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()));
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,82 @@
|
||||
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;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
|
||||
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] = BlockID.DIRT;
|
||||
}
|
||||
}
|
||||
ids0[i] = BlockID.BEDROCK;
|
||||
chunk.ids[4][i] = BlockID.GRASS;
|
||||
cache.add(256);
|
||||
}
|
||||
}
|
||||
if (modified) 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ public class TrimAirFilter extends MCAFilterCounter {
|
||||
chunk.setModified();
|
||||
}
|
||||
}
|
||||
cache.add(Character.MAX_VALUE);
|
||||
chunk.setDeleted(true);
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user