geforkt von Mirrors/FastAsyncWorldEdit
Implement InvertedMask & UnderOverlayMask as decorators
Dieser Commit ist enthalten in:
Ursprung
eb14efd2df
Commit
30ed049918
@ -614,31 +614,13 @@ public class WorldEdit {
|
|||||||
|
|
||||||
case '>':
|
case '>':
|
||||||
case '<':
|
case '<':
|
||||||
final LocalWorld world = player.getWorld();
|
Mask submask;
|
||||||
final boolean over = firstChar == '>';
|
if (component.length() > 1) {
|
||||||
final String idString = component.substring(1);
|
submask = getBlockMaskComponent(player, session, masks, component.substring(1));
|
||||||
final Set<Integer> ids = new HashSet<Integer>();
|
} else {
|
||||||
|
submask = new ExistingBlockMask();
|
||||||
if (!(idString.equals("*") || idString.equals(""))) {
|
|
||||||
for (String sid : idString.split(",")) {
|
|
||||||
try {
|
|
||||||
final int pid = Integer.parseInt(sid);
|
|
||||||
if (!world.isValidBlockType(pid)) {
|
|
||||||
throw new UnknownItemException(sid);
|
|
||||||
}
|
}
|
||||||
ids.add(pid);
|
return new UnderOverlayMask(submask, firstChar == '>');
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
final BlockType type = BlockType.lookup(sid);
|
|
||||||
final int id = type.getID();
|
|
||||||
if (!world.isValidBlockType(id)) {
|
|
||||||
throw new UnknownItemException(sid);
|
|
||||||
}
|
|
||||||
ids.add(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new UnderOverlayMask(ids, over);
|
|
||||||
|
|
||||||
case '$':
|
case '$':
|
||||||
Set<BiomeType> biomes = new HashSet<BiomeType>();
|
Set<BiomeType> biomes = new HashSet<BiomeType>();
|
||||||
@ -651,7 +633,7 @@ public class WorldEdit {
|
|||||||
|
|
||||||
case '!':
|
case '!':
|
||||||
if (component.length() > 1) {
|
if (component.length() > 1) {
|
||||||
return new InvertedBlockTypeMask(getBlockIDs(player, component.substring(1), true));
|
return new InvertedMask(getBlockMaskComponent(player, session, masks, component.substring(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -28,6 +28,7 @@ import com.sk89q.worldedit.Vector;
|
|||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class InvertedBlockTypeMask extends BlockTypeMask {
|
public class InvertedBlockTypeMask extends BlockTypeMask {
|
||||||
public InvertedBlockTypeMask() {
|
public InvertedBlockTypeMask() {
|
||||||
}
|
}
|
||||||
|
25
src/main/java/com/sk89q/worldedit/masks/InvertedMask.java
Normale Datei
25
src/main/java/com/sk89q/worldedit/masks/InvertedMask.java
Normale Datei
@ -0,0 +1,25 @@
|
|||||||
|
package com.sk89q.worldedit.masks;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
|
||||||
|
public class InvertedMask implements Mask {
|
||||||
|
|
||||||
|
private Mask mask;
|
||||||
|
|
||||||
|
public InvertedMask(Mask mask) {
|
||||||
|
this.mask = mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||||
|
mask.prepare(session, player, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean matches(EditSession editSession, Vector pos) {
|
||||||
|
return !mask.matches(editSession, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -19,14 +19,12 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.masks;
|
package com.sk89q.worldedit.masks;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
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.blocks.BlockID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -34,24 +32,37 @@ import com.sk89q.worldedit.blocks.BlockID;
|
|||||||
*/
|
*/
|
||||||
public class UnderOverlayMask implements Mask {
|
public class UnderOverlayMask implements Mask {
|
||||||
|
|
||||||
boolean overlay;
|
private int yMod;
|
||||||
Set<Integer> ids = new HashSet<Integer>();
|
private Mask mask;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public UnderOverlayMask(Set<Integer> ids, boolean overlay) {
|
public UnderOverlayMask(Set<Integer> ids, boolean overlay) {
|
||||||
addAll(ids);
|
this(new BlockTypeMask(ids), overlay);
|
||||||
this.overlay = overlay;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UnderOverlayMask(Mask mask, boolean overlay) {
|
||||||
|
this.yMod = overlay ? -1 : 1;
|
||||||
|
this.mask = mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void addAll(Set<Integer> ids) {
|
public void addAll(Set<Integer> ids) {
|
||||||
this.ids.addAll(ids);
|
if (mask instanceof BlockTypeMask) {
|
||||||
|
BlockTypeMask blockTypeMask = (BlockTypeMask) mask;
|
||||||
|
for (Integer id : ids) {
|
||||||
|
blockTypeMask.add(id);
|
||||||
|
}
|
||||||
|
} else if (mask instanceof ExistingBlockMask) {
|
||||||
|
mask = new BlockTypeMask(ids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||||
|
mask.prepare(session, player, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches(EditSession editSession, Vector pos) {
|
public boolean matches(EditSession editSession, Vector pos) {
|
||||||
int id = editSession.getBlock(pos.setY(pos.getBlockY() + (overlay ? -1 : 1))).getType();
|
return mask.matches(editSession, pos.add(0, yMod, 0));
|
||||||
return ids.isEmpty() ? id != BlockID.AIR : ids.contains(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren