After the last updates creating new workers we're focusing again on bringing more stability.
If you want more info about what we're doing, check out our website or wiki:
http://www.minecolonies.com/
https://wiki.minecolonies.com/
Some fixes:
First, I added some null checks case people configured the crusher wrongly.
Then, the builder got stuck with null stacks so I added a null check to filter the stream.
Then I noticed that our code comparing ItemStorages doesn't do a valid equals check.
Besides that the max citizens per config setting wasn't being followed accordingly.
I noticed it wasn't checked accordingly in the code which checks for the max to spawn more kids.
Besides that, citizens were sleeping in bed with a block at the head position which made them die, so I added a check to avoid this.
Inventory improvements:
Also noticed that we were calling the wrong method to get the valid itemStacks for chisel and bits block (we were calling the structurize method which doesn't have support for this)
After doing some debugging I noticed that we were losing a lot of performance with inventory actions.
Digging deeper into it I noticed that we were not filtering handlers validly quite often.
So, what happened is that per provider of inventory we added it up to 7 times. (Once per direction and one without direction).
This was because the comparison of two inventories is based on the instance and not based on the actual inventory.
So I made sure that, for example, the citizen only returns one which we cache.
More complex it was for buildings, since we want to check actually if we have an inventory from all sides but we can't cache it too long since the inventory of a building expands if more chests are added.
So I also added a cache.
Which we fill if null.
But every ticking update of the actual building we will reset it.
This way, during one single request within the same tick it will be more efficient since the work is quite big to join in all the inventories but at the same time it will be more efficient since it won't have to search 7 times the same inventory space.
Correctly request bigger quantities:
So, first of all I added the count to the stack request.
Then, I added that we don't break after adding one result stack back to the inventory. (Case there is more left)
Then I added that in the resolver of the building which tells the worker how much it has doesn't break after the first, but sums it up.
As a detail I used an atomic integer since you can't increment non final variables within a stream (side effects).
Then, I added that the worker picks up all delivery stacks and not the difference.
Else we would always have to request the total quantity and not the difference between total and what we have.
Then, at the inventory I added a "force" variable which checks how necessary it is to have all items we need on a request.
If force it is true we go through all the items we have to calculate correctly the difference.
Then I'd calculate the total amount from the difference.
And make sure we take this calculated amount.
Later I noticed that in some places we were not requesting enough blocks.
Building Naming:
Then, I finished some work of another coder which left it behind a while ago.
So I fixed up the message to only work on the server side and add it to the building.
And cleaned up the way to make sure if no custom name is given the default is chosen.
Pull Requests:
https://github.com/ldtteam/minecolonies/pull/3483
https://github.com/ldtteam/minecolonies/pull/3485
https://github.com/ldtteam/minecolonies/pull/3489
Repository
https://github.com/ldtteam/minecolonies/pull