Fix brush pattern reset + add offset transform
This commit is contained in:
parent
d765b24b27
commit
cff2cc846a
@ -40,8 +40,6 @@ public class ScatterBrush implements Brush {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
// pick a bunch of random points
|
|
||||||
// expand randomly from them
|
|
||||||
this.mask = editSession.getMask();
|
this.mask = editSession.getMask();
|
||||||
if (this.mask == null) {
|
if (this.mask == null) {
|
||||||
this.mask = Masks.alwaysTrue();
|
this.mask = Masks.alwaysTrue();
|
||||||
|
@ -75,6 +75,21 @@ public class DefaultTransformParser extends InputParser<ResettableExtent> {
|
|||||||
Pattern pattern = worldEdit.getPatternFactory().parseFromInput(rest, context);
|
Pattern pattern = worldEdit.getPatternFactory().parseFromInput(rest, context);
|
||||||
return new PatternTransform(parent, pattern);
|
return new PatternTransform(parent, pattern);
|
||||||
}
|
}
|
||||||
|
case "#offset": {
|
||||||
|
try {
|
||||||
|
String[] split2 = component.split(":");
|
||||||
|
double x = Math.abs(Expression.compile(split2[1]).evaluate());
|
||||||
|
double y = Math.abs(Expression.compile(split2[2]).evaluate());
|
||||||
|
double z = Math.abs(Expression.compile(split2[3]).evaluate());
|
||||||
|
rest = rest.substring(Math.min(rest.length(), split2[1].length() + split2[2].length() + split2[3].length() + 3));
|
||||||
|
if (!rest.isEmpty()) {
|
||||||
|
parent = parseFromInput(rest, context);
|
||||||
|
}
|
||||||
|
return new OffsetExtent(parent, (int) x, (int) y, (int) z);
|
||||||
|
} catch (NumberFormatException | ExpressionException e) {
|
||||||
|
throw new InputParseException("The correct format is #offset:<dx>:<dy>:<dz>");
|
||||||
|
}
|
||||||
|
}
|
||||||
case "#scale": {
|
case "#scale": {
|
||||||
try {
|
try {
|
||||||
String[] split2 = component.split(":");
|
String[] split2 = component.split(":");
|
||||||
|
@ -13,6 +13,7 @@ import com.boydti.fawe.object.brush.visualization.VisualChunk;
|
|||||||
import com.boydti.fawe.object.brush.visualization.VisualExtent;
|
import com.boydti.fawe.object.brush.visualization.VisualExtent;
|
||||||
import com.boydti.fawe.object.brush.visualization.VisualMode;
|
import com.boydti.fawe.object.brush.visualization.VisualMode;
|
||||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||||
|
import com.boydti.fawe.object.pattern.PatternTraverser;
|
||||||
import com.boydti.fawe.util.EditSessionBuilder;
|
import com.boydti.fawe.util.EditSessionBuilder;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
@ -286,7 +287,6 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
BBC.NO_BLOCK.send(player);
|
BBC.NO_BLOCK.send(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockBag bag = session.getBlockBag(player);
|
BlockBag bag = session.getBlockBag(player);
|
||||||
Request.request().setEditSession(editSession);
|
Request.request().setEditSession(editSession);
|
||||||
if (current.mask != null) {
|
if (current.mask != null) {
|
||||||
@ -319,6 +319,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
editSession.addTransform(current.transform);
|
editSession.addTransform(current.transform);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
new PatternTraverser(current).reset(editSession);
|
||||||
current.brush.build(editSession, target, current.material, current.size);
|
current.brush.build(editSession, target, current.material, current.size);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached."); // Never happens
|
player.printError("Max blocks change limit reached."); // Never happens
|
||||||
@ -418,6 +419,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
}
|
}
|
||||||
case OUTLINE: {
|
case OUTLINE: {
|
||||||
BrushSettings current = getContext();
|
BrushSettings current = getContext();
|
||||||
|
new PatternTraverser(current).reset(editSession);
|
||||||
current.brush.build(editSession, position, current.material, current.size);
|
current.brush.build(editSession, position, current.material, current.size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.WorldVector;
|
||||||
import com.sk89q.worldedit.command.tool.BlockTool;
|
import com.sk89q.worldedit.command.tool.BlockTool;
|
||||||
|
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||||
import com.sk89q.worldedit.command.tool.DoubleActionBlockTool;
|
import com.sk89q.worldedit.command.tool.DoubleActionBlockTool;
|
||||||
import com.sk89q.worldedit.command.tool.DoubleActionTraceTool;
|
import com.sk89q.worldedit.command.tool.DoubleActionTraceTool;
|
||||||
import com.sk89q.worldedit.command.tool.Tool;
|
import com.sk89q.worldedit.command.tool.Tool;
|
||||||
@ -438,8 +439,12 @@ public class PlatformManager {
|
|||||||
fp.runAction(new Runnable() {
|
fp.runAction(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (tool instanceof BrushTool) {
|
||||||
|
((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
|
||||||
|
} else {
|
||||||
reset((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
|
reset((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, true, true);
|
}, true, true);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user