Hey everyone, as I said these days we're currently working on some huge changes in our mod and I'll present you today the first part of this together with the port of all of this to the 1.11 version of our mod.
What's new:
Most of our players are complaining for quite a while already that they want our workers to be able to craft, even if they are simple recipes.
We're planning on the long run complex crafter workers. But we set up things step by step to get them tested and stable before we advance further.
For that, we set up a crafting GUI which allows you to drag items into the crafting grid and then click done after the recipe has been analyzed.
After that, you'll be able to display those recipes on the crafting list and remove or order them by priority.
The worker will then if he has the regarding item craft the item and not request it to the warehouse (One of our other devs will post about that in the next days.)
What we did:
First of all ,we added a RecipeManager to our ColonyManager.
This means that all recipes are stored globally in the scope of the server.
The recipe manager has a list of Recipes (Which are instances of IRecipeStorage) and they are accessible by a unique token implementation.
Each worker then has a list of those tokens stored inside his building which allow him to retrieve the recipe from the RecipeManager through the ColonyManager.
We did this to make our system as light as possible on the memory.
Most players will probably teach mostly the same recipes to their workers and we would have to store the heavy recipe storages in each worker or colony dozens and dozens of times all over the server. This way each worker only has to store the tokens of the recipes he knows which makes this system way lighter.
Since the ColonyManager also takes care of serializing it to the client side of the mod each building also only has to serialize the tokens and not the whole RecipeStorage to display it to the client which is also way faster and lighter on the bandwidth.
Each RecipeStorage holds a number of fields.
Which are namely the input (the blocks needed), the output (the resulting block), a possible intermediate block (a furnace or modded crafting bench) the grid size (2x2 or 3x3) and the token of it which we use to store it in its manager.
Then, it is also responsible for knowing if it can be resolved by a certain citizen, or, to be more accurate by a certain list of inventories.
It will then go through the input stack and adds it up (adds 4 wheat stacks in the size of 1, to 1 wheat stack with the size of 4).
Afterwards, it goes through all the resulting stacks and through all the incoming inventories and checks if the right amount of the blocks can be found in a combination of all inventories.
Fulfillment
With the help of this, it will even do the fulfillment.
It will first, check for the free space in the inventory to add the result and then check if it actually can fulfill the recipe.
Afterwards, it runs through all the input and extracts it from the inventories and afterwards, inserts the crafted item in the inventories.
This was it from my side of this issue. In the next days, one of our main developers will write about how those recipes will be handled by the colony and how this will be integrated with the warehouse and delivermen.
I hope you liked the post of today and our new update, I will keep you posted!
Posted on Utopian.io - Rewarding Open Source Contributors