[API 7.0.0] 🌲 TreeDestroyage 14-DEV


#1

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.

:exclamation: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

:floppy_disk: - Download

Recommended version - 0.14-DEV (For Sponge 7.0.0API)
Jenkins for DEV versions (expect bugs and report them to GitHub please!)

Changelog & Source: https://github.com/nylser/TreeDestroyage

Please report any bugs you encounter! Thank you! I’m always open for feature requests!


Timber mod?
Need Plugins
Timber mod?
#2

Does this drop the wood blocks or are the block just getting removed from the world?


#3

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.


#4

Perfect. Exactly what i wanted :smile:

Another question/feature idea:
could you make the required tool (to use the plugin) configurable?


#5

Definitely a possibility! Will do it when I got some more time :smile:


#6

Update: It's now possible to change the required item/tool (it can be any Item in MC)


#7

Does this support marking the blocks destroyed by the tool as caused by the player? Would help logging / grief prevention plugins a ton.


#8

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?)


#9

With the newest version, it does.


#10

The Data API currently supports log variants, I've managed to spawn some Birch Log using it.


#11

Oh nice, could you give me a code snippet of how you did it?


#12
Item item = (Item) player.getWorld().createEntity(EntityTypes.ITEM, player.getLocation().getPosition()).get();
item.offer(item.getItemData().item().set(itemStack.createSnapshot()));
player.getWorld().spawnEntity(item, Cause.empty());

itemStack is the Birch Log ItemStack
player is the player at whose position the item will spawn.


#13

Thank you, but actually my problem is creating the specific log ItemStack


#14

Make it simpler:

Entity entity = player.getWorld().createEntity(EntityTypes.ITEM, player.getLocation().getPosition()).get();
entity.offer(Keys.REPRESENTED_ITEM, itemstack.createSnapshot());
player.getWorld().spawnEntity(item, Cause.of(myPluginInstance));

To actually make the ItemStack, you can do the following:

final ItemStackBuilder builder = plugin.game.getRegistry().createItemBuilder();
final ItemStack logItem = builder.itemType(ItemTypes.LOG)
  .quantity(1)
  .build();

#15

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());

#16

It is being implemented by @lucdon, but not finished. See the Issue on Github


#17

@nylser treedata is implemented


#18

Update: newest version now drops item normally, not using commands anymore. Thanks to the TreeData implementation of @lucdon :smile:!


#19

Update to newest sponge version.


#20

This requires updating to the newest sponge.

Also, can you implement multiple axe items configurable, instead of just one?