Added more brush shapes.

Dieser Commit ist enthalten in:
sk89q 2011-01-30 00:34:13 -08:00
Ursprung 5fb442c7c5
Commit 11b00e1165
14 geänderte Dateien mit 482 neuen und 61 gelöschten Zeilen

Datei anzeigen

@ -2,6 +2,18 @@ name: WorldEdit
main: com.sk89q.worldedit.bukkit.WorldEditPlugin
version: "WEVERSIONMACRO"
commands:
/sb:
description: Choose the sphere brush
usage: /<command> [-h] <block> [radius]
aliases: ['/sphereb']
/cb:
description: Choose the cylinder brush
usage: /<command> [-h] <block> [radius] [height]
aliases: ['/cylb']
/cbb:
description: Choose the clipboard brush
usage: /<command> [-a]
aliases: ['/copyb']
chunkinfo:
description: Get information about the chunk that you are inside
usage: /<command>
@ -197,12 +209,12 @@ commands:
cycler:
description: Block data cycler tool
usage: /<command>
brush:
description: Build spheres from far away
usage: /<command> <block> [radius] [no-replace?]
rbrush:
/brush:
description: Build from far away
usage: /<command> [-r]
/rbrush:
description: Brush tool that will only replace blocks
usage: /<command> <block> [radius]
usage: /<command>
recur:
description: Enable the recursive super pickaxe pickaxe mode
usage: /<command> <radius>

Datei anzeigen

@ -268,6 +268,15 @@ public class CuboidClipboard {
}
}
/**
* Get the size of the copy.
*
* @return
*/
public Vector getSize() {
return size;
}
/**
* Saves the clipboard data to a .schematic-format file.
*

Datei anzeigen

@ -23,6 +23,7 @@ import java.util.LinkedList;
import com.sk89q.worldedit.snapshots.Snapshot;
import com.sk89q.worldedit.superpickaxe.SinglePickaxe;
import com.sk89q.worldedit.superpickaxe.SuperPickaxeMode;
import com.sk89q.worldedit.superpickaxe.brushes.BrushShape;
import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.CuboidRegion;
@ -55,6 +56,7 @@ public class LocalSession {
private Snapshot snapshot;
private String lastScript;
private CompassMode compassMode = CompassMode.JUMPTO;
private BrushShape brushShape = null;
/**
* Clear history.
@ -447,4 +449,18 @@ public class LocalSession {
public void setCompassMode(CompassMode compassMode) {
this.compassMode = compassMode;
}
/**
* @return the brushShape
*/
public BrushShape getBrushShape() {
return brushShape;
}
/**
* @param brushShape the brushShape to set
*/
public void setBrushShape(BrushShape brushShape) {
this.brushShape = brushShape;
}
}

Datei anzeigen

@ -97,6 +97,7 @@ public class WorldEdit {
commands.register(SelectionCommands.class);
commands.register(SnapshotCommands.class);
commands.register(SuperPickaxeCommands.class);
commands.register(BrushShapeCommands.class);
commands.register(UtilityCommands.class);
}

Datei anzeigen

@ -0,0 +1,154 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.commands;
import com.sk89q.util.commands.Command;
import com.sk89q.util.commands.CommandContext;
import com.sk89q.worldedit.CuboidClipboard;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
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.superpickaxe.brushes.ClipboardBrushShape;
import com.sk89q.worldedit.superpickaxe.brushes.CylinderBrushShape;
import com.sk89q.worldedit.superpickaxe.brushes.HollowCylinderBrushShape;
import com.sk89q.worldedit.superpickaxe.brushes.SphereBrushShape;
import com.sk89q.worldedit.superpickaxe.brushes.HollowSphereBrushShape;
/**
* Brush shape commands.
*
* @author sk89q
*/
public class BrushShapeCommands {
@Command(
aliases = {"/sb", "/sphereb"},
usage = "<block> [radius]",
flags = "h",
desc = "Choose the sphere brush",
min = 1,
max = 2
)
@CommandPermissions({"worldedit.superpickaxe.drawing.brush.sphere"})
public static void sphereBrush(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
int radius = args.argsLength() > 1 ? args.getInteger(1) : 2;
if (radius > config.maxBrushRadius) {
player.printError("Maximum allowed brush radius: "
+ config.maxBrushRadius);
return;
}
BaseBlock targetBlock = we.getBlock(player, args.getString(0));
if (args.hasFlag('h')) {
session.setBrushShape(new HollowSphereBrushShape(targetBlock, radius));
} else {
session.setBrushShape(new SphereBrushShape(targetBlock, radius));
}
player.print("Sphere brush shape equipped.");
}
@Command(
aliases = {"/cb", "/cylb"},
usage = "<block> [radius] [height]",
flags = "h",
desc = "Choose the cylinder brush",
min = 1,
max = 2
)
@CommandPermissions({"worldedit.superpickaxe.drawing.brush.cylinder"})
public static void cylinderBrush(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
int radius = args.argsLength() > 1 ? args.getInteger(1) : 2;
if (radius > config.maxBrushRadius) {
player.printError("Maximum allowed brush radius: "
+ config.maxBrushRadius);
return;
}
int height = args.argsLength() > 1 ? args.getInteger(1) : 1;
if (height > config.maxBrushRadius) {
player.printError("Maximum allowed brush radius/height: "
+ config.maxBrushRadius);
return;
}
BaseBlock targetBlock = we.getBlock(player, args.getString(0));
if (args.hasFlag('h')) {
session.setBrushShape(new HollowCylinderBrushShape(targetBlock, radius, height));
} else {
session.setBrushShape(new CylinderBrushShape(targetBlock, radius, height));
}
player.print("Cylinder brush shape equipped.");
}
@Command(
aliases = {"/cbb", "/copyb"},
usage = "",
flags = "a",
desc = "Choose the clipboard brush",
min = 0,
max = 0
)
@CommandPermissions({"worldedit.superpickaxe.drawing.brush.clipboard"})
public static void clipboardBrush(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
CuboidClipboard clipboard = session.getClipboard();
if (clipboard == null) {
player.printError("Copy something first.");
return;
}
Vector size = clipboard.getSize();
if (size.getBlockX() > config.maxBrushRadius
|| size.getBlockY() > config.maxBrushRadius
|| size.getBlockZ() > config.maxBrushRadius) {
player.printError("Maximum allowed brush radius/height: "
+ config.maxBrushRadius);
return;
}
session.setBrushShape(new ClipboardBrushShape(clipboard, args.hasFlag('a')));
player.print("Clipboard brush shape equipped.");
}
}

