mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2025-01-04 07:28:17 +01:00
Anvil trimAllAir + Fix elliptic cylinder arguments
This commit is contained in:
parent
0dbb3b2844
commit
bc0bc5b705
@ -19,6 +19,7 @@ import com.boydti.fawe.jnbt.anvil.filters.RemapFilter;
|
|||||||
import com.boydti.fawe.jnbt.anvil.filters.RemoveLayerFilter;
|
import com.boydti.fawe.jnbt.anvil.filters.RemoveLayerFilter;
|
||||||
import com.boydti.fawe.jnbt.anvil.filters.ReplacePatternFilter;
|
import com.boydti.fawe.jnbt.anvil.filters.ReplacePatternFilter;
|
||||||
import com.boydti.fawe.jnbt.anvil.filters.ReplaceSimpleFilter;
|
import com.boydti.fawe.jnbt.anvil.filters.ReplaceSimpleFilter;
|
||||||
|
import com.boydti.fawe.jnbt.anvil.filters.TrimAirFilter;
|
||||||
import com.boydti.fawe.jnbt.anvil.history.IAnvilHistory;
|
import com.boydti.fawe.jnbt.anvil.history.IAnvilHistory;
|
||||||
import com.boydti.fawe.jnbt.anvil.history.NullAnvilHistory;
|
import com.boydti.fawe.jnbt.anvil.history.NullAnvilHistory;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
@ -254,6 +255,17 @@ 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 = {"trimallair", },
|
||||||
|
desc = "Trim all air in the world"
|
||||||
|
)
|
||||||
|
@CommandPermissions("worldedit.anvil.trimallair")
|
||||||
|
public void trimAllAir(Player player, String folder) throws WorldEditException {
|
||||||
|
TrimAirFilter filter = new TrimAirFilter();
|
||||||
|
TrimAirFilter result = runWithWorld(player, folder, filter, true);
|
||||||
|
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||||
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"replaceallpattern", "reap", "repallpat"},
|
aliases = {"replaceallpattern", "reap", "repallpat"},
|
||||||
usage = "<folder> [from-block] <to-pattern>",
|
usage = "<folder> [from-block] <to-pattern>",
|
||||||
|
@ -240,7 +240,7 @@ public class FawePrimitiveBinding extends BindingHelper {
|
|||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
radiusX = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0]));
|
radiusX = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0]));
|
||||||
radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[2]));
|
radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[1]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.boydti.fawe.jnbt.anvil.filters;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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];
|
||||||
|
if (idLayer == null) continue;
|
||||||
|
for (int i = 0; i < 4096; i++) {
|
||||||
|
if (idLayer[i] != 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{ // Possibly dead code depending on the generator
|
||||||
|
chunk.ids[layer] = null;
|
||||||
|
chunk.data[layer] = null;
|
||||||
|
chunk.setModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chunk.setDeleted(true);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finishFile(MCAFile file, MutableLong cache) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -35,19 +35,19 @@ public class BlobBrush implements Brush {
|
|||||||
double modY = 1d/radius.getY();
|
double modY = 1d/radius.getY();
|
||||||
double modZ = 1d/radius.getZ();
|
double modZ = 1d/radius.getZ();
|
||||||
|
|
||||||
int radiusSqr = (int) (size * size);
|
int radius = (int) size;
|
||||||
int sizeInt = (int) size * 2;
|
int sizeInt = (int) size * 2;
|
||||||
for (int x = -sizeInt; x <= sizeInt; x++) {
|
for (int x = -sizeInt; x <= sizeInt; x++) {
|
||||||
double nx = seedX + x * distort;
|
double nx = seedX + x * distort;
|
||||||
double d1 = x * x * modX;
|
double d1 = Math.abs(x) * modX;
|
||||||
for (int y = -sizeInt; y <= sizeInt; y++) {
|
for (int y = -sizeInt; y <= sizeInt; y++) {
|
||||||
double d2 = d1 + y * y * modY;
|
double d2 = d1 + Math.abs(y) * modY;
|
||||||
double ny = seedY + y * distort;
|
double ny = seedY + y * distort;
|
||||||
for (int z = -sizeInt; z <= sizeInt; z++) {
|
for (int z = -sizeInt; z <= sizeInt; z++) {
|
||||||
double nz = seedZ + z * distort;
|
double nz = seedZ + z * distort;
|
||||||
double distance = d2 + z * z * modZ;
|
double distance = d2 + Math.abs(z) * modZ;
|
||||||
double noise = this.amplitude * SimplexNoise.noise(nx, ny, nz);
|
double noise = this.amplitude * SimplexNoise.noise(nx, ny, nz);
|
||||||
if (distance + distance * noise < radiusSqr) {
|
if (distance + distance * noise < radius) {
|
||||||
editSession.setBlock(px + x, py + y, pz + z, pattern);
|
editSession.setBlock(px + x, py + y, pz + z, pattern);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
package com.boydti.fawe.object.brush;
|
||||||
|
|
||||||
|
import com.boydti.fawe.object.random.SimplexNoise;
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
|
public class RockBrush implements Brush {
|
||||||
|
private final double amplitude;
|
||||||
|
private final double frequency;
|
||||||
|
private final Vector radius;
|
||||||
|
|
||||||
|
public RockBrush(Vector radius, double frequency, double amplitude) {
|
||||||
|
this.frequency = frequency;
|
||||||
|
this.amplitude = amplitude;
|
||||||
|
this.radius = radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
|
double seedX = ThreadLocalRandom.current().nextDouble();
|
||||||
|
double seedY = ThreadLocalRandom.current().nextDouble();
|
||||||
|
double seedZ = ThreadLocalRandom.current().nextDouble();
|
||||||
|
|
||||||
|
int px = position.getBlockX();
|
||||||
|
int py = position.getBlockY();
|
||||||
|
int pz = position.getBlockZ();
|
||||||
|
|
||||||
|
double distort = this.frequency / size;
|
||||||
|
|
||||||
|
double modX = 1d/radius.getX();
|
||||||
|
double modY = 1d/radius.getY();
|
||||||
|
double modZ = 1d/radius.getZ();
|
||||||
|
|
||||||
|
int radiusSqr = (int) (size * size);
|
||||||
|
int sizeInt = (int) size * 2;
|
||||||
|
for (int x = -sizeInt; x <= sizeInt; x++) {
|
||||||
|
double nx = seedX + x * distort;
|
||||||
|
double d1 = x * x * modX;
|
||||||
|
for (int y = -sizeInt; y <= sizeInt; y++) {
|
||||||
|
double d2 = d1 + y * y * modY;
|
||||||
|
double ny = seedY + y * distort;
|
||||||
|
for (int z = -sizeInt; z <= sizeInt; z++) {
|
||||||
|
double nz = seedZ + z * distort;
|
||||||
|
double distance = d2 + z * z * modZ;
|
||||||
|
double noise = this.amplitude * SimplexNoise.noise(nx, ny, nz);
|
||||||
|
if (distance + distance * noise < radiusSqr) {
|
||||||
|
editSession.setBlock(px + x, py + y, pz + z, pattern);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user