diff --git a/src/com/sk89q/worldedit/EditSession.java b/src/com/sk89q/worldedit/EditSession.java index acbb76d3f..5d8359273 100755 --- a/src/com/sk89q/worldedit/EditSession.java +++ b/src/com/sk89q/worldedit/EditSession.java @@ -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; diff --git a/src/com/sk89q/worldedit/WorldEditController.java b/src/com/sk89q/worldedit/WorldEditController.java index 17a2964d8..23a2ef3ef 100644 --- a/src/com/sk89q/worldedit/WorldEditController.java +++ b/src/com/sk89q/worldedit/WorldEditController.java @@ -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] - 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]); diff --git a/src/com/sk89q/worldedit/superpickaxe/PineTreePlanter.java b/src/com/sk89q/worldedit/superpickaxe/PineTreePlanter.java new file mode 100644 index 000000000..3da511ae3 --- /dev/null +++ b/src/com/sk89q/worldedit/superpickaxe/PineTreePlanter.java @@ -0,0 +1,49 @@ +// $Id$ +/* + * WorldEdit + * Copyright (C) 2010 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; + +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; + } + +}