Datei anzeigen

@ -237,61 +237,43 @@ public class SuperPickaxeCommands {
}
@Command(
aliases = {"brush"},
usage = "<block> [radius] [no-replace?]",
desc = "Build spheres from far away",
min = 1,
max = 3
aliases = {"/brush"},
usage = "",
flags = "r",
desc = "Build from far away",
min = 0,
max = 0
)
@CommandPermissions({"worldedit.superpickaxe.drawing.brush"})
public static void brush(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
boolean nonReplacing = args.hasFlag('r');
int radius = args.argsLength() > 1 ? args.getInteger(1) : 2;
boolean nonReplacing = args.argsLength() > 2
? (args.getString(2).equalsIgnoreCase("true")
|| args.getString(2).equalsIgnoreCase("yes")) : false;
if (radius > config.maxBrushRadius) {
player.printError("Maximum allowed brush radius: "
+ config.maxBrushRadius);
return;
}
BaseBlock targetBlock = we.getBlock(player, args.getString(0));
session.setRightClickMode(null);
session.setArmSwingMode(new SphereBrush(targetBlock, radius, nonReplacing));
session.setArmSwingMode(new Brush(nonReplacing));
if (nonReplacing) {
player.print("Non-replacing sphere brush tool equipped.");
player.print("Non-replacing brush tool equipped.");
} else {
player.print("Sphere brush tool equipped. Swing with a pickaxe.");
player.print("Brush tool equipped. Swing with a pickaxe.");
}
}
@Command(
aliases = {"rbrush"},
usage = "<block> [radius] ",
aliases = {"/rbrush"},
usage = "",
desc = "Brush tool that will only replace blocks",
min = 1,
max = 2
min = 0,
max = 0
)
@CommandPermissions({"worldedit.superpickaxe.drawing.brush"})
public static void rbrush(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
int radius = args.argsLength() > 1 ? args.getInteger(1) : 2;
if (radius > config.maxBrushRadius) {
player.printError("Maximum allowed brush radius: "
+ config.maxBrushRadius);
return;
}
BaseBlock targetBlock = we.getBlock(player, args.getString(0));
session.setRightClickMode(null);
session.setArmSwingMode(new ReplacingSphereBrush(targetBlock, radius));
player.print("Replacing sphere brush tool equipped. Swing with a pickaxe.");
session.setArmSwingMode(new ReplacingBrush());
player.print("Replacing brush tool equipped. Swing with a pickaxe.");
}
}

Datei anzeigen

