One day, when I was farming trees once again I kind of wanted to be faster at it. I created a plugin to speed it up!
Now, when you use a golden axe (or whatever items specified in the config) on a tree, it will be fully destroyed upwards from the block you hit it at! Now that’s fast! Additionally you can configure if the item that’s used, gets durability damage.
Please note: The current recommended version is only partly tested! Please report any bugs!
Commands & Permissions
Main Permission (needed to destroy trees)TreeDestroyage.destroy
/trds reload:TreeDestroyage.reload /trds set <option> [value]: TreeDestroyage.set
Using the set command you should be able to directly set configuration values.
Default configuration
# Only activate when the player hits the very bottom of the tree.
baseOnly=false
# Whether the axe should also log the tree downwards.
breakDownwards=true
# Whether to consume durability from tools that support it.
consumeDurability=true
# Enable/disable this plugin functionality
enabled=true
# List of items that can be used as axe
items=[
"minecraft:golden_axe",
"minecraft:diamond_axe"
]
# Maximum amount of blocks that will be destroyed in one hit
maxBlocks=200
# Place the according sapling after logging the tree.
placeSapling=true
# Amount of time in seconds to protect the placed sapling. (0 to disable)
saplingProtection=60
version=7
They are dropped. Right now I’m dropping them using the /summon command because as far as I experienced the implementation of the data api isn’t far enough to support the different wood variants.
Not yet but I think I can implement it. I’m just not sure how to do it. (Maybe fire a ChangeBlockEvent.Break with all the transactions and player as cause?)
Creating the Item works but setting the log type doesn’t work for me, which is what I assume isn’t implemented yet in SpongeForge.
(Using this code it only drops the log item with the default (or first) type:
BlockState state = blockSnapshotTransaction.getOriginal().getState();
Object trait = state.getTraitValues().toArray()[1];
Location loc = blockSnapshotTransaction.getOriginal().getLocation().get();
final ItemStackBuilder builder = getGame().getRegistry().createItemBuilder();
ItemStack itemStack = null;
if (state.getType() == BlockTypes.LOG) {
itemStack = builder.itemType(ItemTypes.LOG).build();
id = "minecraft:log";
if (trait.toString().equalsIgnoreCase("oak")) {
damage = "0";
itemStack.offer(Keys.TREE_TYPE, TreeTypes.OAK);
} else if (trait.toString().equalsIgnoreCase("spruce")) {
damage = "1";
itemStack.offer(Keys.TREE_TYPE, TreeTypes.SPRUCE);
} else if (trait.toString().equalsIgnoreCase("birch")) {
damage = "2";
itemStack.offer(Keys.TREE_TYPE, TreeTypes.BIRCH);
} else if (trait.toString().equalsIgnoreCase("jungle")) {
damage = "3";
itemStack.offer(Keys.TREE_TYPE, TreeTypes.JUNGLE);
}
} else if (state.getType() == BlockTypes.LOG2) {
id = "minecraft:log2";
itemStack = builder.itemType(ItemTypes.LOG2).build();
if (trait.toString().equalsIgnoreCase("acacia")) {
damage = "0";
itemStack.offer(Keys.TREE_TYPE, TreeTypes.ACACIA);
} else if (trait.toString().equalsIgnoreCase("dark_oak")) {
damage = "1";
itemStack.offer(Keys.TREE_TYPE, TreeTypes.DARK_OAK);
}
}
Entity entity = cause.getWorld().createEntity(EntityTypes.ITEM, blockSnapshotTransaction.getOriginal().getPosition()).get(); // 'cause' is the player
entity.offer(Keys.REPRESENTED_ITEM, itemStack.createSnapshot());
cause.getWorld().spawnEntity(entity, Cause.empty());