Hi everyone, unfortunately, I don't have much time to keep you updated with the newest things I am coding for minecolonies so the posts come in a bit later after I merged the changes already.
But, this also gives me the chance the bundle a bunch of pull requests into a bigger update report.
Builder GUI now scans the whole building to display the missing blocks compared to the required blocks.
Which mainly consisted of streamlining the responsible code by using the item handler of the building.
Our workers dumping behavior was not soo smart because it had to run several times through the dumping code before it dumped the whole inventory. This was very costly.
Now we remember the slot we're at in a field.
Also, remember the blocks we didn't dump.
Then, I reworked the dumping completely.
I moved the walking to the building for readability in the front.
Then, we get the stack in the slot (and not iterate through all slots until we reach a block we have to dump)
After that, I added some new code which makes sure that he always dumps some minimum amount (else he might get stuck in a loop dumping forever if he needs all blocks in his inventory)
Then we only return true after we ran through all the slots and are at the last slow.
In the end, we have to clear the list then and reset the counter.
The deliveryman had some other problems since he was only dumping into the main chest of the worker.
Again this was because he only dumped into the tileEntity and not into the item handler.
Changing this fixed this bug.
tileEntityColonyBuilding.getBuilding().getCapability(ITEM_HANDLER_CAPABILITY, null), stack, ((AbstractBuildingWorker) building)::isItemStackInRequest);
No crash just log
Then, I replaced one of the last places we crash and do not recover.
When a colony would be added twice we would crash the game even though we could tolerate this failure to make the user experience smoother.
This means, if a user will now add the same colony again we will return the old colony to him and log the incident.
Fix getting stuck when picking up
Additionally, I fixed that workers don't get stuck when trying to pick up an item in a spot in their building they can't physically reach. This means if the worker gets stuck we detect this and then pick the item up anyway even though we're not close enough.
Fix for missing cooks
Another issue was that our cooks would after a while not return to their building accordingly.
Therefore, I moved the move to the building code from the end to the beginning of the AI.
Guard Attack list fix
Also, guards weren't detecting which mobs they weren't supposed to attack. This was a quick fix by just filtering them out.
Avoiding the overflow of shepherd inventories by using the right method to dump blocks into his inventory.
Fixing miner crash
Fixing a crash with the miner when he changes the level he works on.
Only marking the racks as dirty if they really changed:
Fixing the warehoue overflow into other inventories.
This was a tricky one to figure out. The inventories were not properly scanned in the warehouse which lead to the case that the deliverymen would bring overflowing items to other chests.
I fixed this by properly checking if there was space in a rack.
For that, I created a new method which does check the handler correctly if it can dump into it.
Previously it wouldn't consider the stackability of the items correctly.
Who follows my blog knows that I am a passionate refactorer.
These days I wanted to add some code which stores the current state of the worker to the job.
When I opened the abstract job class I couldn't stop right there.
The abstract job class had a reference to all its child's.
This is something which I really couldn't leave there.
Therefore, I created the job registry class.
This class would then get all the registry code of the abstract job class which would, in turn, make the abstract job class way more readable.
Then, I was able to add the new feature to the job.
While also persisting it.
The idea of this was, to make sure that the action tracker is persisted over sessions so that workers actually dump after the right amount of actions and not only after a number of consecutive actions.
Then, I only had to make sure to adapt the job registry calls and get an increment action calls to fit the new location.
Fixing some weird bugs
Lately we had a report which reported a crash with our mod. When I checked into the log files it had appeared as there was a wrong tileEntity where the minecolonies block was. While this was probably not caused by us, I still implemented a workaround to make sure we can recover from this without crashing.
Doing this by resetting the tileEntity.
And by only iterating over the other tile entities if we have the world.
We updated a bunch of our models as well so we don't have to reuse old models. The models were created by one of our modelers a long time ago, but the work of correctly integrating was missing (since the model program exports it wrong)
Additionally, I got the block models of one of our graphics guys and added them into the mod as well (we might see an utopian post from them soon as well).
I had to adapt a few of the generated model files to make sure the things render ingame accordingly.