3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-09 21:10:05 +01:00

Overhauled the tool system. All tools can now be bound to any held item so you can have multiple tools out a time. New masks framework allows making a filter of blocks to change. Brushes are now powerful as well.

Dieser Commit ist enthalten in:
sk89q 2011-02-18 15:14:43 -08:00
Ursprung dfc7d074bd
Commit b311b0b88a
40 geänderte Dateien mit 1024 neuen und 636 gelöschten Zeilen

Datei anzeigen

@ -2,18 +2,18 @@ name: WorldEdit
main: com.sk89q.worldedit.bukkit.WorldEditPlugin
version: "WEVERSIONMACRO"
commands:
/sb:
sphere:
description: Choose the sphere brush
usage: /<command> [-h] <block> [radius]
aliases: ['/sphereb']
/cb:
aliases: ['s']
cylinder:
description: Choose the cylinder brush
usage: /<command> [-h] <block> [radius] [height]
aliases: ['/cylb']
/cbb:
aliases: ['cyl', 'c']
clipboard:
description: Choose the clipboard brush
usage: /<command> [-a]
aliases: ['/copyb']
aliases: ['copy']
chunkinfo:
description: Get information about the chunk that you are inside
usage: /<command>
@ -57,18 +57,18 @@ commands:
/limit:
description: Modify block change limit
usage: /<command> <limit>
/hcyl:
description: Generate a hollow cylinder
usage: /<command> <block> <radius> [height]
/sphere:
description: Generate a filled sphere
usage: /<command> <block> <radius> [raised?]
/cyl:
description: Generate a cylinder
usage: /<command> <block> <radius> [height]
/hcyl:
description: Generate a hollow cylinder
usage: /<command> <block> <radius> [height]
/hsphere:
description: Generate a hollow sphere
usage: /<command> <block> <radius> [raised?]
/sphere:
description: Generate a filled sphere
usage: /<command> <block> <radius> [raised?]
forestgen:
description: Generate a forest
usage: /<command> [size] [type] [density]
@ -184,13 +184,16 @@ commands:
/restore:
description: Restore the selection from a snapshot
usage: /<command> [snapshot]
/:
description: Toggle the super pickaxe pickaxe function
usage: /<command>
aliases: [',']
area:
description: Enable the area super pickaxe pickaxe mode
usage: /<command> <radius>
recur:
description: Enable the recursive super pickaxe pickaxe mode
usage: /<command> <radius>
aliases: ['recursive']
single:
description: Enable the single block super pickaxe mode
usage: /<command>
none:
description: Turn off all superpickaxe alternate modes
usage: /<command>
@ -200,24 +203,31 @@ commands:
cycler:
description: Block data cycler tool
usage: /<command>
/brush:
description: Build from far away
usage: /<command> [-r]
/rbrush:
description: Brush tool that will only replace blocks
brush:
description: Brush tool
usage: /<command>
recur:
description: Enable the recursive super pickaxe pickaxe mode
usage: /<command> <radius>
aliases: ['b']
info:
description: Block information tool
usage: /<command>
single:
description: Enable the single block super pickaxe mode
usage: /<command>
tree:
description: Tree generator tool
usage: /<command> [type]
tool:
description: Select a tool to bind
usage: /<command>
aliases: ['t']
/:
description: Toggle the super pickaxe pickaxe function
usage: /<command>
aliases: [',']
pickaxe:
description: Select super pickaxe mode
usage: /<command>
aliases: ['pa', 'spa']
mask:
description: Set the brush mask
usage: /<command> [mask]
/fillr:
description: Fill a hole recursively
usage: /<command> <block> <radius> [depth]

Datei anzeigen

@ -104,11 +104,10 @@ public class EditSession {
/**
* Construct the object with a maximum number of blocks.
*
* @param server
* @param world
* @param maxBlocks
*/
public EditSession(ServerInterface server, LocalWorld world, int maxBlocks) {
public EditSession(LocalWorld world, int maxBlocks) {
if (maxBlocks < -1) {
throw new IllegalArgumentException("Max blocks must be >= -1");
}
@ -120,12 +119,12 @@ public class EditSession {
/**
* Construct the object with a maximum number of blocks and a block bag.
*
* @param server
* @param world
* @param maxBlocks
* @param blockBag
* @blockBag
*/
public EditSession(ServerInterface server, LocalWorld world, int maxBlocks,
BlockBag blockBag) {
public EditSession(LocalWorld world, int maxBlocks, BlockBag blockBag) {
if (maxBlocks < -1) {
throw new IllegalArgumentException("Max blocks must be >= -1");
}
@ -231,6 +230,7 @@ public class EditSession {
* @param pt
* @param block
* @return Whether the block changed -- not entirely dependable
* @throws MaxChangedBlocksException
*/
public boolean setBlock(Vector pt, BaseBlock block)
throws MaxChangedBlocksException {
@ -249,6 +249,19 @@ public class EditSession {
return smartSetBlock(pt, block);
}
/**
* Set a block with a pattern.
*
* @param pt
* @param pat
* @return Whether the block changed -- not entirely dependable
* @throws MaxChangedBlocksException
*/
public boolean setBlock(Vector pt, Pattern pat)
throws MaxChangedBlocksException {
return setBlock(pt, pat.next(pt));
}
/**
* Set a block only if there's no block already there.
*
@ -381,23 +394,23 @@ public class EditSession {
/**
* Restores all blocks to their initial state.
*/
public void undo() {
public void undo(EditSession sess) {
for (Map.Entry<BlockVector, BaseBlock> entry : original) {
BlockVector pt = (BlockVector) entry.getKey();
smartSetBlock(pt, (BaseBlock) entry.getValue());
sess.smartSetBlock(pt, (BaseBlock) entry.getValue());
}
flushQueue();
sess.flushQueue();
}
/**
* Sets to new state.
*/
public void redo() {
public void redo(EditSession sess) {
for (Map.Entry<BlockVector, BaseBlock> entry : current) {
BlockVector pt = (BlockVector) entry.getKey();
smartSetBlock(pt, (BaseBlock) entry.getValue());
sess.smartSetBlock(pt, (BaseBlock) entry.getValue());
}
flushQueue();
sess.flushQueue();
}
/**
@ -1453,7 +1466,7 @@ public class EditSession {
* @throws MaxChangedBlocksException
*/
private int makeHCylinderPoints(Vector center, int x, int z, int height,
BaseBlock block) throws MaxChangedBlocksException {
Pattern block) throws MaxChangedBlocksException {
int affected = 0;
if (x == 0) {
@ -1499,7 +1512,7 @@ public class EditSession {
* @return number of blocks set
* @throws MaxChangedBlocksException
*/
public int makeHollowCylinder(Vector pos, BaseBlock block, int radius,
public int makeHollowCylinder(Vector pos, Pattern block, int radius,
int height) throws MaxChangedBlocksException {
int x = 0;
int z = radius;
@ -1548,7 +1561,7 @@ public class EditSession {
* @throws MaxChangedBlocksException
*/
private int makeCylinderPoints(Vector center, int x, int z, int height,
BaseBlock block) throws MaxChangedBlocksException {
Pattern block) throws MaxChangedBlocksException {
int affected = 0;
if (x == z) {
@ -1586,7 +1599,7 @@ public class EditSession {
* @return number of blocks set
* @throws MaxChangedBlocksException
*/
public int makeCylinder(Vector pos, BaseBlock block, int radius, int height)
public int makeCylinder(Vector pos, Pattern block, int radius, int height)
throws MaxChangedBlocksException {
int x = 0;
int z = radius;
@ -1634,7 +1647,7 @@ public class EditSession {
* @return number of blocks changed
* @throws MaxChangedBlocksException
*/
public int makeSphere(Vector pos, BaseBlock block, int radius,
public int makeSphere(Vector pos, Pattern block, int radius,
boolean filled) throws MaxChangedBlocksException {
int affected = 0;

Datei anzeigen

@ -19,7 +19,7 @@ package com.sk89q.worldedit;
*/
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.filters.HeightMapFilter;
import com.sk89q.worldedit.filtering.HeightMapFilter;
import com.sk89q.worldedit.regions.Region;
/**

Datei anzeigen

@ -19,20 +19,29 @@
package com.sk89q.worldedit;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
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.tools.Brush;
import com.sk89q.worldedit.tools.SinglePickaxe;
import com.sk89q.worldedit.tools.BlockTool;
import com.sk89q.worldedit.tools.Tool;
import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.CuboidRegion;
/**
* An instance of this represents the WorldEdit session of a user. A session
* stores history and settings. Sessions are not tied particularly to any
* player and can be shuffled between players, saved, and loaded.
*
* @author sk89q
*/
public class LocalSession {
/**
* List of compass modes.
*/
public enum CompassMode {
JUMPTO,
THRU
@ -50,15 +59,14 @@ public class LocalSession {
private CuboidClipboard clipboard;
private boolean toolControl = true;
private boolean superPickaxe = false;
private SuperPickaxeMode leftClickMode = new SinglePickaxe();
private SuperPickaxeMode armSwingMode;
private SuperPickaxeMode rightClickMode;
private BlockTool pickaxeMode = new SinglePickaxe();
private Map<Integer, Tool> tools
= new HashMap<Integer, Tool>();
private int maxBlocksChanged = -1;
private boolean useInventory;
private Snapshot snapshot;
private String lastScript;
private CompassMode compassMode = CompassMode.JUMPTO;
private BrushShape brushShape = null;
private boolean beenToldVersion = false;
/**
@ -79,7 +87,10 @@ public class LocalSession {
}
/**
* Get the edit session.
* Remember an edit session for the undo history. If the history maximum
* size is reached, old edit sessions will be discarded.
*
* @param editSession
*/
public void remember(EditSession editSession) {
// Don't store anything if no changes were made
@ -97,16 +108,18 @@ public class LocalSession {
}
/**
* Undo.
* Performs an undo.
*
* @param newBlockBag
* @return whether anything was undone
*/
public EditSession undo(BlockBag newBlockBag) {
historyPointer--;
if (historyPointer >= 0) {
EditSession editSession = history.get(historyPointer);
editSession.setBlockBag(newBlockBag);
editSession.undo();
EditSession newEditSession =
new EditSession(editSession.getWorld(), -1, newBlockBag);
editSession.undo(newEditSession);
return editSession;
} else {
historyPointer = 0;
@ -115,15 +128,17 @@ public class LocalSession {
}
/**
* Redo.
* Performs a redo
*
* @param newBlockBag
* @return whether anything was redone
*/
public EditSession redo(BlockBag newBlockBag) {
if (historyPointer < history.size()) {
EditSession editSession = history.get(historyPointer);
editSession.setBlockBag(newBlockBag);
editSession.redo();
EditSession newEditSession =
new EditSession(editSession.getWorld(), -1, newBlockBag);
editSession.redo(newEditSession);
historyPointer++;
return editSession;
}
@ -155,8 +170,8 @@ public class LocalSession {
/**
* Returns true if the region is fully defined.
*
* @throws IncompleteRegionException
*
* @return
*/
public boolean isRegionDefined() {
return pos1 != null && pos2 != null;
@ -303,8 +318,6 @@ public class LocalSession {
/**
* Enable super pick axe.
*
* @param superPickaxe
*/
public void enableSuperPickAxe() {
superPickaxe = true;
@ -312,8 +325,6 @@ public class LocalSession {
/**
* Disable super pick axe.
*
* @param superPickaxe
*/
public void disableSuperPickAxe() {
superPickaxe = false;
@ -330,6 +341,9 @@ public class LocalSession {
}
/**
* Get the placement position.
*
* @param player
* @return position
* @throws IncompleteRegionException
*/
@ -344,7 +358,9 @@ public class LocalSession {
}
/**
* Toggle placement position;
* Toggle placement position.
*
* @return
*/
public boolean togglePlacementPosition() {
placeAtPos1 = !placeAtPos1;
@ -365,13 +381,17 @@ public class LocalSession {
}
/**
* @return the snapshotName
* Get the snapshot that has been selected.
*
* @return the snapshot
*/
public Snapshot getSnapshot() {
return snapshot;
}
/**
* Select a snapshot.
*
* @param snapshot
*/
public void setSnapshot(Snapshot snapshot) {
@ -381,46 +401,61 @@ public class LocalSession {
/**
* @return the superPickaxeMode
*/
public SuperPickaxeMode getLeftClickMode() {
return leftClickMode;
public BlockTool getSuperPickaxe() {
return pickaxeMode;
}
/**
* @param superPickaxeMode the superPickaxeMode to set
* Set the super pickaxe tool.
*
* @param tool
*/
public void setLeftClickMode(SuperPickaxeMode leftClickMode) {
this.leftClickMode = leftClickMode;
public void setSuperPickaxe(BlockTool tool) {
this.pickaxeMode = tool;
}
/**
* Get the tool assigned to the item.
*
* @param item
* @return the tool
*/
public SuperPickaxeMode getRightClickMode() {
return rightClickMode;
public Tool getTool(int item) {
return tools.get(item);
}
/**
* Get the brush tool assigned to the item. If there is no tool assigned
* or the tool is not assigned, the slot will be replaced with the
* brush tool.
*
* @param item
* @return the tool
*/
public Brush getBrushTool(int item) {
Tool tool = getTool(item);
if (tool == null || !(tool instanceof Brush)) {
tool = new Brush();
setTool(item, tool);
}
return (Brush)tool;
}
/**
* Set the tool.
*
* @param item
* @param tool the tool to set
*/
public void setRightClickMode(SuperPickaxeMode rightClickMode) {
this.rightClickMode = rightClickMode;
}
/**
* @return the arm swing mode
*/
public SuperPickaxeMode getArmSwingMode() {
return armSwingMode;
}
/**
* @param rightClickMode the tool to set
*/
public void setArmSwingMode(SuperPickaxeMode armSwingMode) {
this.armSwingMode = armSwingMode;
public void setTool(int item, Tool tool) {
this.tools.put(item, tool);
}
/**
* Returns whether inventory usage is enabled for this session.
*
* @return the useInventory
*/
public boolean isUsingInventory() {
@ -428,6 +463,8 @@ public class LocalSession {
}
/**
* Set the state of inventory usage.
*
* @param useInventory the useInventory to set
*/
public void setUseInventory(boolean useInventory) {
@ -435,6 +472,8 @@ public class LocalSession {
}
/**
* Get the last script used.
*
* @return the lastScript
*/
public String getLastScript() {
@ -442,6 +481,8 @@ public class LocalSession {
}
/**
* Set the last script used.
*
* @param lastScript the lastScript to set
*/
public void setLastScript(String lastScript) {
@ -449,6 +490,8 @@ public class LocalSession {
}
/**
* Get the compass mode.
*
* @return the compassMode
*/
public CompassMode getCompassMode() {
@ -456,28 +499,18 @@ public class LocalSession {
}
/**
* Set the compass mode.
*
* @param compassMode the compassMode to set
*/
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;
}
/**
* Tell the player the WorldEdit version.
*
* @param player
*/
public void tellVersion(LocalPlayer player) {
if (config.showFirstUseVersion) {

Datei anzeigen

@ -21,78 +21,62 @@ package com.sk89q.worldedit;
import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.masks.Mask;
/**
* An edit session that can be set to not replace existing blocks.
* An edit session that will only replace blocks as specified.
*
* @author sk89q
*/
public class ReplacingEditSession extends EditSession {
/**
* True to prevent replacing.
* Filter to use to filter blocks.
*/
private boolean noReplace = false;
private Mask mask;
/**
* Construct the object.
*
* @param server
* @param world
* @param maxBlocks
* @param mask
*/
public ReplacingEditSession(ServerInterface server, LocalWorld world,
int maxBlocks) {
super(server, world, maxBlocks);
public ReplacingEditSession(LocalWorld world,
int maxBlocks, Mask mask) {
super(world, maxBlocks);
this.mask = mask;
}
/**
* Construct the object.
*
* @param server
* @param world
* @param maxBlocks
* @param blockBag
* @param mask
*/
public ReplacingEditSession(ServerInterface server, LocalWorld world,
int maxBlocks, BlockBag blockBag) {
super(server, world, maxBlocks, blockBag);
}
/**
* Enables block replacing.
*/
public void enableReplacing() {
noReplace = false;
}
/**
* Disables block replacing.
*/
public void disableReplacing() {
noReplace = true;
public ReplacingEditSession(LocalWorld world, int maxBlocks,
BlockBag blockBag, Mask mask) {
super(world, maxBlocks, blockBag);
this.mask = mask;
}
/**
* Sets a block without changing history.
*
* @param pt
* @param blockType
* @param block
* @return Whether the block changed
*/
public boolean rawSetBlock(Vector pt, BaseBlock block) {
if (!noReplace) {
return super.rawSetBlock(pt, block);
}
@Override
public boolean rawSetBlock(Vector pt, BaseBlock block) {
int y = pt.getBlockY();
if (y < 0 || y > 127) {
return false;
}
int existing = world.getBlockType(pt);
if (existing != 0) {
if (!mask.matches(this, pt)) {
return false;
}

Datei anzeigen

@ -1,102 +0,0 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010 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;
import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.blocks.BaseBlock;
/**
* An edit session that can be set to only replace existing blocks.
*
* @author sk89q
*/
public class ReplacingExistingEditSession extends EditSession {
/**
* True to replace existing.
*/
private boolean replaceExisting = false;
/**
* Construct the object.
*
* @param server
* @param world
* @param maxBlocks
*/
public ReplacingExistingEditSession(ServerInterface server, LocalWorld world,
int maxBlocks) {
super(server, world, maxBlocks);
}
/**
* Construct the object.
*
* @param server
* @param world
* @param maxBlocks
* @param blockBag
*/
public ReplacingExistingEditSession(ServerInterface server, LocalWorld world,
int maxBlocks, BlockBag blockBag) {
super(server, world, maxBlocks, blockBag);
}
/**
* Enables block replacing.
*/
public void enableReplacing() {
replaceExisting = true;
}
/**
* Disables block replacing.
*/
public void disableReplacing() {
replaceExisting = false;
}
/**
* Sets a block without changing history.
*
* @param pt
* @param blockType
* @return Whether the block changed
*/
public boolean rawSetBlock(Vector pt, BaseBlock block) {
if (!replaceExisting) {
return super.rawSetBlock(pt, block);
}
int y = pt.getBlockY();
if (y < 0 || y > 127) {
return false;
}
int existing = world.getBlockType(pt);
if (existing == 0) {
return false;
}
return super.rawSetBlock(pt, block);
}
}

Datei anzeigen

@ -29,7 +29,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.*;
import javax.script.ScriptException;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandsManager;
import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.LocalSession.CompassMode;
@ -37,6 +36,12 @@ import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.blocks.*;
import com.sk89q.worldedit.commands.*;
import com.sk89q.worldedit.scripting.*;
import com.sk89q.worldedit.tools.BlockTool;
import com.sk89q.worldedit.tools.Tool;
import com.sk89q.worldedit.tools.TraceTool;
import com.sk89q.worldedit.masks.BlockTypeMask;
import com.sk89q.worldedit.masks.ExistingBlockMask;
import com.sk89q.worldedit.masks.Mask;
import com.sk89q.worldedit.patterns.*;
/**
@ -105,8 +110,8 @@ public class WorldEdit {
commands.register(ScriptingCommands.class);
commands.register(SelectionCommands.class);
commands.register(SnapshotCommands.class);
commands.register(SuperPickaxeCommands.class);
commands.register(BrushShapeCommands.class);
commands.register(ToolUtilCommands.class);
commands.register(ToolCommands.class);
commands.register(UtilityCommands.class);
}
@ -290,6 +295,8 @@ public class WorldEdit {
* @param player
* @param list
* @return pattern
* @throws UnknownItemException
* @throws DisallowedItemException
*/
public Pattern getBlockPattern(LocalPlayer player, String list)
throws UnknownItemException, DisallowedItemException {
@ -334,6 +341,29 @@ public class WorldEdit {
return new RandomFillPattern(blockChances);
}
/**
* Get a block mask. Block masks are used to determine which
* blocks to include when replacing.
*
* @param player
* @param list
* @return
* @throws UnknownItemException
* @throws DisallowedItemException
*/
public Mask getBlockMask(LocalPlayer player, String list)
throws UnknownItemException, DisallowedItemException {
if (list.charAt(0) == '#') {
if (list.equalsIgnoreCase("#existing")) {
return new ExistingBlockMask();
} else {
throw new UnknownItemException(list);
}
} else {
return new BlockTypeMask(getBlockIDs(player, list, true));
}
}
/**
* Get a list of blocks as a set.
@ -342,6 +372,8 @@ public class WorldEdit {
* @param list
* @param allBlocksAllowed
* @return set
* @throws UnknownItemException
* @throws DisallowedItemException
*/
public Set<Integer> getBlockIDs(LocalPlayer player,
String list, boolean allBlocksAllowed)
@ -361,6 +393,7 @@ public class WorldEdit {
* traversal exploits by checking the root directory and the file directory.
* On success, a <code>java.io.File</code> object will be returned.
*
* @param player
* @param dir sub-directory to look in
* @param filename filename (user-submitted)
* @param defaultExt append an extension if missing one, null to not use
@ -380,6 +413,7 @@ public class WorldEdit {
* traversal exploits by checking the root directory and the file directory.
* On success, a <code>java.io.File</code> object will be returned.
*
* @param player
* @param dir sub-directory to look in
* @param filename filename (user-submitted)
* @param defaultExt append an extension if missing one, null to not use
@ -493,8 +527,9 @@ public class WorldEdit {
* null if a direction could not be found.
*
* @param player
* @param dir
* @param dirStr
* @return
* @throws UnknownDirectionException
*/
public Vector getDirection(LocalPlayer player, String dirStr)
throws UnknownDirectionException {
@ -540,8 +575,9 @@ public class WorldEdit {
* null if a direction could not be found.
*
* @param player
* @param dir
* @param dirStr
* @return
* @throws UnknownDirectionException
*/
public CuboidClipboard.FlipDirection getFlipDirection(
LocalPlayer player, String dirStr)
@ -589,7 +625,6 @@ public class WorldEdit {
* Flush a block bag's changes to a player.
*
* @param player
* @param blockBag
* @param editSession
*/
public void flushBlockBag(LocalPlayer player,
@ -651,13 +686,7 @@ public class WorldEdit {
public boolean handleArmSwing(LocalPlayer player) {
LocalSession session = getSession(player);
if (player.isHoldingPickAxe()) {
if (session.getArmSwingMode() != null) {
session.getArmSwingMode().act(server, config,
player, session, null);
return true;
}
} else if (player.getItemInHand() == config.navigationWand
if (player.getItemInHand() == config.navigationWand
&& config.navigationWandMaxDistance > 0) {
CompassMode mode = session.getCompassMode();
@ -687,13 +716,7 @@ public class WorldEdit {
public boolean handleRightClick(LocalPlayer player) {
LocalSession session = getSession(player);
if (player.isHoldingPickAxe()) {
if (session.getArmSwingMode() != null) {
session.getArmSwingMode().act(server, config,
player, session, null);
return true;
}
} else if (player.getItemInHand() == config.navigationWand) {
if (player.getItemInHand() == config.navigationWand) {
CompassMode mode = session.getCompassMode();
if (mode == CompassMode.JUMPTO) {
@ -715,6 +738,13 @@ public class WorldEdit {
return true;
}
Tool tool = session.getTool(player.getItemInHand());
if (tool != null && tool instanceof TraceTool) {
((TraceTool)tool).act(server, config, player, session);
return true;
}
return false;
}
@ -733,6 +763,7 @@ public class WorldEdit {
if (itemInHand == config.wandItem && session.isToolControlEnabled()
&& player.hasPermission("worldedit.selection.pos")) {
session.setPos2(clicked);
try {
player.print("Second position set to " + clicked
+ " (" + session.getRegion().getSize() + ").");
@ -741,8 +772,13 @@ public class WorldEdit {
}
return true;
} else if (player.isHoldingPickAxe() && session.getRightClickMode() != null) {
return session.getRightClickMode().act(server, config, player, session, clicked);
}
Tool tool = session.getTool(player.getItemInHand());
if (tool != null && tool instanceof BlockTool) {
((BlockTool)tool).act(server, config, player, session, clicked);
return true;
}
return false;
@ -785,8 +821,8 @@ public class WorldEdit {
return true;
}
} else if (player.isHoldingPickAxe() && session.hasSuperPickAxe()) {
if (session.getLeftClickMode() != null) {
return session.getLeftClickMode().act(server, config,
if (session.getSuperPickaxe() != null) {
return session.getSuperPickaxe().act(server, config,
player, session, clicked);
}
}
@ -830,7 +866,7 @@ public class WorldEdit {
session.tellVersion(player);
EditSession editSession =
new EditSession(server, player.getWorld(),
new EditSession(player.getWorld(),
session.getBlockChangeLimit(), blockBag);
editSession.enableQueue();
@ -913,7 +949,7 @@ public class WorldEdit {
* Executes a WorldEdit script.
*
* @param player
* @param filename
* @param f
* @param args
* @throws WorldEditException
*/

Datei anzeigen

@ -30,28 +30,29 @@ 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;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.tools.Brush;
import com.sk89q.worldedit.tools.brushes.ClipboardBrush;
import com.sk89q.worldedit.tools.brushes.CylinderBrush;
import com.sk89q.worldedit.tools.brushes.HollowCylinderBrush;
import com.sk89q.worldedit.tools.brushes.HollowSphereBrush;
import com.sk89q.worldedit.tools.brushes.SphereBrush;
/**
* Brush shape commands.
*
* @author sk89q
*/
public class BrushShapeCommands {
public class BrushCommands {
@Command(
aliases = {"/sb", "/sphereb"},
aliases = {"sphere", "s"},
usage = "<block> [radius]",
flags = "h",
desc = "Choose the sphere brush",
min = 1,
max = 2
)
@CommandPermissions({"worldedit.superpickaxe.drawing.brush.sphere"})
@CommandPermissions({"worldedit.brush.sphere"})
public static void sphereBrush(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
@ -64,27 +65,31 @@ public class BrushShapeCommands {
+ config.maxBrushRadius);
return;
}
BaseBlock targetBlock = we.getBlock(player, args.getString(0));
Brush tool = session.getBrushTool(player.getItemInHand());
Pattern fill = we.getBlockPattern(player, args.getString(0));
tool.setFill(fill);
tool.setSize(radius);
if (args.hasFlag('h')) {
session.setBrushShape(new HollowSphereBrushShape(targetBlock, radius));
tool.setBrush(new HollowSphereBrush());
} else {
session.setBrushShape(new SphereBrushShape(targetBlock, radius));
tool.setBrush(new SphereBrush());
}
player.print("Sphere brush shape equipped.");
player.print(String.format("Sphere brush shape equipped (%d).",
radius));
}
@Command(
aliases = {"/cb", "/cylb"},
aliases = {"cylinder", "cyl", "c"},
usage = "<block> [radius] [height]",
flags = "h",
desc = "Choose the cylinder brush",
min = 1,
max = 2
max = 3
)
@CommandPermissions({"worldedit.superpickaxe.drawing.brush.cylinder"})
@CommandPermissions({"worldedit.brush.cylinder"})
public static void cylinderBrush(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
@ -98,33 +103,37 @@ public class BrushShapeCommands {
return;
}
int height = args.argsLength() > 1 ? args.getInteger(1) : 1;
int height = args.argsLength() > 2 ? args.getInteger(2) : 1;
if (height > config.maxBrushRadius) {
player.printError("Maximum allowed brush radius/height: "
+ config.maxBrushRadius);
return;
}
BaseBlock targetBlock = we.getBlock(player, args.getString(0));
Brush tool = session.getBrushTool(player.getItemInHand());
Pattern fill = we.getBlockPattern(player, args.getString(0));
tool.setFill(fill);
tool.setSize(radius);
if (args.hasFlag('h')) {
session.setBrushShape(new HollowCylinderBrushShape(targetBlock, radius, height));
tool.setBrush(new HollowCylinderBrush(height));
} else {
session.setBrushShape(new CylinderBrushShape(targetBlock, radius, height));
tool.setBrush(new CylinderBrush(height));
}
player.print("Cylinder brush shape equipped.");
player.print(String.format("Cylinder brush shape equipped (%d by %d).",
radius, height));
}
@Command(
aliases = {"/cbb", "/copyb"},
aliases = {"clipboard", "copy"},
usage = "",
flags = "a",
desc = "Choose the clipboard brush",
min = 0,
max = 0
)
@CommandPermissions({"worldedit.superpickaxe.drawing.brush.clipboard"})
@CommandPermissions({"worldedit.brush.clipboard"})
public static void clipboardBrush(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
@ -147,8 +156,9 @@ public class BrushShapeCommands {
+ config.maxBrushRadius);
return;
}
session.setBrushShape(new ClipboardBrushShape(clipboard, args.hasFlag('a')));
Brush tool = session.getBrushTool(player.getItemInHand());
tool.setBrush(new ClipboardBrush(clipboard, args.hasFlag('a')));
player.print("Clipboard brush shape equipped.");
}

Datei anzeigen

@ -0,0 +1,67 @@
// $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.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.tools.Brush;
import com.sk89q.worldedit.tools.ReplacingBrush;
public class BrushModeCommands {
@Command(
aliases = {"normal", "s"},
usage = "",
desc = "Normal brush mode",
min = 0,
max = 0
)
@CommandPermissions({"worldedit.brush.mode.normal"})
public static void normal(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
session.setRightClickMode(null);
session.setArmSwingMode(new Brush(true));
player.print("Normal brush mode set.");
}
@Command(
aliases = {"replace", "r"},
usage = "",
desc = "Replace existing blocks only",
min = 0,
max = 0
)
@CommandPermissions({"worldedit.brush.mode.replace"})
public static void replace(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
session.setRightClickMode(null);
session.setArmSwingMode(new ReplacingBrush());
player.print("Replacing brush mode equipped.");
}
}

Datei anzeigen

@ -23,7 +23,7 @@ import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.util.TreeGenerator;
/**
@ -44,7 +44,7 @@ public class GenerationCommands {
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
BaseBlock block = we.getBlock(player, args.getString(0));
Pattern block = we.getBlockPattern(player, args.getString(0));
int radius = Math.max(1, args.getInteger(1));
int height = args.argsLength() > 2 ? args.getInteger(2) : 1;
@ -65,7 +65,7 @@ public class GenerationCommands {
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
BaseBlock block = we.getBlock(player, args.getString(0));
Pattern block = we.getBlockPattern(player, args.getString(0));
int radius = Math.max(1, args.getInteger(1));
int height = args.argsLength() > 2 ? args.getInteger(2) : 1;
@ -86,7 +86,7 @@ public class GenerationCommands {
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
BaseBlock block = we.getBlock(player, args.getString(0));
Pattern block = we.getBlockPattern(player, args.getString(0));
int radius = Math.max(1, args.getInteger(1));
boolean raised = args.argsLength() > 2
? (args.getString(2).equalsIgnoreCase("true")
@ -115,7 +115,7 @@ public class GenerationCommands {
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
BaseBlock block = we.getBlock(player, args.getString(0));
Pattern block = we.getBlockPattern(player, args.getString(0));
int radius = Math.max(1, args.getInteger(1));
boolean raised = args.argsLength() > 2
? (args.getString(2).equalsIgnoreCase("true")

Datei anzeigen

@ -25,8 +25,8 @@ import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.filters.GaussianKernel;
import com.sk89q.worldedit.filters.HeightMapFilter;
import com.sk89q.worldedit.filtering.GaussianKernel;
import com.sk89q.worldedit.filtering.HeightMapFilter;
import com.sk89q.worldedit.patterns.*;
import com.sk89q.worldedit.regions.Region;

Datei anzeigen

@ -1,7 +1,7 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
* 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
@ -22,37 +22,17 @@ package com.sk89q.worldedit.commands;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.minecraft.util.commands.NestedCommand;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.superpickaxe.*;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.tools.AreaPickaxe;
import com.sk89q.worldedit.tools.RecursivePickaxe;
import com.sk89q.worldedit.tools.SinglePickaxe;
/**
* Super pickaxe commands.
*
* @author sk89q
*/
public class SuperPickaxeCommands {
@Command(
aliases = {"/", ","},
usage = "",
desc = "Toggle the super pickaxe pickaxe function",
min = 0,
max = 0
)
@CommandPermissions({"worldedit.superpickaxe.pickaxe"})
public static void togglePickaxe(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
if (session.toggleSuperPickAxe()) {
player.print("Super pick axe enabled.");
} else {
player.print("Super pick axe disabled.");
}
}
public class SuperPickaxeCommands {
@Command(
aliases = {"single"},
usage = "",
@ -60,12 +40,12 @@ public class SuperPickaxeCommands {
min = 0,
max = 0
)
@CommandPermissions({"worldedit.superpickaxe.pickaxe"})
@CommandPermissions({"worldedit.superpickaxe"})
public static void single(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
session.setLeftClickMode(new SinglePickaxe());
session.setSuperPickaxe(new SinglePickaxe());
session.enableSuperPickAxe();
player.print("Mode changed. Left click with a pickaxe. // to disable.");
}
@ -77,7 +57,7 @@ public class SuperPickaxeCommands {
min = 1,
max = 1
)
@CommandPermissions({"worldedit.superpickaxe.pickaxe.area"})
@CommandPermissions({"worldedit.superpickaxe.area"})
public static void area(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
@ -90,19 +70,19 @@ public class SuperPickaxeCommands {
return;
}
session.setLeftClickMode(new AreaPickaxe(range));
session.setSuperPickaxe(new AreaPickaxe(range));
session.enableSuperPickAxe();
player.print("Mode changed. Left click with a pickaxe. // to disable.");
}
@Command(
aliases = {"recur"},
aliases = {"recur", "recursive"},
usage = "<radius>",
desc = "Enable the recursive super pickaxe pickaxe mode",
min = 1,
max = 1
)
@CommandPermissions({"worldedit.superpickaxe.pickaxe.recursive"})
@CommandPermissions({"worldedit.superpickaxe.recursive"})
public static void recursive(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
@ -115,143 +95,8 @@ public class SuperPickaxeCommands {
return;
}
session.setLeftClickMode(new RecursivePickaxe(range));
session.setSuperPickaxe(new RecursivePickaxe(range));
session.enableSuperPickAxe();
player.print("Mode changed. Left click with a pickaxe. // to disable.");
}
@Command(
aliases = {"none"},
usage = "",
desc = "Turn off all superpickaxe alternate modes",
min = 0,
max = 0
)
public static void none(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
session.setArmSwingMode(null);
session.setRightClickMode(null);
player.print("Now no longer equipping a tool.");
}
@Command(
aliases = {"info"},
usage = "",
desc = "Block information tool",
min = 0,
max = 0
)
@CommandPermissions({"worldedit.superpickaxe.info"})
public static void info(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
session.setArmSwingMode(null);
session.setRightClickMode(new QueryTool());
player.print("Info tool equipped. Right click with a pickaxe.");
}
@Command(
aliases = {"tree"},
usage = "[type]",
desc = "Tree generator tool",
min = 0,
max = 1
)
@CommandPermissions({"worldedit.superpickaxe.tree"})
public static void tree(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
TreeGenerator.TreeType type = args.argsLength() > 0 ?
type = TreeGenerator.lookup(args.getString(0))
: TreeGenerator.TreeType.TREE;
if (type == null) {
player.printError("Tree type '" + args.getString(0) + "' is unknown.");
return;
}
session.setArmSwingMode(null);
session.setRightClickMode(new TreePlanter(new TreeGenerator(type)));
player.print("Tree tool equipped. Right click grass with a pickaxe.");
}
@Command(
aliases = {"repl"},
usage = "<block>",
desc = "Block replacer tool",
min = 1,
max = 1
)
@CommandPermissions({"worldedit.superpickaxe.replacer"})
public static void repl(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
BaseBlock targetBlock = we.getBlock(player, args.getString(0));
session.setArmSwingMode(null);
session.setRightClickMode(new BlockReplacer(targetBlock));
player.print("Block replacer tool equipped. Right click with a pickaxe.");
}
@Command(
aliases = {"cycler"},
usage = "",
desc = "Block data cycler tool",
min = 0,
max = 0
)
@CommandPermissions({"worldedit.superpickaxe.data-cycler"})
public static void cycler(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
session.setArmSwingMode(null);
session.setRightClickMode(new BlockDataCyler());
player.print("Block cycler tool equipped. Right click with a pickaxe.");
}
@Command(
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 {
boolean nonReplacing = args.hasFlag('r');
session.setRightClickMode(null);
session.setArmSwingMode(new Brush(nonReplacing));
if (nonReplacing) {
player.print("Non-replacing brush tool equipped.");
} else {
player.print("Brush tool equipped. Swing with a pickaxe.");
}
}
@Command(
aliases = {"/rbrush"},
usage = "",
desc = "Brush tool that will only replace blocks",
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 {
session.setRightClickMode(null);
session.setArmSwingMode(new ReplacingBrush());
player.print("Replacing brush tool equipped. Swing with a pickaxe.");
}
}

Datei anzeigen

@ -0,0 +1,130 @@
// $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.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.minecraft.util.commands.NestedCommand;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.tools.*;
import com.sk89q.worldedit.util.TreeGenerator;
public class ToolCommands {
@Command(
aliases = {"none"},
usage = "",
desc = "Turn off all superpickaxe alternate modes",
min = 0,
max = 0
)
public static void none(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
session.setTool(player.getItemInHand(), null);
player.print("Now no longer equipping a tool.");
}
@Command(
aliases = {"info"},
usage = "",
desc = "Block information tool",
min = 0,
max = 0
)
@CommandPermissions({"worldedit.tool.info"})
public static void info(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
session.setTool(player.getItemInHand(), new QueryTool());
player.print("Info tool equipped. Right click with a pickaxe.");
}
@Command(
aliases = {"tree"},
usage = "[type]",
desc = "Tree generator tool",
min = 0,
max = 1
)
@CommandPermissions({"worldedit.tool.tree"})
public static void tree(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
TreeGenerator.TreeType type = args.argsLength() > 0 ?
type = TreeGenerator.lookup(args.getString(0))
: TreeGenerator.TreeType.TREE;
if (type == null) {
player.printError("Tree type '" + args.getString(0) + "' is unknown.");
return;
}
session.setTool(player.getItemInHand(), new TreePlanter(new TreeGenerator(type)));
player.print("Tree tool equipped. Right click grass with a pickaxe.");
}
@Command(
aliases = {"repl"},
usage = "<block>",
desc = "Block replacer tool",
min = 1,
max = 1
)
@CommandPermissions({"worldedit.tool.replacer"})
public static void repl(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
BaseBlock targetBlock = we.getBlock(player, args.getString(0));
session.setTool(player.getItemInHand(), new BlockReplacer(targetBlock));
player.print("Block replacer tool equipped. Right click with a pickaxe.");
}
@Command(
aliases = {"cycler"},
usage = "",
desc = "Block data cycler tool",
min = 0,
max = 0
)
@CommandPermissions({"worldedit.tool.data-cycler"})
public static void cycler(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
session.setTool(player.getItemInHand(), new BlockDataCyler());
player.print("Block cycler tool equipped. Right click with a pickaxe.");
}
@Command(
aliases = {"brush", "b"},
desc = "Brush tool"
)
@NestedCommand({BrushCommands.class})
public static void brush(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
}
}

Datei anzeigen

@ -0,0 +1,93 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010 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.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.minecraft.util.commands.NestedCommand;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.masks.Mask;
/**
* Tool commands.
*
* @author sk89q
*/
public class ToolUtilCommands {
@Command(
aliases = {"/", ","},
usage = "",
desc = "Toggle the super pickaxe pickaxe function",
min = 0,
max = 0
)
@CommandPermissions({"worldedit.superpickaxe"})
public static void togglePickaxe(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
if (session.toggleSuperPickAxe()) {
player.print("Super pick axe enabled.");
} else {
player.print("Super pick axe disabled.");
}
}
@Command(
aliases = {"pickaxe", "pa", "spa"},
desc = "Select super pickaxe mode"
)
@NestedCommand({SuperPickaxeCommands.class})
public static void pickaxe(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
}
@Command(
aliases = {"tool", "t"},
desc = "Select a tool to bind"
)
@NestedCommand({ToolCommands.class})
public static void tool(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
}
@Command(
aliases = {"mask"},
usage = "[mask]",
desc = "Set the brush mask",
min = 0,
max = 1
)
public static void mask(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
if (args.argsLength() == 0) {
session.getBrushTool(player.getItemInHand()).setMask(null);
player.print("Brush mask disabled.");
} else {
Mask mask = we.getBlockMask(player, args.getString(0));
session.getBrushTool(player.getItemInHand()).setMask(mask);
player.print("Brush mask set.");
}
}
}

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.filters;
package com.sk89q.worldedit.filtering;
import java.awt.image.Kernel;

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.filters;
package com.sk89q.worldedit.filtering;
import java.awt.image.Kernel;

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.filters;
package com.sk89q.worldedit.filtering;
import java.awt.image.Kernel;

Datei anzeigen

@ -17,26 +17,40 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe.brushes;
package com.sk89q.worldedit.masks;
import java.util.HashSet;
import java.util.Set;
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;
/**
* A filter that matches blocks based on block types.
*
* @author sk89q
*/
public class BlockTypeMask implements Mask {
private Set<Integer> types;
public HollowCylinderBrushShape(BaseBlock targetBlock, int radius, int height) {
this.targetBlock = targetBlock;
this.radius = radius;
this.height = height;
public BlockTypeMask() {
types = new HashSet<Integer>();
}
public void build(EditSession editSession, Vector pos)
throws MaxChangedBlocksException {
editSession.makeHollowCylinder(pos, targetBlock, radius, height);
public BlockTypeMask(Set<Integer> types) {
this.types = types;
}
public BlockTypeMask(int type) {
this();
add(type);
}
public void add(int type) {
types.add(type);
}
public boolean matches(EditSession editSession, Vector pos) {
return types.contains(editSession.getBlockType(pos));
}
}

Datei anzeigen

@ -0,0 +1,29 @@
// $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.masks;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
public class ExistingBlockMask implements Mask {
public boolean matches(EditSession editSession, Vector pos) {
return editSession.getBlockType(pos) != 0;
}
}

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.masks;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
/**
* Base matcher for the block filtering framework. Implementing classes
* can be used to filter blocks to set or replace
*
* @author sk89q
*/
public interface Mask {
/**
* Given a block position, this method returns true if the block at
* that position matches the filter. Block information is not provided
* as getting a BaseBlock has unneeded overhead in most block querying
* situations (enumerating a chest's contents is a waste, for example).
*
* @param pos
* @return
*/
public boolean matches(EditSession editSession, Vector pos);
}

Datei anzeigen

@ -61,7 +61,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
*/
public EditSession remember() {
EditSession editSession =
new EditSession(server, player.getWorld(),
new EditSession(player.getWorld(),
session.getBlockChangeLimit(), session.getBlockBag(player));
editSession.enableQueue();
editSessions.add(editSession);

Datei anzeigen

@ -1,79 +0,0 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010 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;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.superpickaxe.brushes.BrushShape;
/**
* Builds a shape at the place being looked at.
*
* @author sk89q
*/
public class Brush implements SuperPickaxeMode {
private boolean nonReplacing;
public Brush(boolean nonReplacing) {
this.nonReplacing = nonReplacing;
}
@Override
public boolean act(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {
WorldVector target = player.getBlockTrace(500);
if (target == null) {
player.printError("No block in sight!");
return true;
}
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);
if (nonReplacing) {
editSession.disableReplacing();
}
try {
shape.build(editSession, target);
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {
if (bag != null) {
bag.flushChanges();
}
editSession.enableReplacing();
session.remember(editSession);
}
return true;
}
}

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe;
package com.sk89q.worldedit.tools;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
@ -28,7 +28,7 @@ import com.sk89q.worldedit.blocks.BlockID;
*
* @author sk89q
*/
public class AreaPickaxe implements SuperPickaxeMode {
public class AreaPickaxe implements BlockTool {
private static final BaseBlock air = new BaseBlock(0);
private int range;
@ -52,9 +52,9 @@ public class AreaPickaxe implements SuperPickaxeMode {
if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
return true;
}
EditSession editSession = new EditSession(server, world,
session.getBlockChangeLimit());
EditSession editSession =
new EditSession(world, session.getBlockChangeLimit());
try {
for (int x = ox - range; x <= ox + range; x++) {

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe;
package com.sk89q.worldedit.tools;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BlockID;
@ -27,7 +27,7 @@ import com.sk89q.worldedit.blocks.BlockID;
*
* @author sk89q
*/
public class BlockDataCyler implements SuperPickaxeMode {
public class BlockDataCyler implements BlockTool {
@Override
public boolean act(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {

Datei anzeigen

@ -17,18 +17,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe;
package com.sk89q.worldedit.tools;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.blocks.BaseBlock;
/**
* A smode that replaces one block.
* A mode that replaces one block.
*
* @author sk89q
*/
public class BlockReplacer implements SuperPickaxeMode {
public class BlockReplacer implements BlockTool {
private BaseBlock targetBlock;
public BlockReplacer(BaseBlock targetBlock) {
@ -42,7 +42,7 @@ public class BlockReplacer implements SuperPickaxeMode {
BlockBag bag = session.getBlockBag(player);
LocalWorld world = clicked.getWorld();
EditSession editSession = new EditSession(server, world, -1, bag);
EditSession editSession = new EditSession(world, -1, bag);
try {
editSession.setBlock(clicked, targetBlock);

Datei anzeigen

@ -17,20 +17,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe;
package com.sk89q.worldedit.tools;
import com.sk89q.worldedit.*;
/**
* Represents a super pickaxe mode.
* Represents a tool that uses a block..
*
* @author sk89q
*/
public interface SuperPickaxeMode {
public interface BlockTool extends Tool {
/**
* Perform the action. Should return true to deny the default
* action.
*
* @param server
* @param config
* @param player
* @param session
* @param clicked

Datei anzeigen

@ -0,0 +1,159 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010 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.tools;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.masks.Mask;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.patterns.SingleBlockPattern;
import com.sk89q.worldedit.tools.brushes.BrushShape;
import com.sk89q.worldedit.tools.brushes.SphereBrush;
/**
* Builds a shape at the place being looked at.
*
* @author sk89q
*/
public class Brush implements TraceTool {
private Mask mask = null;
private BrushShape brush = new SphereBrush();
private Pattern material = new SingleBlockPattern(new BaseBlock(BlockID.COBBLESTONE));
private int size = 1;
/**
* Get the filter.
*
* @return the filter
*/
public Mask getMask() {
return mask;
}
/**
* Set the block filter used for identifying blocks to replace.
*
* @param filter the filter to set
*/
public void setMask(Mask filter) {
this.mask = filter;
}
/**
* Set the brush.
*
* @param brush
*/
public void setBrush(BrushShape brush) {
this.brush = brush;
}
/**
* Get the current brush.
*
* @return
*/
public BrushShape getBrush() {
return brush;
}
/**
* Set the material.
*
* @param material
*/
public void setFill(Pattern material) {
this.material = material;
}
/**
* Get the material.
*
* @return
*/
public Pattern getMaterial() {
return material;
}
/**
* Get the set brush size.
*
* @return
*/
public int getSize() {
return size;
}
/**
* Set the set brush size.
*
* @param size
*/
public void setSize(int size) {
this.size = size;
}
/**
* Perform the action. Should return true to deny the default
* action.
*
* @param player
* @param session
* @return true to deny
*/
@Override
public boolean act(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session) {
WorldVector target = player.getBlockTrace(500);
if (target == null) {
player.printError("No block in sight!");
return true;
}
BlockBag bag = session.getBlockBag(player);
EditSession editSession;
if (mask == null) {
editSession = new EditSession(target.getWorld(),
session.getBlockChangeLimit(), bag);
} else {
editSession = new ReplacingEditSession(target.getWorld(),
session.getBlockChangeLimit(), bag, mask);
}
try {
brush.build(editSession, target, material, size);
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {
if (bag != null) {
bag.flushChanges();
}
session.remember(editSession);
}
return true;
}
}

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe;
package com.sk89q.worldedit.tools;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.*;
@ -27,14 +27,14 @@ import com.sk89q.worldedit.blocks.*;
*
* @author sk89q
*/
public class QueryTool implements SuperPickaxeMode {
public class QueryTool implements BlockTool {
@Override
public boolean act(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {
LocalWorld world = clicked.getWorld();
BaseBlock block = (new EditSession(server, world, 0)).rawGetBlock(clicked);
BaseBlock block = (new EditSession(world, 0)).rawGetBlock(clicked);
player.print("\u00A79@" + clicked + ": " + "\u00A7e"
+ "Type: " + block.getType() + "\u00A77" + " ("

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe;
package com.sk89q.worldedit.tools;
import java.util.HashSet;
import java.util.Set;
@ -31,7 +31,7 @@ import com.sk89q.worldedit.blocks.BlockID;
*
* @author sk89q
*/
public class RecursivePickaxe implements SuperPickaxeMode {
public class RecursivePickaxe implements BlockTool {
private static final BaseBlock air = new BaseBlock(0);
private int range;
@ -54,8 +54,8 @@ public class RecursivePickaxe implements SuperPickaxeMode {
return true;
}
EditSession editSession = new EditSession(server, world,
session.getBlockChangeLimit());
EditSession editSession =
new EditSession(world, session.getBlockChangeLimit());
try {
recurse(server, editSession, world, clicked.toBlockVector(),

Datei anzeigen

@ -17,18 +17,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe;
package com.sk89q.worldedit.tools;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.superpickaxe.brushes.BrushShape;
import com.sk89q.worldedit.tools.brushes.BrushShape;
/**
* Builds a sphere at the place being looked at.
*
* @author sk89q
*/
public class ReplacingBrush implements SuperPickaxeMode {
public class ReplacingBrush implements Tool {
public boolean act(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {
WorldVector target = player.getBlockTrace(500);

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe;
package com.sk89q.worldedit.tools;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BlockID;
@ -27,7 +27,7 @@ import com.sk89q.worldedit.blocks.BlockID;
*
* @author sk89q
*/
public class SinglePickaxe implements SuperPickaxeMode {
public class SinglePickaxe implements BlockTool {
@Override
public boolean act(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {

Datei anzeigen

@ -0,0 +1,29 @@
// $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.tools;
/**
* Represents a tool. This interface alone defines nothing. A tool also
* has to implement <code>BlockTool</code> or <code>TraceTool</code>.
*
* @author sk89q
*/
public abstract interface Tool {
}

Datei anzeigen

@ -0,0 +1,45 @@
// $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.tools;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.ServerInterface;
/**
* Represents a tool that does not require a block.
*
* @author sk89q
*/
public interface TraceTool extends Tool {
/**
* Perform the action. Should return true to deny the default
* action.
*
* @param server
* @param config
* @param player
* @param session
* @return true to deny
*/
public boolean act(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session);
}

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe;
package com.sk89q.worldedit.tools;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.util.TreeGenerator;
@ -27,7 +27,7 @@ import com.sk89q.worldedit.util.TreeGenerator;
*
* @author sk89q
*/
public class TreePlanter implements SuperPickaxeMode {
public class TreePlanter implements BlockTool {
private TreeGenerator gen;
public TreePlanter(TreeGenerator gen) {
@ -40,7 +40,7 @@ public class TreePlanter implements SuperPickaxeMode {
LocalWorld world = clicked.getWorld();
EditSession editSession =
new EditSession(server, world, session.getBlockChangeLimit());
new EditSession(world, session.getBlockChangeLimit());
try {
if (!gen.generate(editSession, clicked.add(0, 1, 0))) {

Datei anzeigen

@ -17,11 +17,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe.brushes;
package com.sk89q.worldedit.tools.brushes;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.patterns.Pattern;
/**
* Represents a shape.
@ -34,8 +35,10 @@ public interface BrushShape {
*
* @param build
* @param pos
* @param mat
* @param size
* @throws MaxChangedBlocksException
*/
public void build(EditSession editSession, Vector pos)
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
throws MaxChangedBlocksException;
}

Datei anzeigen

@ -17,23 +17,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe.brushes;
package com.sk89q.worldedit.tools.brushes;
import com.sk89q.worldedit.CuboidClipboard;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.patterns.Pattern;
public class ClipboardBrushShape implements BrushShape {
public class ClipboardBrush implements BrushShape {
private CuboidClipboard clipboard;
private boolean noAir;
public ClipboardBrushShape(CuboidClipboard clipboard, boolean noAir) {
public ClipboardBrush(CuboidClipboard clipboard, boolean noAir) {
this.clipboard = clipboard;
this.noAir = noAir;
}
public void build(EditSession editSession, Vector pos)
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
throws MaxChangedBlocksException {
clipboard.place(editSession,
pos.subtract(clipboard.getSize().divide(2)), noAir);

Datei anzeigen

@ -17,26 +17,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe.brushes;
package com.sk89q.worldedit.tools.brushes;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.patterns.Pattern;
public class CylinderBrushShape implements BrushShape {
private BaseBlock targetBlock;
private int radius;
public class CylinderBrush implements BrushShape {
private int height;
public CylinderBrushShape(BaseBlock targetBlock, int radius, int height) {
this.targetBlock = targetBlock;
this.radius = radius;
public CylinderBrush(int height) {
this.height = height;
}
public void build(EditSession editSession, Vector pos)
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
throws MaxChangedBlocksException {
editSession.makeCylinder(pos, targetBlock, radius, height);
editSession.makeCylinder(pos, mat, size, height);
}
}

Datei anzeigen

@ -17,24 +17,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe.brushes;
package com.sk89q.worldedit.tools.brushes;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.patterns.Pattern;
public class SphereBrushShape implements BrushShape {
private BaseBlock targetBlock;
private int radius;
public class HollowCylinderBrush implements BrushShape {
private int height;
public SphereBrushShape(BaseBlock targetBlock, int radius) {
this.targetBlock = targetBlock;
this.radius = radius;
public HollowCylinderBrush(int height) {
this.height = height;
}
public void build(EditSession editSession, Vector pos)
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
throws MaxChangedBlocksException {
editSession.makeSphere(pos, targetBlock, radius, true);
editSession.makeHollowCylinder(pos, mat, size, height);
}
}

Datei anzeigen

@ -17,24 +17,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.superpickaxe.brushes;
package com.sk89q.worldedit.tools.brushes;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.patterns.Pattern;
public class HollowSphereBrushShape implements BrushShape {
private BaseBlock targetBlock;
private int radius;
public HollowSphereBrushShape(BaseBlock targetBlock, int radius) {
this.targetBlock = targetBlock;
this.radius = radius;
public class HollowSphereBrush implements BrushShape {
public HollowSphereBrush() {
}
public void build(EditSession editSession, Vector pos)
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
throws MaxChangedBlocksException {
editSession.makeSphere(pos, targetBlock, radius, false);
editSession.makeSphere(pos, mat, size, false);
}
}

Datei anzeigen

@ -0,0 +1,35 @@
// $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.tools.brushes;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.patterns.Pattern;
public class SphereBrush implements BrushShape {
public SphereBrush() {
}
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
throws MaxChangedBlocksException {
editSession.makeSphere(pos, mat, size, true);
}
}