Added pine tree tool.

This commit is contained in:
sk89q 2011-01-17 17:05:18 -08:00
parent 39914155b6
commit df836d285d
3 changed files with 58 additions and 1 deletions

View File

@ -1882,7 +1882,7 @@ public class EditSession {
*
* @param basePos
*/
private void makePineTree(Vector basePos) throws MaxChangedBlocksException {
public void makePineTree(Vector basePos) throws MaxChangedBlocksException {
int trunkHeight = (int) Math.floor(Math.random() * 2) + 3;
int height = (int) Math.floor(Math.random() * 5) + 8;

View File

@ -125,6 +125,7 @@ public class WorldEditController {
commands.put("/none", "Switch to no tool");
commands.put("/info", "Switch to the info tool");
commands.put("/tree", "Switch to the tree tool");
commands.put("/pinetree", "Switch to the pine tree tool");
commands.put("/bigtree", "Switch to the big tree tool");
commands.put("/repl", "[ID] - Switch to the block replacer tool");
commands.put("/brush", "[ID] <Radius> <NoReplace?> - Switch to the sphere brush tool");
@ -684,6 +685,13 @@ public class WorldEditController {
player.print("Big tree tool equipped. Right click with a pickaxe.");
return true;
// Pine tree tool
} else if (split[0].equalsIgnoreCase("/pinetree")) {
checkArgs(split, 0, 0, split[0]);
session.setRightClickMode(new PineTreePlanter());
player.print("Pine tree tree tool equipped. Right click with a pickaxe.");
return true;
// Info tool
} else if (split[0].equalsIgnoreCase("/info")) {
checkArgs(split, 0, 0, split[0]);

View File

@ -0,0 +1,49 @@
// $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.*;
/**
* Plants a pine tree.
*
* @author sk89q
*/
public class PineTreePlanter implements SuperPickaxeMode {
@Override
public boolean act(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {
LocalWorld world = clicked.getWorld();
EditSession editSession =
new EditSession(server, world, session.getBlockChangeLimit());
try {
editSession.makePineTree(clicked.add(0, 1, 0));
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {
session.remember(editSession);
}
return true;
}
}