@ -21,21 +21,17 @@ package com.sk89q.worldedit.superpickaxe;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.superpickaxe.brushes.BrushShape;
/**
* Builds a sphere at the place being looked at.
* Builds a shape at the place being looked at.
*
* @author sk89q
*/
public class SphereBrush implements SuperPickaxeMode {
private BaseBlock targetBlock;
private int radius;
public class Brush implements SuperPickaxeMode {
private boolean nonReplacing;
public SphereBrush(BaseBlock targetBlock, int radius, boolean nonReplacing) {
this.targetBlock = targetBlock;
this.radius = radius;
public Brush(boolean nonReplacing) {
this.nonReplacing = nonReplacing;
}
@ -51,6 +47,13 @@ public class SphereBrush implements SuperPickaxeMode {
BlockBag bag = session.getBlockBag(player);
BrushShape shape = session.getBrushShape();
if (shape == null) {
player.printError("Select a brush first.");
return true;
}
ReplacingEditSession editSession = new ReplacingEditSession(server, target.getWorld(),
session.getBlockChangeLimit(), bag);
@ -59,7 +62,7 @@ public class SphereBrush implements SuperPickaxeMode {
}
try {
editSession.makeSphere(target, targetBlock, radius, true);
shape.build(editSession, target);
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {

Datei anzeigen

@ -21,23 +21,14 @@ package com.sk89q.worldedit.superpickaxe;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.superpickaxe.brushes.BrushShape;
/**
* Builds a sphere at the place being looked at.
*
* @author sk89q
*/
public class ReplacingSphereBrush implements SuperPickaxeMode {
private BaseBlock targetBlock;
private int radius;
public ReplacingSphereBrush(BaseBlock targetBlock, int radius) {
this.targetBlock = targetBlock;
this.radius = radius;
}
@Override
public class ReplacingBrush implements SuperPickaxeMode {
public boolean act(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {
WorldVector target = player.getBlockTrace(500);
@ -49,6 +40,13 @@ public class ReplacingSphereBrush implements SuperPickaxeMode {
BlockBag bag = session.getBlockBag(player);
BrushShape shape = session.getBrushShape();
if (shape == null) {
player.printError("Select a brush first.");
return true;
}
ReplacingExistingEditSession editSession =
new ReplacingExistingEditSession(server, target.getWorld(),
session.getBlockChangeLimit(), bag);
@ -56,7 +54,7 @@ public class ReplacingSphereBrush implements SuperPickaxeMode {
editSession.enableReplacing();
try {
editSession.makeSphere(target, targetBlock, radius, true);
shape.build(editSession, target);
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {

Datei anzeigen

@ -0,0 +1,41 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe.brushes;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
/**
* Represents a shape.
*
* @author sk89q
*/
public interface BrushShape {
/**
* Build the object.
*
* @param build
* @param pos
* @throws MaxChangedBlocksException
*/
public void build(EditSession editSession, Vector pos)
throws MaxChangedBlocksException;
}

Datei anzeigen

@ -0,0 +1,41 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe.brushes;
import com.sk89q.worldedit.CuboidClipboard;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
public class ClipboardBrushShape implements BrushShape {
private CuboidClipboard clipboard;
private boolean noAir;
public ClipboardBrushShape(CuboidClipboard clipboard, boolean noAir) {
this.clipboard = clipboard;
this.noAir = noAir;
}
public void build(EditSession editSession, Vector pos)
throws MaxChangedBlocksException {
clipboard.place(editSession,
pos.subtract(clipboard.getSize().divide(2)), noAir);
}
}

Datei anzeigen

@ -0,0 +1,42 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe.brushes;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
public class CylinderBrushShape implements BrushShape {
private BaseBlock targetBlock;
private int radius;
private int height;
public CylinderBrushShape(BaseBlock targetBlock, int radius, int height) {
this.targetBlock = targetBlock;
this.radius = radius;
this.height = height;
}
public void build(EditSession editSession, Vector pos)
throws MaxChangedBlocksException {
editSession.makeCylinder(pos, targetBlock, radius, height);
}
}

Datei anzeigen

@ -0,0 +1,42 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe.brushes;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
public class HollowCylinderBrushShape implements BrushShape {
private BaseBlock targetBlock;
private int radius;
private int height;
public HollowCylinderBrushShape(BaseBlock targetBlock, int radius, int height) {
this.targetBlock = targetBlock;
this.radius = radius;
this.height = height;
}
public void build(EditSession editSession, Vector pos)
throws MaxChangedBlocksException {
editSession.makeHollowCylinder(pos, targetBlock, radius, height);
}
}

Datei anzeigen

@ -0,0 +1,40 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe.brushes;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
public class HollowSphereBrushShape implements BrushShape {
private BaseBlock targetBlock;
private int radius;
public HollowSphereBrushShape(BaseBlock targetBlock, int radius) {
this.targetBlock = targetBlock;
this.radius = radius;
}
public void build(EditSession editSession, Vector pos)
throws MaxChangedBlocksException {
editSession.makeSphere(pos, targetBlock, radius, false);
}
}

Datei anzeigen

@ -0,0 +1,40 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe.brushes;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
public class SphereBrushShape implements BrushShape {
private BaseBlock targetBlock;
private int radius;
public SphereBrushShape(BaseBlock targetBlock, int radius) {
this.targetBlock = targetBlock;
this.radius = radius;
}
public void build(EditSession editSession, Vector pos)
throws MaxChangedBlocksException {
editSession.makeSphere(pos, targetBlock, radius, true);
}
}