geforkt von Mirrors/FastAsyncWorldEdit
Changed instances of Pattern, Mask, etc. to newer versions.
Most affected is the brush code.
Dieser Commit ist enthalten in:
Ursprung
9381beb417
Commit
d96d3cf8bc
@ -57,7 +57,6 @@ import com.sk89q.worldedit.history.changeset.ChangeSet;
|
|||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
||||||
import com.sk89q.worldedit.masks.Mask;
|
|
||||||
import com.sk89q.worldedit.math.interpolation.Interpolation;
|
import com.sk89q.worldedit.math.interpolation.Interpolation;
|
||||||
import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation;
|
import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation;
|
||||||
import com.sk89q.worldedit.math.interpolation.Node;
|
import com.sk89q.worldedit.math.interpolation.Node;
|
||||||
@ -275,7 +274,6 @@ public class EditSession implements Extent {
|
|||||||
*
|
*
|
||||||
* @return mask, may be null
|
* @return mask, may be null
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public Mask getMask() {
|
public Mask getMask() {
|
||||||
return oldMask;
|
return oldMask;
|
||||||
}
|
}
|
||||||
@ -285,13 +283,24 @@ public class EditSession implements Extent {
|
|||||||
*
|
*
|
||||||
* @param mask mask or null
|
* @param mask mask or null
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void setMask(Mask mask) {
|
public void setMask(Mask mask) {
|
||||||
this.oldMask = mask;
|
this.oldMask = mask;
|
||||||
if (mask == null) {
|
if (mask == null) {
|
||||||
maskingExtent.setMask(Masks.alwaysTrue());
|
maskingExtent.setMask(Masks.alwaysTrue());
|
||||||
} else {
|
} else {
|
||||||
maskingExtent.setMask(Masks.wrap(mask, this));
|
maskingExtent.setMask(mask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #setMask(Mask)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public void setMask(com.sk89q.worldedit.masks.Mask mask) {
|
||||||
|
if (mask == null) {
|
||||||
|
setMask((Mask) null);
|
||||||
|
} else {
|
||||||
|
setMask(Masks.wrap(mask));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,7 +795,7 @@ public class EditSession implements Extent {
|
|||||||
checkNotNull(position);
|
checkNotNull(position);
|
||||||
checkArgument(apothem >= 1, "apothem >= 1");
|
checkArgument(apothem >= 1, "apothem >= 1");
|
||||||
|
|
||||||
Mask mask = new com.sk89q.worldedit.masks.FuzzyBlockMask(new BaseBlock(blockType, -1));
|
Mask mask = new FuzzyBlockMask(this, new BaseBlock(blockType, -1));
|
||||||
Vector adjustment = new Vector(1, 1, 1).multiply(apothem - 1);
|
Vector adjustment = new Vector(1, 1, 1).multiply(apothem - 1);
|
||||||
Region region = new CuboidRegion(
|
Region region = new CuboidRegion(
|
||||||
getWorld(), // Causes clamping of Y range
|
getWorld(), // Causes clamping of Y range
|
||||||
@ -855,7 +864,7 @@ public class EditSession implements Extent {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
|
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
Mask mask = filter == null ? new com.sk89q.worldedit.masks.ExistingBlockMask() : new com.sk89q.worldedit.masks.FuzzyBlockMask(filter);
|
Mask mask = filter == null ? new ExistingBlockMask(this) : new FuzzyBlockMask(this, filter);
|
||||||
return replaceBlocks(region, mask, pattern);
|
return replaceBlocks(region, mask, pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -876,7 +885,7 @@ public class EditSession implements Extent {
|
|||||||
checkNotNull(pattern);
|
checkNotNull(pattern);
|
||||||
|
|
||||||
BlockReplace replace = new BlockReplace(this, Patterns.wrap(pattern));
|
BlockReplace replace = new BlockReplace(this, Patterns.wrap(pattern));
|
||||||
RegionMaskingFilter filter = new RegionMaskingFilter(Masks.wrap(mask, this), replace);
|
RegionMaskingFilter filter = new RegionMaskingFilter(mask, replace);
|
||||||
RegionVisitor visitor = new RegionVisitor(region, filter);
|
RegionVisitor visitor = new RegionVisitor(region, filter);
|
||||||
Operations.completeLegacy(visitor);
|
Operations.completeLegacy(visitor);
|
||||||
return visitor.getAffected();
|
return visitor.getAffected();
|
||||||
|
@ -26,9 +26,9 @@ import com.sk89q.minecraft.util.commands.Logging;
|
|||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.masks.BiomeTypeMask;
|
import com.sk89q.worldedit.masks.BiomeTypeMask;
|
||||||
import com.sk89q.worldedit.masks.InvertedMask;
|
import com.sk89q.worldedit.masks.InvertedMask;
|
||||||
import com.sk89q.worldedit.masks.Mask;
|
|
||||||
import com.sk89q.worldedit.regions.FlatRegion;
|
import com.sk89q.worldedit.regions.FlatRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
@ -22,46 +22,42 @@ package com.sk89q.worldedit.command;
|
|||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.worldedit.CuboidClipboard;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
|
||||||
import com.sk89q.worldedit.LocalWorld.KillFlags;
|
import com.sk89q.worldedit.LocalWorld.KillFlags;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
import com.sk89q.worldedit.command.UtilityCommands.FlagContainer;
|
import com.sk89q.worldedit.command.UtilityCommands.FlagContainer;
|
||||||
import com.sk89q.worldedit.masks.BlockMask;
|
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
|
||||||
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
|
||||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||||
import com.sk89q.worldedit.command.tool.brush.ButcherBrush;
|
import com.sk89q.worldedit.command.tool.brush.*;
|
||||||
import com.sk89q.worldedit.command.tool.brush.ClipboardBrush;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.command.tool.brush.CylinderBrush;
|
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||||
import com.sk89q.worldedit.command.tool.brush.GravityBrush;
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
import com.sk89q.worldedit.command.tool.brush.HollowCylinderBrush;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.command.tool.brush.HollowSphereBrush;
|
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||||
import com.sk89q.worldedit.command.tool.brush.SmoothBrush;
|
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||||
import com.sk89q.worldedit.command.tool.brush.SphereBrush;
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Brush shape commands.
|
* Commands to set brush shape.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class BrushCommands {
|
public class BrushCommands {
|
||||||
private final WorldEdit we;
|
|
||||||
|
private final WorldEdit worldEdit;
|
||||||
public BrushCommands(WorldEdit we) {
|
|
||||||
this.we = we;
|
/**
|
||||||
|
* Create a new instance.
|
||||||
|
*
|
||||||
|
* @param worldEdit reference to WorldEdit
|
||||||
|
*/
|
||||||
|
public BrushCommands(WorldEdit worldEdit) {
|
||||||
|
checkNotNull(worldEdit);
|
||||||
|
this.worldEdit = worldEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "sphere", "s" },
|
aliases = { "sphere", "s" },
|
||||||
usage = "<block> [radius]",
|
usage = "<pattern> [radius]",
|
||||||
flags = "h",
|
flags = "h",
|
||||||
desc = "Choose the sphere brush",
|
desc = "Choose the sphere brush",
|
||||||
help =
|
help =
|
||||||
@ -71,25 +67,21 @@ public class BrushCommands {
|
|||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.sphere")
|
@CommandPermissions("worldedit.brush.sphere")
|
||||||
public void sphereBrush(CommandContext args, LocalSession session,
|
public void sphereBrush(Player player, LocalSession session, EditSession editSession, Pattern fill,
|
||||||
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
@Optional("2") double radius, @Switch('h') boolean hollow) throws WorldEditException {
|
||||||
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
double radius = args.argsLength() > 1 ? args.getDouble(1) : 2;
|
|
||||||
we.checkMaxBrushRadius(radius);
|
|
||||||
|
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
Pattern fill = we.getBlockPattern(player, args.getString(0));
|
|
||||||
tool.setFill(fill);
|
tool.setFill(fill);
|
||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
|
|
||||||
if (args.hasFlag('h')) {
|
if (hollow) {
|
||||||
tool.setBrush(new HollowSphereBrush(), "worldedit.brush.sphere");
|
tool.setBrush(new HollowSphereBrush(), "worldedit.brush.sphere");
|
||||||
} else {
|
} else {
|
||||||
tool.setBrush(new SphereBrush(), "worldedit.brush.sphere");
|
tool.setBrush(new SphereBrush(), "worldedit.brush.sphere");
|
||||||
}
|
}
|
||||||
|
|
||||||
player.print(String.format("Sphere brush shape equipped (%.0f).",
|
player.print(String.format("Sphere brush shape equipped (%.0f).", radius));
|
||||||
radius));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -104,28 +96,22 @@ public class BrushCommands {
|
|||||||
max = 3
|
max = 3
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.cylinder")
|
@CommandPermissions("worldedit.brush.cylinder")
|
||||||
public void cylinderBrush(CommandContext args, LocalSession session,
|
public void cylinderBrush(Player player, LocalSession session, EditSession editSession, Pattern fill,
|
||||||
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
@Optional("2") double radius, @Optional("1") int height, @Switch('h') boolean hollow) throws WorldEditException {
|
||||||
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
double radius = args.argsLength() > 1 ? args.getDouble(1) : 2;
|
worldEdit.checkMaxBrushRadius(height);
|
||||||
we.checkMaxBrushRadius(radius);
|
|
||||||
|
|
||||||
int height = args.argsLength() > 2 ? args.getInteger(2) : 1;
|
|
||||||
we.checkMaxBrushRadius(height);
|
|
||||||
|
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
Pattern fill = we.getBlockPattern(player, args.getString(0));
|
|
||||||
tool.setFill(fill);
|
tool.setFill(fill);
|
||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
|
|
||||||
if (args.hasFlag('h')) {
|
if (hollow) {
|
||||||
tool.setBrush(new HollowCylinderBrush(height), "worldedit.brush.cylinder");
|
tool.setBrush(new HollowCylinderBrush(height), "worldedit.brush.cylinder");
|
||||||
} else {
|
} else {
|
||||||
tool.setBrush(new CylinderBrush(height), "worldedit.brush.cylinder");
|
tool.setBrush(new CylinderBrush(height), "worldedit.brush.cylinder");
|
||||||
}
|
}
|
||||||
|
|
||||||
player.print(String.format("Cylinder brush shape equipped (%.0f by %d).",
|
player.print(String.format("Cylinder brush shape equipped (%.0f by %d).", radius, height));
|
||||||
radius, height));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -140,8 +126,7 @@ public class BrushCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.clipboard")
|
@CommandPermissions("worldedit.brush.clipboard")
|
||||||
public void clipboardBrush(CommandContext args, LocalSession session,
|
public void clipboardBrush(Player player, LocalSession session, EditSession editSession, @Switch('a') boolean ignoreAir) throws WorldEditException {
|
||||||
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
|
||||||
|
|
||||||
CuboidClipboard clipboard = session.getClipboard();
|
CuboidClipboard clipboard = session.getClipboard();
|
||||||
|
|
||||||
@ -152,12 +137,12 @@ public class BrushCommands {
|
|||||||
|
|
||||||
Vector size = clipboard.getSize();
|
Vector size = clipboard.getSize();
|
||||||
|
|
||||||
we.checkMaxBrushRadius(size.getBlockX());
|
worldEdit.checkMaxBrushRadius(size.getBlockX());
|
||||||
we.checkMaxBrushRadius(size.getBlockY());
|
worldEdit.checkMaxBrushRadius(size.getBlockY());
|
||||||
we.checkMaxBrushRadius(size.getBlockZ());
|
worldEdit.checkMaxBrushRadius(size.getBlockZ());
|
||||||
|
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
tool.setBrush(new ClipboardBrush(clipboard, args.hasFlag('a')), "worldedit.brush.clipboard");
|
tool.setBrush(new ClipboardBrush(clipboard, ignoreAir), "worldedit.brush.clipboard");
|
||||||
|
|
||||||
player.print("Clipboard brush shape equipped.");
|
player.print("Clipboard brush shape equipped.");
|
||||||
}
|
}
|
||||||
@ -169,24 +154,20 @@ public class BrushCommands {
|
|||||||
desc = "Choose the terrain softener brush",
|
desc = "Choose the terrain softener brush",
|
||||||
help =
|
help =
|
||||||
"Chooses the terrain softener brush.\n" +
|
"Chooses the terrain softener brush.\n" +
|
||||||
"The -n flag makes it only consider naturally occuring blocks.",
|
"The -n flag makes it only consider naturally occurring blocks.",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.smooth")
|
@CommandPermissions("worldedit.brush.smooth")
|
||||||
public void smoothBrush(CommandContext args, LocalSession session,
|
public void smoothBrush(Player player, LocalSession session, EditSession editSession,
|
||||||
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
@Optional("2") double radius, @Optional("4") int iterations, @Switch('n') boolean naturalBlocksOnly) throws WorldEditException {
|
||||||
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
double radius = args.argsLength() > 0 ? args.getDouble(0) : 2;
|
|
||||||
we.checkMaxBrushRadius(radius);
|
|
||||||
|
|
||||||
int iterations = args.argsLength() > 1 ? args.getInteger(1) : 4;
|
|
||||||
|
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
tool.setBrush(new SmoothBrush(iterations, args.hasFlag('n')), "worldedit.brush.smooth");
|
tool.setBrush(new SmoothBrush(iterations, naturalBlocksOnly), "worldedit.brush.smooth");
|
||||||
|
|
||||||
player.print(String.format("Smooth brush equipped (%.0f x %dx, using " + (args.hasFlag('n') ? "natural blocks only" : "any block") + ").",
|
player.print(String.format("Smooth brush equipped (%.0f x %dx, using " + (naturalBlocksOnly ? "natural blocks only" : "any block") + ").",
|
||||||
radius, iterations));
|
radius, iterations));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,21 +179,17 @@ public class BrushCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.ex")
|
@CommandPermissions("worldedit.brush.ex")
|
||||||
public void extinguishBrush(CommandContext args, LocalSession session,
|
public void extinguishBrush(Player player, LocalSession session, EditSession editSession, @Optional("5") double radius) throws WorldEditException {
|
||||||
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
|
|
||||||
double radius = args.argsLength() > 1 ? args.getDouble(1) : 5;
|
|
||||||
we.checkMaxBrushRadius(radius);
|
|
||||||
|
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
Pattern fill = new SingleBlockPattern(new BaseBlock(0));
|
Pattern fill = new BlockPattern(new BaseBlock(0));
|
||||||
tool.setFill(fill);
|
tool.setFill(fill);
|
||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
tool.setMask(new BlockMask(new BaseBlock(BlockID.FIRE)));
|
tool.setMask(new BlockMask(editSession, new BaseBlock(BlockID.FIRE)));
|
||||||
tool.setBrush(new SphereBrush(), "worldedit.brush.ex");
|
tool.setBrush(new SphereBrush(), "worldedit.brush.ex");
|
||||||
|
|
||||||
player.print(String.format("Extinguisher equipped (%.0f).",
|
player.print(String.format("Extinguisher equipped (%.0f).", radius));
|
||||||
radius));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -228,15 +205,12 @@ public class BrushCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.gravity")
|
@CommandPermissions("worldedit.brush.gravity")
|
||||||
public void gravityBrush(CommandContext args, LocalSession session,
|
public void gravityBrush(Player player, LocalSession session, EditSession editSession, @Optional("5") double radius, @Switch('h') boolean fromMaxY) throws WorldEditException {
|
||||||
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
|
|
||||||
double radius = args.argsLength() > 0 ? args.getDouble(0) : 5;
|
|
||||||
we.checkMaxBrushRadius(radius);
|
|
||||||
|
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
tool.setBrush(new GravityBrush(args.hasFlag('h')), "worldedit.brush.gravity");
|
tool.setBrush(new GravityBrush(fromMaxY), "worldedit.brush.gravity");
|
||||||
|
|
||||||
player.print(String.format("Gravity brush equipped (%.0f).",
|
player.print(String.format("Gravity brush equipped (%.0f).",
|
||||||
radius));
|
radius));
|
||||||
@ -253,10 +227,9 @@ public class BrushCommands {
|
|||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.butcher")
|
@CommandPermissions("worldedit.brush.butcher")
|
||||||
public void butcherBrush(CommandContext args, LocalSession session,
|
public void butcherBrush(CommandContext args, LocalSession session, Player player, EditSession editSession) throws WorldEditException {
|
||||||
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
|
||||||
|
|
||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = worldEdit.getConfiguration();
|
||||||
|
|
||||||
double radius = args.argsLength() > 0 ? args.getDouble(0) : 5;
|
double radius = args.argsLength() > 0 ? args.getDouble(0) : 5;
|
||||||
double maxRadius = config.maxBrushRadius;
|
double maxRadius = config.maxBrushRadius;
|
||||||
|
@ -23,13 +23,13 @@ import com.sk89q.minecraft.util.commands.Command;
|
|||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.masks.Mask;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tool commands.
|
* Tool commands.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class ToolUtilCommands {
|
public class ToolUtilCommands {
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
||||||
@ -77,13 +77,11 @@ public class ToolUtilCommands {
|
|||||||
max = -1
|
max = -1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.options.mask")
|
@CommandPermissions("worldedit.brush.options.mask")
|
||||||
public void mask(CommandContext args, LocalSession session, LocalPlayer player,
|
public void mask(Player player, LocalSession session, EditSession editSession, @Optional Mask mask) throws WorldEditException {
|
||||||
EditSession editSession) throws WorldEditException {
|
if (mask == null) {
|
||||||
if (args.argsLength() == 0) {
|
|
||||||
session.getBrushTool(player.getItemInHand()).setMask(null);
|
session.getBrushTool(player.getItemInHand()).setMask(null);
|
||||||
player.print("Brush mask disabled.");
|
player.print("Brush mask disabled.");
|
||||||
} else {
|
} else {
|
||||||
Mask mask = we.getBlockMask(player, session, args.getJoinedStrings(0));
|
|
||||||
session.getBrushTool(player.getItemInHand()).setMask(mask);
|
session.getBrushTool(player.getItemInHand()).setMask(mask);
|
||||||
player.print("Brush mask set.");
|
player.print("Brush mask set.");
|
||||||
}
|
}
|
||||||
@ -97,9 +95,7 @@ public class ToolUtilCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.options.material")
|
@CommandPermissions("worldedit.brush.options.material")
|
||||||
public void material(CommandContext args, LocalSession session, LocalPlayer player,
|
public void material(Player player, LocalSession session, EditSession editSession, Pattern pattern) throws WorldEditException {
|
||||||
EditSession editSession) throws WorldEditException {
|
|
||||||
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
|
||||||
session.getBrushTool(player.getItemInHand()).setFill(pattern);
|
session.getBrushTool(player.getItemInHand()).setFill(pattern);
|
||||||
player.print("Brush material set.");
|
player.print("Brush material set.");
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,15 @@ package com.sk89q.worldedit.command.tool;
|
|||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A super pickaxe mode that will remove blocks in an area.
|
* A super pickaxe mode that will remove blocks in an area.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class AreaPickaxe implements BlockTool {
|
public class AreaPickaxe implements BlockTool {
|
||||||
|
|
||||||
private static final BaseBlock air = new BaseBlock(0);
|
private static final BaseBlock air = new BaseBlock(0);
|
||||||
private int range;
|
private int range;
|
||||||
|
|
||||||
@ -36,17 +38,17 @@ public class AreaPickaxe implements BlockTool {
|
|||||||
this.range = range;
|
this.range = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
@Override
|
||||||
|
public boolean canUse(Actor player) {
|
||||||
return player.hasPermission("worldedit.superpickaxe.area");
|
return player.hasPermission("worldedit.superpickaxe.area");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
@Override
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||||
LocalWorld world = clicked.getWorld();
|
|
||||||
int ox = clicked.getBlockX();
|
int ox = clicked.getBlockX();
|
||||||
int oy = clicked.getBlockY();
|
int oy = clicked.getBlockY();
|
||||||
int oz = clicked.getBlockZ();
|
int oz = clicked.getBlockZ();
|
||||||
int initialType = world.getBlockType(clicked);
|
int initialType = clicked.getWorld().getBlockType(clicked.toVector());
|
||||||
|
|
||||||
if (initialType == 0) {
|
if (initialType == 0) {
|
||||||
return true;
|
return true;
|
||||||
@ -68,7 +70,7 @@ public class AreaPickaxe implements BlockTool {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
world.queueBlockBreakEffect(server, pos, initialType, clicked.distanceSq(pos));
|
clicked.getWorld().queueBlockBreakEffect(server, pos, initialType, clicked.toVector().distanceSq(pos));
|
||||||
|
|
||||||
editSession.setBlock(pos, air);
|
editSession.setBlock(pos, air);
|
||||||
}
|
}
|
||||||
@ -83,4 +85,5 @@ public class AreaPickaxe implements BlockTool {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,29 +19,34 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mode that cycles the data values of supported blocks.
|
* A mode that cycles the data values of supported blocks.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class BlockDataCyler implements DoubleActionBlockTool {
|
public class BlockDataCyler implements DoubleActionBlockTool {
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
@Override
|
||||||
|
public boolean canUse(Actor player) {
|
||||||
return player.hasPermission("worldedit.tool.data-cycler");
|
return player.hasPermission("worldedit.tool.data-cycler");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean handleCycle(ServerInterface server, LocalConfiguration config,
|
private boolean handleCycle(Platform server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked, boolean forward) {
|
Player player, LocalSession session, Location clicked, boolean forward) {
|
||||||
|
|
||||||
LocalWorld world = clicked.getWorld();
|
World world = clicked.getWorld();
|
||||||
|
|
||||||
int type = world.getBlockType(clicked);
|
int type = world.getBlockType(clicked.toVector());
|
||||||
int data = world.getBlockData(clicked);
|
int data = world.getBlockData(clicked.toVector());
|
||||||
|
|
||||||
if (config.allowedDataCycleBlocks.size() > 0
|
if (!config.allowedDataCycleBlocks.isEmpty()
|
||||||
&& !player.hasPermission("worldedit.override.data-cycler")
|
&& !player.hasPermission("worldedit.override.data-cycler")
|
||||||
&& !config.allowedDataCycleBlocks.contains(type)) {
|
&& !config.allowedDataCycleBlocks.contains(type)) {
|
||||||
player.printError("You are not permitted to cycle the data value of that block.");
|
player.printError("You are not permitted to cycle the data value of that block.");
|
||||||
@ -54,20 +59,19 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
|||||||
if (data < 0) {
|
if (data < 0) {
|
||||||
player.printError("That block's data cannot be cycled!");
|
player.printError("That block's data cannot be cycled!");
|
||||||
} else {
|
} else {
|
||||||
world.setBlockData(clicked, data);
|
world.setBlockData(clicked.toVector(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
@Override
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||||
return handleCycle(server, config, player, session, clicked, true);
|
return handleCycle(server, config, player, session, clicked, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actSecondary(ServerInterface server,
|
@Override
|
||||||
LocalConfiguration config, LocalPlayer player,
|
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||||
LocalSession session, WorldVector clicked) {
|
|
||||||
return handleCycle(server, config, player, session, clicked, false);
|
return handleCycle(server, config, player, session, clicked, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,37 +20,40 @@
|
|||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockType;
|
import com.sk89q.worldedit.blocks.BlockType;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mode that replaces one block.
|
* A mode that replaces one block.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class BlockReplacer implements DoubleActionBlockTool {
|
public class BlockReplacer implements DoubleActionBlockTool {
|
||||||
|
|
||||||
private BaseBlock targetBlock;
|
private BaseBlock targetBlock;
|
||||||
|
|
||||||
public BlockReplacer(BaseBlock targetBlock) {
|
public BlockReplacer(BaseBlock targetBlock) {
|
||||||
this.targetBlock = targetBlock;
|
this.targetBlock = targetBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
@Override
|
||||||
|
public boolean canUse(Actor player) {
|
||||||
return player.hasPermission("worldedit.tool.replacer");
|
return player.hasPermission("worldedit.tool.replacer");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
@Override
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||||
|
BlockBag bag = session.getBlockBag(player);
|
||||||
|
|
||||||
BlockBag bag = session.getBlockBag(player);
|
World world = clicked.getWorld();
|
||||||
|
|
||||||
LocalWorld world = clicked.getWorld();
|
|
||||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, bag, player);
|
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, bag, player);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
editSession.setBlock(clicked, targetBlock);
|
editSession.setBlock(clicked.toVector(), targetBlock);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException ignored) {
|
||||||
} finally {
|
} finally {
|
||||||
if (bag != null) {
|
if (bag != null) {
|
||||||
bag.flushChanges();
|
bag.flushChanges();
|
||||||
@ -61,13 +64,12 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actSecondary(ServerInterface server,
|
|
||||||
LocalConfiguration config, LocalPlayer player,
|
|
||||||
LocalSession session, WorldVector clicked) {
|
|
||||||
|
|
||||||
LocalWorld world = clicked.getWorld();
|
@Override
|
||||||
|
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||||
|
World world = clicked.getWorld();
|
||||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, player);
|
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, player);
|
||||||
targetBlock = (editSession).getBlock(clicked);
|
targetBlock = (editSession).getBlock(clicked.toVector());
|
||||||
BlockType type = BlockType.fromID(targetBlock.getType());
|
BlockType type = BlockType.fromID(targetBlock.getType());
|
||||||
|
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
|
@ -19,25 +19,13 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a tool that uses a block..
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public interface BlockTool extends Tool {
|
public interface BlockTool extends Tool {
|
||||||
/**
|
|
||||||
* Perform the action. Should return true to deny the default
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked);
|
||||||
* action.
|
|
||||||
*
|
|
||||||
* @param server
|
|
||||||
* @param config
|
|
||||||
* @param player
|
|
||||||
* @param session
|
|
||||||
* @param clicked
|
|
||||||
* @return true to deny
|
|
||||||
*/
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked);
|
|
||||||
}
|
}
|
||||||
|
@ -20,28 +20,30 @@
|
|||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
import com.sk89q.worldedit.masks.CombinedMask;
|
|
||||||
import com.sk89q.worldedit.masks.Mask;
|
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
|
||||||
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
|
||||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||||
import com.sk89q.worldedit.command.tool.brush.SphereBrush;
|
import com.sk89q.worldedit.command.tool.brush.SphereBrush;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
|
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||||
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.session.request.Request;
|
import com.sk89q.worldedit.session.request.Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a shape at the place being looked at.
|
* Builds a shape at the place being looked at.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class BrushTool implements TraceTool {
|
public class BrushTool implements TraceTool {
|
||||||
|
|
||||||
protected static int MAX_RANGE = 500;
|
protected static int MAX_RANGE = 500;
|
||||||
protected int range = -1;
|
protected int range = -1;
|
||||||
private Mask mask = null;
|
private Mask mask = null;
|
||||||
private Brush brush = new SphereBrush();
|
private Brush brush = new SphereBrush();
|
||||||
private Pattern material = new SingleBlockPattern(new BaseBlock(BlockID.COBBLESTONE));
|
private Pattern material = new BlockPattern(new BaseBlock(BlockID.COBBLESTONE));
|
||||||
private double size = 1;
|
private double size = 1;
|
||||||
private String permission;
|
private String permission;
|
||||||
|
|
||||||
@ -54,14 +56,8 @@ public class BrushTool implements TraceTool {
|
|||||||
this.permission = permission;
|
this.permission = permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Checks to see if the player can still be using this tool (considering
|
public boolean canUse(Actor player) {
|
||||||
* permissions and such).
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
|
||||||
return player.hasPermission(permission);
|
return player.hasPermission(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,22 +147,14 @@ public class BrushTool implements TraceTool {
|
|||||||
/**
|
/**
|
||||||
* Set the set brush range.
|
* Set the set brush range.
|
||||||
*
|
*
|
||||||
* @param size
|
* @param range
|
||||||
*/
|
*/
|
||||||
public void setRange(int range) {
|
public void setRange(int range) {
|
||||||
this.range = range;
|
this.range = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Perform the action. Should return true to deny the default
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||||
* action.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @param session
|
|
||||||
* @return true to deny
|
|
||||||
*/
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
|
||||||
LocalPlayer player, LocalSession session) {
|
|
||||||
WorldVector target = null;
|
WorldVector target = null;
|
||||||
target = player.getBlockTrace(getRange(), true);
|
target = player.getBlockTrace(getRange(), true);
|
||||||
|
|
||||||
@ -180,14 +168,14 @@ public class BrushTool implements TraceTool {
|
|||||||
EditSession editSession = session.createEditSession(player);
|
EditSession editSession = session.createEditSession(player);
|
||||||
Request.request().setEditSession(editSession);
|
Request.request().setEditSession(editSession);
|
||||||
if (mask != null) {
|
if (mask != null) {
|
||||||
mask.prepare(session, player, target);
|
|
||||||
Mask existingMask = editSession.getMask();
|
Mask existingMask = editSession.getMask();
|
||||||
|
|
||||||
if (existingMask == null) {
|
if (existingMask == null) {
|
||||||
editSession.setMask(mask);
|
editSession.setMask(mask);
|
||||||
} else if (existingMask instanceof CombinedMask) {
|
} else if (existingMask instanceof MaskIntersection) {
|
||||||
((CombinedMask) existingMask).add(mask);
|
((MaskIntersection) existingMask).add(mask);
|
||||||
} else {
|
} else {
|
||||||
CombinedMask newMask = new CombinedMask(existingMask);
|
MaskIntersection newMask = new MaskIntersection(existingMask);
|
||||||
newMask.add(mask);
|
newMask.add(mask);
|
||||||
editSession.setMask(newMask);
|
editSession.setMask(newMask);
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,13 @@
|
|||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wand that can be used at a distance.
|
* A wand that can be used at a distance.
|
||||||
*
|
|
||||||
* @author wizjany
|
|
||||||
*/
|
*/
|
||||||
public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
|
public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
|
||||||
|
|
||||||
@ -34,12 +35,12 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canUse(LocalPlayer player) {
|
public boolean canUse(Actor player) {
|
||||||
return player.hasPermission("worldedit.wand");
|
return player.hasPermission("worldedit.wand");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
|
@Override
|
||||||
LocalPlayer player, LocalSession session) {
|
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||||
if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) {
|
if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) {
|
||||||
WorldVector target = getTarget(player);
|
WorldVector target = getTarget(player);
|
||||||
if (target == null) return true;
|
if (target == null) return true;
|
||||||
@ -56,8 +57,7 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||||
LocalPlayer player, LocalSession session) {
|
|
||||||
if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) {
|
if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) {
|
||||||
WorldVector target = getTarget(player);
|
WorldVector target = getTarget(player);
|
||||||
if (target == null) return true;
|
if (target == null) return true;
|
||||||
@ -72,7 +72,7 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldVector getTarget(LocalPlayer player) {
|
public WorldVector getTarget(Player player) {
|
||||||
WorldVector target = null;
|
WorldVector target = null;
|
||||||
if (this.range > -1) {
|
if (this.range > -1) {
|
||||||
target = player.getBlockTrace(getRange(), true);
|
target = player.getBlockTrace(getRange(), true);
|
||||||
|
@ -20,28 +20,16 @@
|
|||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.ServerInterface;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a block tool that also has a secondary/primary function.
|
* Represents a block tool that also has a secondary/primary function.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public interface DoubleActionBlockTool extends BlockTool {
|
public interface DoubleActionBlockTool extends BlockTool {
|
||||||
/**
|
|
||||||
* Perform the secondary action. Should return true to deny the default
|
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked);
|
||||||
* action.
|
|
||||||
*
|
|
||||||
* @param server
|
|
||||||
* @param config
|
|
||||||
* @param player
|
|
||||||
* @param session
|
|
||||||
* @param clicked
|
|
||||||
* @return true to deny
|
|
||||||
*/
|
|
||||||
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
|
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked);
|
|
||||||
}
|
}
|
||||||
|
@ -20,24 +20,15 @@
|
|||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.ServerInterface;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a trace tool that also has a secondary/primary function.
|
* Represents a trace tool that also has a secondary/primary function.
|
||||||
*/
|
*/
|
||||||
public interface DoubleActionTraceTool extends TraceTool {
|
public interface DoubleActionTraceTool extends TraceTool {
|
||||||
/**
|
|
||||||
* Perform the secondary action. Should return true to deny the default
|
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session);
|
||||||
* action.
|
|
||||||
*
|
|
||||||
* @param server
|
|
||||||
* @param config
|
|
||||||
* @param player
|
|
||||||
* @param session
|
|
||||||
* @return true to deny
|
|
||||||
*/
|
|
||||||
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
|
|
||||||
LocalPlayer player, LocalSession session);
|
|
||||||
}
|
}
|
||||||
|
@ -19,18 +19,22 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.Set;
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A pickaxe mode that removes floating treetops (logs and leaves not connected
|
* A pickaxe mode that removes floating treetops (logs and leaves not connected
|
||||||
* to anything else)
|
* to anything else)
|
||||||
*
|
|
||||||
* @author Moo0
|
|
||||||
*/
|
*/
|
||||||
public class FloatingTreeRemover implements BlockTool {
|
public class FloatingTreeRemover implements BlockTool {
|
||||||
private static final BaseBlock AIR = new BaseBlock(BlockID.AIR);
|
private static final BaseBlock AIR = new BaseBlock(BlockID.AIR);
|
||||||
@ -40,16 +44,18 @@ public class FloatingTreeRemover implements BlockTool {
|
|||||||
rangeSq = 100*100;
|
rangeSq = 100*100;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
@Override
|
||||||
|
public boolean canUse(Actor player) {
|
||||||
return player.hasPermission("worldedit.tool.deltree");
|
return player.hasPermission("worldedit.tool.deltree");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
@Override
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config,
|
||||||
|
Player player, LocalSession session, Location clicked) {
|
||||||
|
|
||||||
final LocalWorld world = clicked.getWorld();
|
final World world = clicked.getWorld();
|
||||||
|
|
||||||
switch (world.getBlockType(clicked)) {
|
switch (world.getBlockType(clicked.toVector())) {
|
||||||
case BlockID.LOG:
|
case BlockID.LOG:
|
||||||
case BlockID.LOG2:
|
case BlockID.LOG2:
|
||||||
case BlockID.LEAVES:
|
case BlockID.LEAVES:
|
||||||
@ -67,7 +73,7 @@ public class FloatingTreeRemover implements BlockTool {
|
|||||||
final EditSession editSession = session.createEditSession(player);
|
final EditSession editSession = session.createEditSession(player);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Set<Vector> blockSet = bfs(world, clicked);
|
final Set<Vector> blockSet = bfs(world, clicked.toVector());
|
||||||
if (blockSet == null) {
|
if (blockSet == null) {
|
||||||
player.printError("That's not a floating tree.");
|
player.printError("That's not a floating tree.");
|
||||||
return true;
|
return true;
|
||||||
@ -111,7 +117,7 @@ public class FloatingTreeRemover implements BlockTool {
|
|||||||
* @param origin any point contained in the floating tree
|
* @param origin any point contained in the floating tree
|
||||||
* @return a set containing all blocks in the tree/shroom or null if this is not a floating tree/shroom.
|
* @return a set containing all blocks in the tree/shroom or null if this is not a floating tree/shroom.
|
||||||
*/
|
*/
|
||||||
private Set<Vector> bfs(LocalWorld world, Vector origin) throws MaxChangedBlocksException {
|
private Set<Vector> bfs(World world, Vector origin) throws MaxChangedBlocksException {
|
||||||
final Set<Vector> visited = new HashSet<Vector>();
|
final Set<Vector> visited = new HashSet<Vector>();
|
||||||
final LinkedList<Vector> queue = new LinkedList<Vector>();
|
final LinkedList<Vector> queue = new LinkedList<Vector>();
|
||||||
|
|
||||||
|
@ -19,18 +19,23 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A tool that flood fills blocks.
|
* A tool that flood fills blocks.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class FloodFillTool implements BlockTool {
|
public class FloodFillTool implements BlockTool {
|
||||||
|
|
||||||
private int range;
|
private int range;
|
||||||
private Pattern pattern;
|
private Pattern pattern;
|
||||||
|
|
||||||
@ -39,15 +44,16 @@ public class FloodFillTool implements BlockTool {
|
|||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
@Override
|
||||||
|
public boolean canUse(Actor player) {
|
||||||
return player.hasPermission("worldedit.tool.flood-fill");
|
return player.hasPermission("worldedit.tool.flood-fill");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
@Override
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||||
LocalWorld world = clicked.getWorld();
|
World world = clicked.getWorld();
|
||||||
|
|
||||||
int initialType = world.getBlockType(clicked);
|
int initialType = world.getBlockType(clicked.toVector());
|
||||||
|
|
||||||
if (initialType == BlockID.AIR) {
|
if (initialType == BlockID.AIR) {
|
||||||
return true;
|
return true;
|
||||||
@ -60,8 +66,8 @@ public class FloodFillTool implements BlockTool {
|
|||||||
EditSession editSession = session.createEditSession(player);
|
EditSession editSession = session.createEditSession(player);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
recurse(server, editSession, world, clicked.toBlockVector(),
|
recurse(server, editSession, world, clicked.toVector().toBlockVector(),
|
||||||
clicked, range, initialType, new HashSet<BlockVector>());
|
clicked.toVector(), range, initialType, new HashSet<BlockVector>());
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
} finally {
|
} finally {
|
||||||
@ -71,23 +77,8 @@ public class FloodFillTool implements BlockTool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void recurse(Platform server, EditSession editSession, World world, BlockVector pos, Vector origin, int size, int initialType,
|
||||||
* Helper method.
|
Set<BlockVector> visited) throws MaxChangedBlocksException {
|
||||||
*
|
|
||||||
* @param server
|
|
||||||
* @param superPickaxeManyDrop
|
|
||||||
* @param world
|
|
||||||
* @param pos
|
|
||||||
* @param origin
|
|
||||||
* @param size
|
|
||||||
* @param initialType
|
|
||||||
* @param visited
|
|
||||||
*/
|
|
||||||
private void recurse(ServerInterface server, EditSession editSession,
|
|
||||||
LocalWorld world, BlockVector pos,
|
|
||||||
Vector origin, int size, int initialType,
|
|
||||||
Set<BlockVector> visited)
|
|
||||||
throws MaxChangedBlocksException {
|
|
||||||
|
|
||||||
if (origin.distance(pos) > size || visited.contains(pos)) {
|
if (origin.distance(pos) > size || visited.contains(pos)) {
|
||||||
return;
|
return;
|
||||||
|
@ -22,11 +22,12 @@ package com.sk89q.worldedit.command.tool;
|
|||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A tool that can place (or remove) blocks at a distance.
|
* A tool that can place (or remove) blocks at a distance.
|
||||||
*
|
|
||||||
* @author wizjany
|
|
||||||
*/
|
*/
|
||||||
public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTool {
|
public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTool {
|
||||||
|
|
||||||
@ -40,13 +41,12 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canUse(LocalPlayer player) {
|
public boolean canUse(Actor player) {
|
||||||
return player.hasPermission("worldedit.tool.lrbuild");
|
return player.hasPermission("worldedit.tool.lrbuild");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
|
@Override
|
||||||
LocalPlayer player, LocalSession session) {
|
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||||
|
|
||||||
WorldVectorFace pos = getTargetFace(player);
|
WorldVectorFace pos = getTargetFace(player);
|
||||||
if (pos == null) return false;
|
if (pos == null) return false;
|
||||||
EditSession eS = session.createEditSession(player);
|
EditSession eS = session.createEditSession(player);
|
||||||
@ -65,9 +65,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||||
LocalPlayer player, LocalSession session) {
|
|
||||||
|
|
||||||
WorldVectorFace pos = getTargetFace(player);
|
WorldVectorFace pos = getTargetFace(player);
|
||||||
if (pos == null) return false;
|
if (pos == null) return false;
|
||||||
EditSession eS = session.createEditSession(player);
|
EditSession eS = session.createEditSession(player);
|
||||||
@ -84,7 +82,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldVectorFace getTargetFace(LocalPlayer player) {
|
public WorldVectorFace getTargetFace(Player player) {
|
||||||
WorldVectorFace target = null;
|
WorldVectorFace target = null;
|
||||||
target = player.getBlockTraceFace(getRange(), true);
|
target = player.getBlockTraceFace(getRange(), true);
|
||||||
|
|
||||||
@ -95,4 +93,5 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,33 +19,39 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.blocks.*;
|
import com.sk89q.worldedit.blocks.*;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plants a tree.
|
* Looks up information about a block.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class QueryTool implements BlockTool {
|
public class QueryTool implements BlockTool {
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
@Override
|
||||||
|
public boolean canUse(Actor player) {
|
||||||
return player.hasPermission("worldedit.tool.info");
|
return player.hasPermission("worldedit.tool.info");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
@Override
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||||
|
|
||||||
LocalWorld world = clicked.getWorld();
|
World world = clicked.getWorld();
|
||||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, 0, player);
|
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, 0, player);
|
||||||
BaseBlock block = (editSession).rawGetBlock(clicked);
|
BaseBlock block = (editSession).rawGetBlock(clicked.toVector());
|
||||||
BlockType type = BlockType.fromID(block.getType());
|
BlockType type = BlockType.fromID(block.getType());
|
||||||
|
|
||||||
player.print("\u00A79@" + clicked + ": " + "\u00A7e"
|
player.print("\u00A79@" + clicked.toVector() + ": " + "\u00A7e"
|
||||||
+ "#" + block.getType() + "\u00A77" + " ("
|
+ "#" + block.getType() + "\u00A77" + " ("
|
||||||
+ (type == null ? "Unknown" : type.getName()) + ") "
|
+ (type == null ? "Unknown" : type.getName()) + ") "
|
||||||
+ "\u00A7f"
|
+ "\u00A7f"
|
||||||
+ "[" + block.getData() + "]" + " (" + world.getBlockLightLevel(clicked) + "/" + world.getBlockLightLevel(clicked.add(0, 1, 0)) + ")");
|
+ "[" + block.getData() + "]" + " (" + world.getBlockLightLevel(clicked.toVector()) + "/" + world.getBlockLightLevel(clicked.toVector().add(0, 1, 0)) + ")");
|
||||||
|
|
||||||
if (block instanceof MobSpawnerBlock) {
|
if (block instanceof MobSpawnerBlock) {
|
||||||
player.printRaw("\u00A7e" + "Mob Type: "
|
player.printRaw("\u00A7e" + "Mob Type: "
|
||||||
|
@ -22,6 +22,10 @@ package com.sk89q.worldedit.command.tool;
|
|||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -29,10 +33,9 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* A pickaxe mode that recursively finds adjacent blocks within range of
|
* A pickaxe mode that recursively finds adjacent blocks within range of
|
||||||
* an initial block and of the same type.
|
* an initial block and of the same type.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class RecursivePickaxe implements BlockTool {
|
public class RecursivePickaxe implements BlockTool {
|
||||||
|
|
||||||
private static final BaseBlock air = new BaseBlock(0);
|
private static final BaseBlock air = new BaseBlock(0);
|
||||||
private double range;
|
private double range;
|
||||||
|
|
||||||
@ -40,15 +43,16 @@ public class RecursivePickaxe implements BlockTool {
|
|||||||
this.range = range;
|
this.range = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
@Override
|
||||||
|
public boolean canUse(Actor player) {
|
||||||
return player.hasPermission("worldedit.superpickaxe.recursive");
|
return player.hasPermission("worldedit.superpickaxe.recursive");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
@Override
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||||
LocalWorld world = clicked.getWorld();
|
World world = clicked.getWorld();
|
||||||
|
|
||||||
int initialType = world.getBlockType(clicked);
|
int initialType = world.getBlockType(clicked.toVector());
|
||||||
|
|
||||||
if (initialType == BlockID.AIR) {
|
if (initialType == BlockID.AIR) {
|
||||||
return true;
|
return true;
|
||||||
@ -62,8 +66,8 @@ public class RecursivePickaxe implements BlockTool {
|
|||||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
recurse(server, editSession, world, clicked.toBlockVector(),
|
recurse(server, editSession, world, clicked.toVector().toBlockVector(),
|
||||||
clicked, range, initialType, new HashSet<BlockVector>());
|
clicked.toVector(), range, initialType, new HashSet<BlockVector>());
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
} finally {
|
} finally {
|
||||||
@ -74,22 +78,8 @@ public class RecursivePickaxe implements BlockTool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static void recurse(Platform server, EditSession editSession, World world, BlockVector pos,
|
||||||
* Helper method.
|
Vector origin, double size, int initialType, Set<BlockVector> visited) throws MaxChangedBlocksException {
|
||||||
*
|
|
||||||
* @param server
|
|
||||||
* @param world
|
|
||||||
* @param pos
|
|
||||||
* @param origin
|
|
||||||
* @param size
|
|
||||||
* @param initialType
|
|
||||||
* @param visited
|
|
||||||
*/
|
|
||||||
private static void recurse(ServerInterface server, EditSession editSession,
|
|
||||||
LocalWorld world, BlockVector pos,
|
|
||||||
Vector origin, double size, int initialType,
|
|
||||||
Set<BlockVector> visited)
|
|
||||||
throws MaxChangedBlocksException {
|
|
||||||
|
|
||||||
final double distanceSq = origin.distanceSq(pos);
|
final double distanceSq = origin.distanceSq(pos);
|
||||||
if (distanceSq > size*size || visited.contains(pos)) {
|
if (distanceSq > size*size || visited.contains(pos)) {
|
||||||
|
@ -19,26 +19,31 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A super pickaxe mode that removes one block.
|
* A super pickaxe mode that removes one block.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class SinglePickaxe implements BlockTool {
|
public class SinglePickaxe implements BlockTool {
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
@Override
|
||||||
|
public boolean canUse(Actor player) {
|
||||||
return player.hasPermission("worldedit.superpickaxe");
|
return player.hasPermission("worldedit.superpickaxe");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
@Override
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||||
LocalWorld world = clicked.getWorld();
|
World world = clicked.getWorld();
|
||||||
|
final int blockType = world.getBlockType(clicked.toVector());
|
||||||
final int blockType = world.getBlockType(clicked);
|
|
||||||
if (blockType == BlockID.BEDROCK
|
if (blockType == BlockID.BEDROCK
|
||||||
&& !player.canDestroyBedrock()) {
|
&& !player.canDestroyBedrock()) {
|
||||||
return true;
|
return true;
|
||||||
@ -48,14 +53,14 @@ public class SinglePickaxe implements BlockTool {
|
|||||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
|
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
editSession.setBlock(clicked, new BaseBlock(BlockID.AIR));
|
editSession.setBlock(clicked.toVector(), new BaseBlock(BlockID.AIR));
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
} finally {
|
} finally {
|
||||||
editSession.flushQueue();
|
editSession.flushQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
world.playEffect(clicked, 2001, blockType);
|
world.playEffect(clicked.toVector(), 2001, blockType);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -19,23 +19,21 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a tool. This interface alone defines nothing. A tool also
|
* Represents a tool. This interface alone defines nothing. A tool also
|
||||||
* has to implement <code>BlockTool</code> or <code>TraceTool</code>.
|
* has to implement <code>BlockTool</code> or <code>TraceTool</code>.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public abstract interface Tool {
|
public interface Tool {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if the player can still be using this tool (considering
|
* Checks to see if the player can still be using this tool (considering
|
||||||
* permissions and such).
|
* permissions and such).
|
||||||
*
|
*
|
||||||
* @param player
|
* @param actor the actor
|
||||||
* @return
|
* @return true if use is permitted
|
||||||
*/
|
*/
|
||||||
public boolean canUse(LocalPlayer player);
|
public boolean canUse(Actor actor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,26 +20,11 @@
|
|||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.ServerInterface;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a tool that does not require a block.
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public interface TraceTool extends Tool {
|
public interface TraceTool extends Tool {
|
||||||
/**
|
|
||||||
* Perform the action. Should return true to deny the default
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session);
|
||||||
* action.
|
|
||||||
*
|
|
||||||
* @param server
|
|
||||||
* @param config
|
|
||||||
* @param player
|
|
||||||
* @param session
|
|
||||||
* @return true to deny
|
|
||||||
*/
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
|
||||||
LocalPlayer player, LocalSession session);
|
|
||||||
}
|
}
|
||||||
|
@ -20,26 +20,30 @@
|
|||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.util.*;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plants a tree.
|
* Plants a tree.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class TreePlanter implements BlockTool {
|
public class TreePlanter implements BlockTool {
|
||||||
|
|
||||||
private TreeGenerator gen;
|
private TreeGenerator gen;
|
||||||
|
|
||||||
public TreePlanter(TreeGenerator gen) {
|
public TreePlanter(TreeGenerator gen) {
|
||||||
this.gen = gen;
|
this.gen = gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
@Override
|
||||||
|
public boolean canUse(Actor player) {
|
||||||
return player.hasPermission("worldedit.tool.tree");
|
return player.hasPermission("worldedit.tool.tree");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
@Override
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||||
|
|
||||||
EditSession editSession = session.createEditSession(player);
|
EditSession editSession = session.createEditSession(player);
|
||||||
|
|
||||||
@ -47,7 +51,7 @@ public class TreePlanter implements BlockTool {
|
|||||||
boolean successful = false;
|
boolean successful = false;
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
if (gen.generate(editSession, clicked.add(0, 1, 0))) {
|
if (gen.generate(editSession, clicked.toVector().add(0, 1, 0))) {
|
||||||
successful = true;
|
successful = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a brush.
|
* Represents a brush.
|
||||||
@ -39,6 +39,5 @@ public interface Brush {
|
|||||||
* @param size
|
* @param size
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException;
|
||||||
throws MaxChangedBlocksException;
|
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,10 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
|
||||||
public class ButcherBrush implements Brush {
|
public class ButcherBrush implements Brush {
|
||||||
|
|
||||||
private int flags;
|
private int flags;
|
||||||
|
|
||||||
public ButcherBrush(int flags) {
|
public ButcherBrush(int flags) {
|
||||||
@ -32,8 +33,7 @@ public class ButcherBrush implements Brush {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
|
||||||
throws MaxChangedBlocksException {
|
|
||||||
editSession.getWorld().killMobs(pos, size, flags);
|
editSession.getWorld().killMobs(pos, size, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,9 +23,10 @@ import com.sk89q.worldedit.CuboidClipboard;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
|
||||||
public class ClipboardBrush implements Brush {
|
public class ClipboardBrush implements Brush {
|
||||||
|
|
||||||
private CuboidClipboard clipboard;
|
private CuboidClipboard clipboard;
|
||||||
private boolean noAir;
|
private boolean noAir;
|
||||||
|
|
||||||
@ -34,8 +35,8 @@ public class ClipboardBrush implements Brush {
|
|||||||
this.noAir = noAir;
|
this.noAir = noAir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
|
||||||
throws MaxChangedBlocksException {
|
|
||||||
clipboard.place(editSession, pos.subtract(clipboard.getSize().divide(2)), noAir);
|
clipboard.place(editSession, pos.subtract(clipboard.getSize().divide(2)), noAir);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,17 +22,19 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||||
|
|
||||||
public class CylinderBrush implements Brush {
|
public class CylinderBrush implements Brush {
|
||||||
|
|
||||||
private int height;
|
private int height;
|
||||||
|
|
||||||
public CylinderBrush(int height) {
|
public CylinderBrush(int height) {
|
||||||
this.height = height;
|
this.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
|
||||||
throws MaxChangedBlocksException {
|
editSession.makeCylinder(pos, Patterns.wrap(mat), size, size, height, true);
|
||||||
editSession.makeCylinder(pos, mat, size, size, height, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,12 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
|||||||
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.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author zml2008
|
|
||||||
*/
|
|
||||||
public class GravityBrush implements Brush {
|
public class GravityBrush implements Brush {
|
||||||
|
|
||||||
private final boolean fullHeight;
|
private final boolean fullHeight;
|
||||||
|
|
||||||
public GravityBrush(boolean fullHeight) {
|
public GravityBrush(boolean fullHeight) {
|
||||||
@ -65,4 +63,5 @@ public class GravityBrush implements Brush {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,17 +22,20 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||||
|
|
||||||
public class HollowCylinderBrush implements Brush {
|
public class HollowCylinderBrush implements Brush {
|
||||||
|
|
||||||
private int height;
|
private int height;
|
||||||
|
|
||||||
public HollowCylinderBrush(int height) {
|
public HollowCylinderBrush(int height) {
|
||||||
this.height = height;
|
this.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
@Override
|
||||||
throws MaxChangedBlocksException {
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
|
||||||
editSession.makeCylinder(pos, mat, size, size, height, false);
|
editSession.makeCylinder(pos, Patterns.wrap(mat), size, size, height, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,13 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||||
|
|
||||||
public class HollowSphereBrush implements Brush {
|
public class HollowSphereBrush implements Brush {
|
||||||
public HollowSphereBrush() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
@Override
|
||||||
throws MaxChangedBlocksException {
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
|
||||||
editSession.makeSphere(pos, mat, size, size, size, false);
|
editSession.makeSphere(pos, Patterns.wrap(mat), size, size, size, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package com.sk89q.worldedit.command.tool.brush;
|
package com.sk89q.worldedit.command.tool.brush;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.internal.LocalWorldAdapter;
|
import com.sk89q.worldedit.internal.LocalWorldAdapter;
|
||||||
import com.sk89q.worldedit.math.convolution.HeightMap;
|
import com.sk89q.worldedit.math.convolution.HeightMap;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
@ -27,11 +28,11 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.WorldVector;
|
||||||
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
||||||
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
public class SmoothBrush implements Brush {
|
public class SmoothBrush implements Brush {
|
||||||
|
|
||||||
private int iterations;
|
private int iterations;
|
||||||
private boolean naturalOnly;
|
private boolean naturalOnly;
|
||||||
|
|
||||||
@ -53,4 +54,5 @@ public class SmoothBrush implements Brush {
|
|||||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
||||||
heightMap.applyFilter(filter, iterations);
|
heightMap.applyFilter(filter, iterations);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,13 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||||
|
|
||||||
public class SphereBrush implements Brush {
|
public class SphereBrush implements Brush {
|
||||||
public SphereBrush() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
@Override
|
||||||
throws MaxChangedBlocksException {
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
|
||||||
editSession.makeSphere(pos, mat, size, size, size, true);
|
editSession.makeSphere(pos, Patterns.wrap(mat), size, size, size, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,24 +318,19 @@ public class PlatformManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player instanceof LocalPlayer) { // Temporary workaround
|
if (player.isHoldingPickAxe() && session.hasSuperPickAxe()) {
|
||||||
LocalPlayer localPlayer = (LocalPlayer) player;
|
final BlockTool superPickaxe = session.getSuperPickaxe();
|
||||||
WorldVector worldVector = new WorldVector(location);
|
if (superPickaxe != null && superPickaxe.canUse(player)) {
|
||||||
|
event.setCancelled(superPickaxe.actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location));
|
||||||
if (player.isHoldingPickAxe() && session.hasSuperPickAxe()) {
|
return;
|
||||||
final BlockTool superPickaxe = session.getSuperPickaxe();
|
|
||||||
if (superPickaxe != null && superPickaxe.canUse(localPlayer)) {
|
|
||||||
event.setCancelled(superPickaxe.actPrimary(getServerInterface(), getConfiguration(), localPlayer, session, worldVector));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Tool tool = session.getTool(player.getItemInHand());
|
Tool tool = session.getTool(player.getItemInHand());
|
||||||
if (tool != null && tool instanceof DoubleActionBlockTool) {
|
if (tool != null && tool instanceof DoubleActionBlockTool) {
|
||||||
if (tool.canUse(localPlayer)) {
|
if (tool.canUse(player)) {
|
||||||
((DoubleActionBlockTool) tool).actSecondary(getServerInterface(), getConfiguration(), localPlayer, session, worldVector);
|
((DoubleActionBlockTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,16 +353,11 @@ public class PlatformManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player instanceof LocalPlayer) { // Temporary workaround
|
Tool tool = session.getTool(player.getItemInHand());
|
||||||
LocalPlayer localPlayer = (LocalPlayer) player;
|
if (tool != null && tool instanceof BlockTool) {
|
||||||
WorldVector worldVector = new WorldVector(location);
|
if (tool.canUse(player)) {
|
||||||
|
((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
|
||||||
Tool tool = session.getTool(player.getItemInHand());
|
event.setCancelled(true);
|
||||||
if (tool != null && tool instanceof BlockTool) {
|
|
||||||
if (tool.canUse(localPlayer)) {
|
|
||||||
((BlockTool) tool).actPrimary(getServerInterface(), getConfiguration(), localPlayer, session, worldVector);
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -380,6 +370,7 @@ public class PlatformManager {
|
|||||||
// Create a proxy actor with a potentially different world for
|
// Create a proxy actor with a potentially different world for
|
||||||
// making changes to the world
|
// making changes to the world
|
||||||
Player player = createProxyActor(event.getPlayer());
|
Player player = createProxyActor(event.getPlayer());
|
||||||
|
World world = player.getWorld();
|
||||||
|
|
||||||
switch (event.getInputType()) {
|
switch (event.getInputType()) {
|
||||||
case PRIMARY: {
|
case PRIMARY: {
|
||||||
@ -405,16 +396,12 @@ public class PlatformManager {
|
|||||||
|
|
||||||
LocalSession session = worldEdit.getSessionManager().get(player);
|
LocalSession session = worldEdit.getSessionManager().get(player);
|
||||||
|
|
||||||
if (player instanceof LocalPlayer) { // Temporary workaround
|
Tool tool = session.getTool(player.getItemInHand());
|
||||||
LocalPlayer localPlayer = (LocalPlayer) player;
|
if (tool != null && tool instanceof DoubleActionTraceTool) {
|
||||||
|
if (tool.canUse(player)) {
|
||||||
Tool tool = session.getTool(player.getItemInHand());
|
((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session);
|
||||||
if (tool != null && tool instanceof DoubleActionTraceTool) {
|
event.setCancelled(true);
|
||||||
if (tool.canUse(localPlayer)) {
|
return;
|
||||||
((DoubleActionTraceTool) tool).actSecondary(getServerInterface(), getConfiguration(), localPlayer, session);
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,16 +428,12 @@ public class PlatformManager {
|
|||||||
|
|
||||||
LocalSession session = worldEdit.getSessionManager().get(player);
|
LocalSession session = worldEdit.getSessionManager().get(player);
|
||||||
|
|
||||||
if (player instanceof LocalPlayer) { // Temporary workaround
|
Tool tool = session.getTool(player.getItemInHand());
|
||||||
LocalPlayer localPlayer = (LocalPlayer) player;
|
if (tool != null && tool instanceof TraceTool) {
|
||||||
|
if (tool.canUse(player)) {
|
||||||
Tool tool = session.getTool(player.getItemInHand());
|
((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session);
|
||||||
if (tool != null && tool instanceof TraceTool) {
|
event.setCancelled(true);
|
||||||
if (tool.canUse(localPlayer)) {
|
return;
|
||||||
((TraceTool) tool).actPrimary(getServerInterface(), getConfiguration(), localPlayer, session);
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.internal;
|
|||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
@ -250,7 +251,7 @@ public class LocalWorldAdapter extends LocalWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean queueBlockBreakEffect(ServerInterface server, Vector position, int blockId, double priority) {
|
public boolean queueBlockBreakEffect(Platform server, Vector position, int blockId, double priority) {
|
||||||
return world.queueBlockBreakEffect(server, position, blockId, priority);
|
return world.queueBlockBreakEffect(server, position, blockId, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import com.sk89q.worldedit.blocks.BaseBlock;
|
|||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
import com.sk89q.worldedit.blocks.BlockType;
|
import com.sk89q.worldedit.blocks.BlockType;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
@ -219,7 +220,7 @@ public abstract class AbstractWorld implements World {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean queueBlockBreakEffect(ServerInterface server, Vector position, int blockId, double priority) {
|
public boolean queueBlockBreakEffect(Platform server, Vector position, int blockId, double priority) {
|
||||||
if (taskId == -1) {
|
if (taskId == -1) {
|
||||||
taskId = server.schedule(0, 1, new Runnable() {
|
taskId = server.schedule(0, 1, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.world;
|
|||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
@ -342,7 +343,7 @@ public interface World extends Extent {
|
|||||||
* @param priority the priority
|
* @param priority the priority
|
||||||
* @return true if the effect was played
|
* @return true if the effect was played
|
||||||
*/
|
*/
|
||||||
boolean queueBlockBreakEffect(ServerInterface server, Vector position, int blockId, double priority);
|
boolean queueBlockBreakEffect(Platform server, Vector position, int blockId, double priority);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean equals(Object other);
|
boolean equals(Object other);
|
||||||
|
@ -123,7 +123,7 @@ public class SnapshotRestore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkAndAddBlock(Vector pos) {
|
private void checkAndAddBlock(Vector pos) {
|
||||||
if (editSession.getMask() != null && !editSession.getMask().matches(editSession, pos))
|
if (editSession.getMask() != null && !editSession.getMask().test(pos))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BlockVector2D chunkPos = ChunkStore.toChunk(pos);
|
BlockVector2D chunkPos = ChunkStore.toChunk(pos);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren