Add id/data pattern
This commit is contained in:
parent
84fdf8e246
commit
57d41ae6f7
@ -0,0 +1,25 @@
|
|||||||
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.FaweCache;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
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 DataPattern extends AbstractPattern {
|
||||||
|
private final Extent extent;
|
||||||
|
private final Pattern pattern;
|
||||||
|
|
||||||
|
public DataPattern(Extent extent, Pattern parent) {
|
||||||
|
this.extent = extent;
|
||||||
|
this.pattern = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock apply(Vector position) {
|
||||||
|
BaseBlock oldBlock = extent.getBlock(position);
|
||||||
|
BaseBlock newBlock = pattern.apply(position);
|
||||||
|
return FaweCache.getBlock(oldBlock.getId(), newBlock.getData());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.FaweCache;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
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 IdPattern extends AbstractPattern {
|
||||||
|
private final Extent extent;
|
||||||
|
private final Pattern pattern;
|
||||||
|
|
||||||
|
public IdPattern(Extent extent, Pattern parent) {
|
||||||
|
this.extent = extent;
|
||||||
|
this.pattern = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock apply(Vector position) {
|
||||||
|
BaseBlock oldBlock = extent.getBlock(position);
|
||||||
|
BaseBlock newBlock = pattern.apply(position);
|
||||||
|
return FaweCache.getBlock(newBlock.getId(), oldBlock.getData());
|
||||||
|
}
|
||||||
|
}
|
@ -1,19 +1,6 @@
|
|||||||
package com.sk89q.worldedit.extension.factory;
|
package com.sk89q.worldedit.extension.factory;
|
||||||
|
|
||||||
import com.boydti.fawe.object.pattern.ExistingPattern;
|
import com.boydti.fawe.object.pattern.*;
|
||||||
import com.boydti.fawe.object.pattern.ExpressionPattern;
|
|
||||||
import com.boydti.fawe.object.pattern.Linear3DBlockPattern;
|
|
||||||
import com.boydti.fawe.object.pattern.LinearBlockPattern;
|
|
||||||
import com.boydti.fawe.object.pattern.MaskedPattern;
|
|
||||||
import com.boydti.fawe.object.pattern.NoXPattern;
|
|
||||||
import com.boydti.fawe.object.pattern.NoYPattern;
|
|
||||||
import com.boydti.fawe.object.pattern.NoZPattern;
|
|
||||||
import com.boydti.fawe.object.pattern.OffsetPattern;
|
|
||||||
import com.boydti.fawe.object.pattern.PatternExtent;
|
|
||||||
import com.boydti.fawe.object.pattern.RandomOffsetPattern;
|
|
||||||
import com.boydti.fawe.object.pattern.RelativePattern;
|
|
||||||
import com.boydti.fawe.object.pattern.SolidRandomOffsetPattern;
|
|
||||||
import com.boydti.fawe.object.pattern.SurfaceRandomOffsetPattern;
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.EmptyClipboardException;
|
import com.sk89q.worldedit.EmptyClipboardException;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -92,6 +79,12 @@ public class HashTagPatternParser extends InputParser<Pattern> {
|
|||||||
if (split2.length > 1) {
|
if (split2.length > 1) {
|
||||||
String rest = input.substring(split2[0].length() + 1);
|
String rest = input.substring(split2[0].length() + 1);
|
||||||
switch (split2[0].toLowerCase()) {
|
switch (split2[0].toLowerCase()) {
|
||||||
|
case "#id": {
|
||||||
|
return new IdPattern(context.requireExtent(), parseFromInput(rest, context));
|
||||||
|
}
|
||||||
|
case "#data": {
|
||||||
|
return new DataPattern(context.requireExtent(), parseFromInput(rest, context));
|
||||||
|
}
|
||||||
case "#~":
|
case "#~":
|
||||||
case "#r":
|
case "#r":
|
||||||
case "#relative":
|
case "#relative":
|
||||||
|
Loading…
Reference in New Issue
Block a user