geforkt von Mirrors/FastAsyncWorldEdit
Make //setbiome respect global mask, if set to a biome mask
Dieser Commit ist enthalten in:
Ursprung
e7d55ca87d
Commit
2846119f08
@ -19,6 +19,9 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.Vector2D;
|
import com.sk89q.worldedit.Vector2D;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.masks.BiomeTypeMask;
|
||||||
|
import com.sk89q.worldedit.masks.InvertedMask;
|
||||||
|
import com.sk89q.worldedit.masks.Mask;
|
||||||
import com.sk89q.worldedit.regions.FlatRegion;
|
import com.sk89q.worldedit.regions.FlatRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
@ -138,10 +141,24 @@ public class BiomeCommands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mask mask = editSession.getMask();
|
||||||
|
BiomeTypeMask biomeMask = null;
|
||||||
|
boolean inverted = false;
|
||||||
|
if (mask instanceof BiomeTypeMask) {
|
||||||
|
biomeMask = (BiomeTypeMask) mask;
|
||||||
|
} else if (mask instanceof InvertedMask && ((InvertedMask) mask).getInvertedMask() instanceof BiomeTypeMask) {
|
||||||
|
inverted = true;
|
||||||
|
biomeMask = (BiomeTypeMask) ((InvertedMask) mask).getInvertedMask();
|
||||||
|
}
|
||||||
|
|
||||||
if (args.hasFlag('p')) {
|
if (args.hasFlag('p')) {
|
||||||
Vector2D pos = player.getPosition().toVector2D();
|
Vector2D pos = player.getPosition().toVector2D();
|
||||||
|
if (biomeMask != null && (biomeMask.matches2D(editSession, pos) ^ inverted)) {
|
||||||
player.getWorld().setBiome(pos, target);
|
player.getWorld().setBiome(pos, target);
|
||||||
player.print("Biome changed to " + target.getName() + " at your current location.");
|
player.print("Biome changed to " + target.getName() + " at your current location.");
|
||||||
|
} else {
|
||||||
|
player.print("Your global mask doesn't match this biome. Type //gmask to disable it.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
LocalWorld world = player.getWorld();
|
LocalWorld world = player.getWorld();
|
||||||
@ -149,19 +166,23 @@ public class BiomeCommands {
|
|||||||
|
|
||||||
if (region instanceof FlatRegion) {
|
if (region instanceof FlatRegion) {
|
||||||
for (Vector2D pt : ((FlatRegion) region).asFlatRegion()) {
|
for (Vector2D pt : ((FlatRegion) region).asFlatRegion()) {
|
||||||
|
if (biomeMask != null && (biomeMask.matches2D(editSession, pt) ^ inverted)) {
|
||||||
world.setBiome(pt, target);
|
world.setBiome(pt, target);
|
||||||
++affected;
|
++affected;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
HashSet<Long> alreadyVisited = new HashSet<Long>();
|
HashSet<Long> alreadyVisited = new HashSet<Long>();
|
||||||
for (Vector pt : region) {
|
for (Vector pt : region) {
|
||||||
if (!alreadyVisited.contains((long)pt.getBlockX() << 32 | pt.getBlockZ())) {
|
if (!alreadyVisited.contains((long)pt.getBlockX() << 32 | pt.getBlockZ())) {
|
||||||
alreadyVisited.add(((long)pt.getBlockX() << 32 | pt.getBlockZ()));
|
alreadyVisited.add(((long)pt.getBlockX() << 32 | pt.getBlockZ()));
|
||||||
|
if (biomeMask != null && (biomeMask.matches(editSession, pt) ^ inverted)) {
|
||||||
world.setBiome(pt.toVector2D(), target);
|
world.setBiome(pt.toVector2D(), target);
|
||||||
++affected;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
player.print("Biome changed to " + target.getName() + ". " + affected + " columns affected.");
|
player.print("Biome changed to " + target.getName() + ". " + affected + " columns affected.");
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import com.sk89q.worldedit.EditSession;
|
|||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.Vector2D;
|
||||||
|
|
||||||
public class BiomeTypeMask implements Mask {
|
public class BiomeTypeMask implements Mask {
|
||||||
|
|
||||||
@ -24,9 +25,13 @@ public class BiomeTypeMask implements Mask {
|
|||||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches(EditSession editSession, Vector pos) {
|
public boolean matches2D(EditSession editSession, Vector2D pos) {
|
||||||
BiomeType biome = editSession.getWorld().getBiome(pos.toVector2D());
|
BiomeType biome = editSession.getWorld().getBiome(pos);
|
||||||
return biomes.contains(biome);
|
return biomes.contains(biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean matches(EditSession editSession, Vector pos) {
|
||||||
|
return matches2D(editSession, pos.toVector2D());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,4 +22,7 @@ public class InvertedMask implements Mask {
|
|||||||
return !mask.matches(editSession, pos);
|
return !mask.matches(editSession, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Mask getInvertedMask() {
|
||||||
|
return mask;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren