diff --git a/plugin.yml b/plugin.yml index 09503f6d3..d764c00cf 100644 --- a/plugin.yml +++ b/plugin.yml @@ -2,6 +2,18 @@ name: WorldEdit main: com.sk89q.worldedit.bukkit.WorldEditPlugin version: "WEVERSIONMACRO" commands: + /sb: + description: Choose the sphere brush + usage: / [-h] [radius] + aliases: ['/sphereb'] + /cb: + description: Choose the cylinder brush + usage: / [-h] [radius] [height] + aliases: ['/cylb'] + /cbb: + description: Choose the clipboard brush + usage: / [-a] + aliases: ['/copyb'] chunkinfo: description: Get information about the chunk that you are inside usage: / @@ -197,12 +209,12 @@ commands: cycler: description: Block data cycler tool usage: / - brush: - description: Build spheres from far away - usage: / [radius] [no-replace?] - rbrush: + /brush: + description: Build from far away + usage: / [-r] + /rbrush: description: Brush tool that will only replace blocks - usage: / [radius] + usage: / recur: description: Enable the recursive super pickaxe pickaxe mode usage: / diff --git a/src/com/sk89q/worldedit/CuboidClipboard.java b/src/com/sk89q/worldedit/CuboidClipboard.java index ac7b7cf99..552881865 100644 --- a/src/com/sk89q/worldedit/CuboidClipboard.java +++ b/src/com/sk89q/worldedit/CuboidClipboard.java @@ -267,6 +267,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. diff --git a/src/com/sk89q/worldedit/LocalSession.java b/src/com/sk89q/worldedit/LocalSession.java index ea279a173..04520dcdb 100644 --- a/src/com/sk89q/worldedit/LocalSession.java +++ b/src/com/sk89q/worldedit/LocalSession.java @@ -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; + } } diff --git a/src/com/sk89q/worldedit/WorldEdit.java b/src/com/sk89q/worldedit/WorldEdit.java index 123f66cd2..cd172420d 100644 --- a/src/com/sk89q/worldedit/WorldEdit.java +++ b/src/com/sk89q/worldedit/WorldEdit.java @@ -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); } diff --git a/src/com/sk89q/worldedit/commands/BrushShapeCommands.java b/src/com/sk89q/worldedit/commands/BrushShapeCommands.java new file mode 100644 index 000000000..a7a574208 --- /dev/null +++ b/src/com/sk89q/worldedit/commands/BrushShapeCommands.java @@ -0,0 +1,154 @@ +// $Id$ +/* + * WorldEdit + * Copyright (C) 2010, 2011 sk89q + * + * 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 . +*/ + +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 = " [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 = " [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."); + } +} diff --git a/src/com/sk89q/worldedit/commands/SuperPickaxeCommands.java b/src/com/sk89q/worldedit/commands/SuperPickaxeCommands.java index f3f8bdc4d..5272ebe63 100644 --- a/src/com/sk89q/worldedit/commands/SuperPickaxeCommands.java +++ b/src/com/sk89q/worldedit/commands/SuperPickaxeCommands.java @@ -237,61 +237,43 @@ public class SuperPickaxeCommands { } @Command( - aliases = {"brush"}, - usage = " [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(); - - 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)); + boolean nonReplacing = args.hasFlag('r'); + 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 = " [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."); } } diff --git a/src/com/sk89q/worldedit/superpickaxe/SphereBrush.java b/src/com/sk89q/worldedit/superpickaxe/Brush.java similarity index 79% rename from src/com/sk89q/worldedit/superpickaxe/SphereBrush.java rename to src/com/sk89q/worldedit/superpickaxe/Brush.java index fe83e80ad..2f8ee30db 100644 --- a/src/com/sk89q/worldedit/superpickaxe/SphereBrush.java +++ b/src/com/sk89q/worldedit/superpickaxe/Brush.java @@ -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 { diff --git a/src/com/sk89q/worldedit/superpickaxe/ReplacingSphereBrush.java b/src/com/sk89q/worldedit/superpickaxe/ReplacingBrush.java similarity index 80% rename from src/com/sk89q/worldedit/superpickaxe/ReplacingSphereBrush.java rename to src/com/sk89q/worldedit/superpickaxe/ReplacingBrush.java index 364225dac..c3ba719ac 100644 --- a/src/com/sk89q/worldedit/superpickaxe/ReplacingSphereBrush.java +++ b/src/com/sk89q/worldedit/superpickaxe/ReplacingBrush.java @@ -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 { diff --git a/src/com/sk89q/worldedit/superpickaxe/brushes/BrushShape.java b/src/com/sk89q/worldedit/superpickaxe/brushes/BrushShape.java new file mode 100644 index 000000000..9e2e4281b --- /dev/null +++ b/src/com/sk89q/worldedit/superpickaxe/brushes/BrushShape.java @@ -0,0 +1,41 @@ +// $Id$ +/* + * WorldEdit + * Copyright (C) 2010, 2011 sk89q + * + * 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 . +*/ + +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; +} diff --git a/src/com/sk89q/worldedit/superpickaxe/brushes/ClipboardBrushShape.java b/src/com/sk89q/worldedit/superpickaxe/brushes/ClipboardBrushShape.java new file mode 100644 index 000000000..d72b9f8af --- /dev/null +++ b/src/com/sk89q/worldedit/superpickaxe/brushes/ClipboardBrushShape.java @@ -0,0 +1,41 @@ +// $Id$ +/* + * WorldEdit + * Copyright (C) 2010, 2011 sk89q + * + * 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 . +*/ + +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); + } +} diff --git a/src/com/sk89q/worldedit/superpickaxe/brushes/CylinderBrushShape.java b/src/com/sk89q/worldedit/superpickaxe/brushes/CylinderBrushShape.java new file mode 100644 index 000000000..6dadd99a0 --- /dev/null +++ b/src/com/sk89q/worldedit/superpickaxe/brushes/CylinderBrushShape.java @@ -0,0 +1,42 @@ +// $Id$ +/* + * WorldEdit + * Copyright (C) 2010, 2011 sk89q + * + * 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 . +*/ + +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); + } +} diff --git a/src/com/sk89q/worldedit/superpickaxe/brushes/HollowCylinderBrushShape.java b/src/com/sk89q/worldedit/superpickaxe/brushes/HollowCylinderBrushShape.java new file mode 100644 index 000000000..07f3319e8 --- /dev/null +++ b/src/com/sk89q/worldedit/superpickaxe/brushes/HollowCylinderBrushShape.java @@ -0,0 +1,42 @@ +// $Id$ +/* + * WorldEdit + * Copyright (C) 2010, 2011 sk89q + * + * 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 . +*/ + +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); + } +} diff --git a/src/com/sk89q/worldedit/superpickaxe/brushes/HollowSphereBrushShape.java b/src/com/sk89q/worldedit/superpickaxe/brushes/HollowSphereBrushShape.java new file mode 100644 index 000000000..e9e55205e --- /dev/null +++ b/src/com/sk89q/worldedit/superpickaxe/brushes/HollowSphereBrushShape.java @@ -0,0 +1,40 @@ +// $Id$ +/* + * WorldEdit + * Copyright (C) 2010, 2011 sk89q + * + * 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 . +*/ + +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); + } +} diff --git a/src/com/sk89q/worldedit/superpickaxe/brushes/SphereBrushShape.java b/src/com/sk89q/worldedit/superpickaxe/brushes/SphereBrushShape.java new file mode 100644 index 000000000..0b3422535 --- /dev/null +++ b/src/com/sk89q/worldedit/superpickaxe/brushes/SphereBrushShape.java @@ -0,0 +1,40 @@ +// $Id$ +/* + * WorldEdit + * Copyright (C) 2010, 2011 sk89q + * + * 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 . +*/ + +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); + } +}