mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-28 21:56:33 +01:00
Add l2d
This commit is contained in:
parent
b979db514e
commit
b181e8e400
@ -0,0 +1,35 @@
|
||||
package com.boydti.fawe.object.pattern;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
|
||||
public class Linear2DBlockPattern extends AbstractPattern {
|
||||
|
||||
private final Pattern[] patternsArray;
|
||||
|
||||
public Linear2DBlockPattern(Pattern[] patterns) {
|
||||
this.patternsArray = patterns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(Vector position) {
|
||||
int index = (position.getBlockX() + position.getBlockZ()) % patternsArray.length;
|
||||
if (index < 0) {
|
||||
index += patternsArray.length;
|
||||
}
|
||||
return patternsArray[index].apply(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, Vector set, Vector get) throws WorldEditException {
|
||||
int index = (get.getBlockX() + get.getBlockZ()) % patternsArray.length;
|
||||
if (index < 0) {
|
||||
index += patternsArray.length;
|
||||
}
|
||||
return patternsArray[index].apply(extent, set, get);
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ import com.boydti.fawe.object.pattern.ExpressionPattern;
|
||||
import com.boydti.fawe.object.pattern.FullClipboardPattern;
|
||||
import com.boydti.fawe.object.pattern.IdDataMaskPattern;
|
||||
import com.boydti.fawe.object.pattern.IdPattern;
|
||||
import com.boydti.fawe.object.pattern.Linear2DBlockPattern;
|
||||
import com.boydti.fawe.object.pattern.Linear3DBlockPattern;
|
||||
import com.boydti.fawe.object.pattern.LinearBlockPattern;
|
||||
import com.boydti.fawe.object.pattern.MaskedPattern;
|
||||
@ -433,6 +434,21 @@ public class PatternCommands extends MethodCommands {
|
||||
return other;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"#linear2d", "#l2d"},
|
||||
desc = "Use the x,z coordinate to pick a block from the list",
|
||||
usage = "<pattern>",
|
||||
min = 1,
|
||||
max = 1
|
||||
)
|
||||
public Pattern linear2d(Actor actor, LocalSession session, Pattern other) {
|
||||
if (other instanceof RandomPattern) {
|
||||
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||
return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||
}
|
||||
return other;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"="},
|
||||
desc = "Expression pattern: http://wiki.sk89q.com/wiki/WorldEdit/Expression_syntax",
|
||||
|
Loading…
Reference in New Issue
Block a user