Hi everyone, I'm SomeAddons and recently joined the Minecolonies Team. The first Task I contributed was the mod compatibility with the Dynamic Trees mod and minecolonies Lumberjack NPC, which I'll talk about a bit here.
Dynamic Trees
Dynamic trees is a minecraft mod which adds dynamically grown trees and can be found on https://github.com/ferreusveritas/DynamicTrees
This image shows a dynamic tree which has various branches of different size, making them look more realistic:
Now here is the default vanilla minecraft tree, which is a lot simpler as it only consists of a few wooden blocks and some leaves ontop:
Compatibility
As can be seen dynamic trees are quite a bit more complex than the normal trees, especially if I want to chop them down with the Lumberjack NPC. Now to implement it I needed to make it optional since not every players is using the dynamic tree mod, so it is not always present. For this I've used a compatibility class with optional overrides.
In DynamicTreeProxy.java:
In DynamicTreeCompat.java:
We have a base method which always returns false and a method which contains the actual functionality but only overrides when the dynamic tree modID is present, this is how all compatibility functions at minecolonies work.
Checking a block for dynamic trees becomes simple as this:
Now since I can check for dynamic trees the actual logic for the Lumberjack can be created.
Tree detection
This is an important part for the Lumberjack NPC, as he has to recognize which blocks represent a tree. The checkTree method does it:
Here I check for Dynamic Trees blocks and it's growth using a radius property which says how large a dynamic tree branch has grown:
Default minecraft trees do not have a growth value like this at all, they're either still a sapling or fully grown.
Apart from growth dynamic trees are detected the same way as default minecraft trees, except that they do not have a top wood log, just a bottom one. Which works just fine since dynamic trees are felled by chopping its lowest wooden block, unlike normal trees where you have to chop every single block of the tree.
After detecting the tree I calculate its sapling from a leaf to let the Lumberjack replant the tree after felling. This is done by checking the Leafblock of the tree for its drops, in minecraft the saplings always drop from leaves.
Chopping Tree
Next after detecting the tree and which sapling to use to replant is chopping the dynamic tree. Until now "chopping" was done by replacing the wood block of the tree with air and putting it into the Lumberjacks inventory as drop, but this does not work for dynamic trees. For those you chop the lowest wooden block and the tree is completely felled. Luckily the dynamic tree mod has a method we can use to fell the tree. To use this I've added a runnable as optional block break action to the mineBlock method:
The runnable for dynamic trees uses a function implemented by dynamic tree's so it is created in the Dynamic tree compatibility class again:
Here I'm creating a fakeplayer entity which allows the Lumberjack to act as if a player would fell the tree, a fakeplayer is required to use dynamic tree's chopping method. Since fakeplayers are somewhat more expensive to generate I just create one per dimension and save them in a hashmap, using the dimension id as key.
Finally as a result the lumberjack does chop the dynamic tree:
I hope you liked this little write-up, looking forward to write some more on further updates to minecolonies.
Repository:
https://github.com/ldtteam/minecolonies
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Actually the "blocks at an angle" is smart use of an entity by dynamic trees :D
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you for your review, @helo! Keep up the good work!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey, @someaddons!
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Great job, until now I didn't see yet how the dynamic trees look and get fell. Looks amazing!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hello! Your post has been resteemed and upvoted by @ilovecoding because we love coding! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On!
Reply !stop to disable the comment. Thanks!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @someaddons! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hi @someaddons!
Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @someaddons! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @someaddons! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @someaddons! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @someaddons! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word
STOP
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @someaddons! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @someaddons! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word
STOP
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @someaddons! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word
STOP
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit