Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add smart sapling planting #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ AhosallTreeCapitator is a simple and efficient plugin that automates the process

- Compatible with all types of Minecraft axes and trees.
- Players who only want to mine one block can use sneaking mode to disable the capping of entire trees.
- Trees are replanted after cutting them above the first block of the tree, if you cut them on the first block the saplings will not be replanted.

## Compatibility

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>xyz.ahosall.treecapitator</groupId>
<artifactId>ahosall-tree-capitator</artifactId>
<version>1.0.1</version>
<version>1.1.0</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ private void processConnectedWood(Block block, Player player, ItemStack tool, Se

adjacentBlock.getWorld().playSound(player.getLocation(), Sound.BLOCK_WOOD_BREAK, 1.0f, 1.0f);
adjacentBlock.getWorld().dropItemNaturally(adjacentBlock.getLocation(), new ItemStack(adjacentBlock.getType()));
adjacentBlock.setType(Material.AIR);

Material blockMaterial = Material.AIR;
Boolean isDirt = adjacentBlock.getRelative(0, -1, 0).getType().equals(Material.DIRT);

if (isDirt)
blockMaterial = Material.getMaterial(adjacentBlock.getType().toString().replace("_LOG", "_SAPLING"));

adjacentBlock.setType(blockMaterial);

updateDurability(tool);
processConnectedWood(adjacentBlock, player, tool, processedBlocks);
Expand Down