Hi everyone, been a while since I last posted going to try posting more frequently!
I've done some more work on the minecraft mod Minecolonies and added children to the mod.
The first step was creating the visual children, without there wouldnt be any. As I am more a technical than a creative guy I went with rendering the existing citizens smaller instead of creating new models for them myself. It took a bit of trying around till I found that Minecraft already has support for child entities, which made the small-size display as simple as this:
This flag has to be saved at various places, in the Data structure of minecolonies. For the children we got the following classes:
- CitizenData which contains any meta information about the citizens.
- CitizenDataView the client-side representation of the CitizenData
- EntityCitizen the actual citizen entity, which is client and serverside.
Creating children
Now lets create the children! Minecolonies has so called "Citizen Huts", in which the inhabitants of the colony are living.
Those huts are now trying to spawn children periodically if a male and a female citizen are living there and the colony is not maxed out. To check whether the parents are present the citizen hut simply remembers them upon moving in:
To create a new citizen we first need a new CitizenData entry for them, since it holds all the metadata:
Children will learn from their parents through averaging their attributes, with some randomness factor as natural abilities:
After creating the necessary data for our new child citizen we can spawn it and notify the players in the colony about it.
In recap colony children mechanic is now following these rules:
- Mom / dad entities are required and chosen randomly in a citizen hut.
- Children inherit stats from their parents, with average +-2.
- Children get assigned to a free housing slot in the colony to be raised there. If the house has an adult living there the child takes its last name and gets raised by it.
Children Behaviour and AI
Finally the children need some activities so we're adding a childAI to them. For AI's we're using a state machine, which I'll explain more about in a future post. For our AI we're defining states and transitions to use:
To make the colony look more lively the children got two movement activities:
- They randomly follow other entities, even critters, around, as children are naturally very curious!
- They randomly visit existing buildings in the colony, watching grownups at work.
For following other entities we're checking entities around the child every 150 game ticks. The check happens in a simple box radius around the child entity, and is not executed too often to not affect performance much.
Once we found a target we're storing a weak reference to it, a weak reference is so the game is allowed to unload the entity when it wants to. After finding a target the child's pathing is set to follow the target around. Visiting other building works in a similar fashion, we randomly choose a building in the colony and task the child to walk there.
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
Hire
, you can now hire people? Why not talk about that in your post? See:WindowTownHallHireCitizen.java
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? Chat with us on Discord.
[utopian-moderator]
you're right the PR contains another feature, which I did not add as I thought the post would become too long. The 2. Feature is the ability to "Send Recruitment Packages" with resources out into the void and find a new citizen this way. This lets players get a new Adult citizen quickly at the cost of resources, for those interested it looks like this:
Thank you for your review, @helo! Keep up the good work!
I love having the kids running around, fills the colony with much more live =D
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
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!
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
Hey buddy are you a Developer?
Posted using Partiko Messaging
Congratulations @someaddons! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!