|
23 | 23 | import com.sk89q.worldedit.LocalConfiguration; |
24 | 24 | import com.sk89q.worldedit.LocalSession; |
25 | 25 | import com.sk89q.worldedit.MaxChangedBlocksException; |
| 26 | +import com.sk89q.worldedit.WorldEditException; |
26 | 27 | import com.sk89q.worldedit.entity.Player; |
27 | 28 | import com.sk89q.worldedit.extension.platform.Actor; |
28 | 29 | import com.sk89q.worldedit.extension.platform.Platform; |
29 | | -import com.sk89q.worldedit.math.BlockVector3; |
| 30 | +import com.sk89q.worldedit.function.generator.TreeGenerator; |
30 | 31 | import com.sk89q.worldedit.util.Direction; |
31 | 32 | import com.sk89q.worldedit.util.Location; |
32 | 33 | import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; |
@@ -55,21 +56,15 @@ public boolean actPrimary(Platform server, LocalConfiguration config, Player pla |
55 | 56 |
|
56 | 57 | try (EditSession editSession = BlockTool.createEditSession(player, session, clicked)) { |
57 | 58 | try { |
58 | | - boolean successful = false; |
59 | | - |
60 | | - final BlockVector3 pos = clicked.toVector().add(0, 1, 0).toBlockPoint(); |
61 | | - for (int i = 0; i < 10; i++) { |
62 | | - if (player.getWorld().generateTree(treeType, editSession, pos)) { |
63 | | - successful = true; |
64 | | - break; |
65 | | - } |
66 | | - } |
| 59 | + boolean successful = new TreeGenerator(editSession, treeType).apply(clicked.toVector().toBlockPoint()); |
67 | 60 |
|
68 | 61 | if (!successful) { |
69 | 62 | player.printError(TranslatableComponent.of("worldedit.tool.tree.obstructed")); |
70 | 63 | } |
71 | 64 | } catch (MaxChangedBlocksException e) { |
72 | 65 | player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes")); |
| 66 | + } catch (WorldEditException ignored) { |
| 67 | + // This should never happen |
73 | 68 | } finally { |
74 | 69 | session.remember(editSession); |
75 | 70 | } |
|
0 commit comments