This content was deleted by the author. You can see it from Blockchain History logs.

Minecolonies & The little things in life #3

Hey everyone, like I mentioned previously, we're currently working on some small fixes and quality of live improvements in order to get improve our stability.

Therefore, I fixed a total of 6 open GitHub issues and some additional ones which have only been reported on our discord.

Namely issues 2084 to 2087 and issues 2065 and 2091.
I usually go issue over each issue, but since a few of those issues are related and I fixed a bunch of stuff besides that I will do it differently today.


Minecolonies does not only have friendly villagers, to make things more exciting depending on your colony strength a bunch of barbarians visit your colony each every configurable night.

This works great in singleplayer, but on the server, those barbarians never seemed to spawn where they should, and, instead even went to the wrong colonies.

This was a pain since, if you have a colony with 100 citizens it might come visit a colony with only 4, which would result in a lot of tears (depending on the player's age and proximity to the water).

Therefore, we spend 2 whole days logging all over our code to check where they were spawning.

We ended up even writing an event handler just to find out where they were spawning.
Just to find out they were spawning in exact the place they were supposed to.
But when we went there, they almost never showed up.

After a while of debugging on our debug server, I asked myself, what if something during their construction might mess with their position just after they spawn.

So I took a peek in their class and found this in their constructor:

Which sets the colony which they're supposed to haunt.
But, at the time of the construction of the colony, they didn't spawn yet, and therefore, their position was at 0/0/0 in the world. Which basically set the wrong target.

On top of that, the pathfinder noticed that the target was too far away and teleported them over.

What a mess!

Basically what we did was getting the colony only on demand after the entity has been spawned.

After we fixed that we noticed they weren't moving and I wondered what would be wrong now...
Some more hours went by when I noticed this jewel:

In Minecraft 1.11 the correct method name was "continueExecuting" and since it didn't have the "@Override" over it, as it was supposed to.

That's why code style is important like I said here

As you can imagine, a lot of headache for an easy fix, which could've been avoided by following the code quality rules.


Then we had a few issues with our colonist crafting system (Post of that coming soon).

We noticed we had to double check if the colonists can actually craft because players might rob their stuff.

We noticed we have to write id incrementers consistently:

All messages do ++id, so a following id++ will register two with the same id.

Blocking adding recipes when the hut can't learn more.

Checking for contains with the wrong types.

A bunch of formatting and style issues.


Besides that, Minecolonies has a "Build-Tool" which allows players to tell the Builder of the colony to build certain things.

Currently, if the player wants to place ten roads he has to open the tool, select the road and close it again, while this works, it's highly uncomfortable.

For this, I changed that we detect if the player clicks "shift-done" and will leave the window with the right schematic open.

Very easy fix, besides that I only had to turn on that the game will stay running during the window so that the construction markers get placed correctly.

Which works, due to our custom mod windows quite smoothly as well.


Additionally, one of our players and contributors reported that a few of our workers were creating lag. When I checked their code I noticed that we were
calculating the bounding box of his hut quite often.
Therefore, I decided to cache this.

First I added a field in the class which contains this.

And then I added a check, each time it needs the area to look if we have calculated it already, if not it will calculate and store it if so it will just return it.

Trading memory for CPU.

And last but not least, our players were reporting that the color of all our text in all GUIs was black.

I double checked and found this gem:

While debugging some things one of our devs turned it to 0 and all of us failed at finding this in the code review.

I hope you liked this short debug session.
I'm currently thinking about making a video of the next quality of code sessions, what do you think? Comment below and see you the next time.



Posted on Utopian.io - Rewarding Open Source Contributors