Minecolonies & The Crusher

in #utopian-io6 years ago

Hi everyone, additional to the changes to the miner and composter we also created a worker which allows the colony to produce materials which are difficult to get depending on the location in the world (Especially in the sky or under the earth).

For that reason, we created the crusher!

The crusher is able to transform certain vanilla blocks into others.

This way he crushes cobblestone to gravel, gravel to sand and sand to clay at the cost of 2:1 each (considering that in the process parts of the stone will go missing etc).

Setup:

As always we start with setting up a new block for the hut.

And then register the block and item.

Not forgetting to add the custom inventory renderer.

Create a building.

And then map block to the building.

The crusher building has the list of recipes on what he can transform certain things into.

Which are filled with the required data.

When are then transformed in static recipe storages for quick access.

Besides that the building stores the daily quantity it can produce, the current quantity of this day and the mode it is set on.

The max daily quantity is set depending on the level of the building and the daily quantity reset with each new day.

Also gotta setup a default job.

and add a string based mapping.

Gui:

The GUI to trigger these settings sets up the input settings field, registers thebutton and setsup the current values.

On saving the changes made in the GUI the mode in the building view is set.

Which triggers a message to the server side.

And also setsup the strings in the GUI according to the changes.

The message to send over has to be registered.

And it checks if the sending player has the permission and if so, checks if the quantity is too big and then assigns the quantity to the building.

Leaving only the AI.

The AI:

The AI inherits crafting so it can also crush on request.

It has a small decision method where we check if the underlying crafting code requires things to do.

If this is not the case we run straight into the crushing code.

The crushing code walks the AI to the building, face the crusher block, setup delay and progress and then check if the current recipe is set.

Uploading file..._pzbzzyy37

Then it checks if he reached his daily quantity in the direct production mode. If not he checks if he reached the progress counter.

If he has all the resources to craft. (checkForItems checks for this)

He then increments the craft counter, decreases saturation and increments the actions done if he is not currently fulfilling a request.

If he doesn't have it, and he is not in the crafting stage he will setup everything to request the needed items.

Finally, we play a crushing sound at the citizen and send particles over.

Which also has to be registered.

The craft method is quite similar to the existing craft method but reduces the complexity of hitting the block to running the crusher block.

Small fixes:

In the event where we check if a player can lay in a bed (checking if a citizen is there already) we have to check if the bed has the right properties and is not a modded bed (causes some compatibility issues).

Repository:

https://github.com/ldtteam/minecolonies

Pull Request:

https://github.com/ldtteam/minecolonies/pull/3327/files

Sort:  
  • Great article with all the elements of success. The crusher crushes it, super innovation.
  • The code could use more inline comments when the functions are bigger.

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!

Your post was upvoted by the @archdruid gaming curation team in partnership with @curie to support spreading the rewards to great content. Join the Archdruid Gaming Community at https://discord.gg/6yD2Emr. Good Game, Well Played!

Hi, @raycoms!

You just got a 10.22% 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.

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!

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.

Congratulations @raycoms!
Your post was mentioned in the Steem Hit Parade in the following category:

  • Pending payout - Ranked 9 with $ 64,83

ǝɹǝɥ sɐʍ ɹoʇɐɹnƆ pɐW ǝɥ┴