Minecolonies & Several Improvements

in utopian-io •  2 months ago

Hi everyone, I almost finished most of my backlog and am coming to more recent changes now.

First of all, I noticed that we had some duplicated code in the warehouse tileEntity handling, while we changed the handling in the super class we didn't adapt it in the warehouse which caused some bugs.

With a relatively simple solution.

Another long term bug was farmers not working the fields when there were multiple was related to these farmers not freeing the field case it was assigned to them.

Which caused them to go back and forth without actually doing anything.

Citizen Building Assignment:

Something people have been complaining about for a long time is the citizen housing assignment where citizens would have to be unassigned from one building to be then assigned at another causing a lot of running around.

Where we were previously filter only by citizens without a home.

.filter(citizen -> citizen.getHomeBuilding() == null).sorted(Comparator.comparing(CitizenDataView::getName))

we now sort by the ones not assigned to the current building and not assigned to a barracks tower.

.filter(cit -> cit.getHomeBuilding() == null || !(colony.getBuilding(cit.getHomeBuilding()) instanceof BuildingBarracksTower.View) && !cit.getHomeBuilding().equals(building.getID()))

Additionally, to allow players to find the perfect citizen for the home I added a bit more information as the distance of the work and home building.

So we would now display the distance to the work building and, if the worker has a job the current distance he has to do, if not we just display the position.

At the site of the building I then only had to make sure that we can unassign a worker and then assign to another building at the same time.

Combatibility:

Many minecraft players know it, besides the normal overworld there are many other popular gamemodes as skyblock where you'd play on an island in the sky or stoneblock where you'd be underground.

In these gamemodes it's usually much more difficult to get certain resources.

For these resources we set some things up to make minecolonies more enjoyable in these settings.

The first thing I did was adding to the composter a way to obtain not only compost but also dirt (a rare resources in these game modes).

For that, I added, programatically, a button to the GUI of the composter.

Which allows the player to choose if he wants dirt or compost as a reward.

The setup method would check what the current mode is and then name the button accordingly to the option.

Then on switching we would choose the mode and send the result to the server.

For which I registered a message.

Which sets this on arrival on the server site.

The building then got this additional value.

Takes care of writing and reading from file and of sending the data to the client side.

And, depending on which one is activated the worker would then return a quantity which is defined in the config.

As a second setting, we allowed the miner to get a certain quantity of ores from mining normal stone.

Here, we made it possible to select the percentage, which blocks should result in the additional chance and which ores with which multiplier get dropped.

This allows the player or modpack creater to define extra modded ores to be configured.

To avoid overhead from loading this I added it to our Compatibility class.

Where, on loading, we'd run through the player defined strings. Check if the string is correctly configured (separated by "!") and if the item actually exists. If so we would add the configured quantity of this item to the list.

Additionally, I added a way to detect if a block is such a lucky block.
Here we would check if the stack exists, and if so check if either the name of the stack matches the configured name or at least the tag (ore id) matches.

Finally, I added a way to get a random ore.

The easiest way for me was to shuffle this array and then just return the first one of it.

At the AI, I only had to override the triggerMinedBlock method and add some logic to check if the block is one of the lucky blocks and then add a random ore to the inventory.

Pull Requests:

https://github.com/ldtteam/minecolonies/pull/3325/files
https://github.com/ldtteam/minecolonies/pull/3314/files
https://github.com/ldtteam/minecolonies/pull/3319/files

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  
  • Great article with all the elements of success. I really liked the mentions of other minecraft mods like SkyBlocks who @immanuel94 regularly contribute to Utopian.
  • The code could use more inline comments when the functions are bigger. This is the only example I could find in this contribution this time.

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]

·

Thank you for your review, @helo! Keep up the good work!

Hi @raycoms!

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

Hi, @raycoms!

You just got a 10.54% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.

This post has been included in the latest edition of SoS Daily News - a digest of all you need to know about the State of Steem.

Hey, @raycoms!

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!