This commit is contained in:
Jesse Boyd 2016-09-28 23:34:48 +10:00
parent b414229c91
commit cb4821078e
2 changed files with 6 additions and 3 deletions

View File

@ -3,16 +3,19 @@ package com.boydti.fawe.object.pattern;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
public class OffsetPattern extends AbstractPattern { public class OffsetPattern extends AbstractPattern {
private final int dx,dy,dz; private final int dx,dy,dz;
private final Vector mutable = new Vector(); private final Vector mutable = new Vector();
private final Pattern pattern;
public OffsetPattern(int dx, int dy, int dz) { public OffsetPattern(Pattern pattern, int dx, int dy, int dz) {
this.dx = dx; this.dx = dx;
this.dy = dy; this.dy = dy;
this.dz = dz; this.dz = dz;
this.pattern = pattern;
} }
@Override @Override
@ -20,6 +23,6 @@ public class OffsetPattern extends AbstractPattern {
mutable.x = position.x + dx; mutable.x = position.x + dx;
mutable.y = position.y + dy; mutable.y = position.y + dy;
mutable.z = position.z + dz; mutable.z = position.z + dz;
return null; return pattern.apply(mutable);
} }
} }

View File

@ -131,7 +131,7 @@ public class HashTagPatternParser extends InputParser<Pattern> {
int z = Math.abs(Integer.parseInt(split2[3])); int z = Math.abs(Integer.parseInt(split2[3]));
rest = rest.substring(split2[1].length() + split2[2].length() + split2[3].length() + 3); rest = rest.substring(split2[1].length() + split2[2].length() + split2[3].length() + 3);
Pattern pattern = parseFromInput(rest, context); Pattern pattern = parseFromInput(rest, context);
return new OffsetPattern(x, y, z); return new OffsetPattern(pattern, x, y, z);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new InputParseException("The correct format is #offset:<dx>:<dy>:<dz>:<pattern>"); throw new InputParseException("The correct format is #offset:<dx>:<dy>:<dz>:<pattern>");
} }