Hi everyone, been immensely busy with university but still got some small nice things out during the course of the last 2 weeks.
If you want to know more about Minecolonies check out our website and wiki:
http://www.minecolonies.com/
https://wiki.minecolonies.com/
Small Fixes:
Let's start with some small fixes.
I added a config value to configure a max y level for barbarians to spawn.
And case it's reached we won't spawn them then.
Then, for our underground game mode, I added a way to allow the builder to work efficiently under certain y levels if configured like that.
Then, I fixed a crash case move building is clicked without having a valid building loaded.
Besides that, I fixed that the first citizen won't spawn with very low stats and that, case there is no citizen it just returns the average happiness.
Also, fixed a crash when checking the validity of colony placement on the client side by checking if it server side before doing the check.
Finally, builders were getting stuck when placing entities since they were trying to request air.
So all I had to do is a filter from the list of requests all air blocks.
The New Deco Block:
Then, I added a bigger new feature. Up to now decorations could be placed with the build tool but only canceled from the town hall and neither upgraded or repaired.
For this reason, I added the decoration controller block.
The block looks like a small chalkboard which can be seen in the screenshot above.
On right click, it opens a GUI and allows to configure the name of the decoration (including file path) and the level.
This is only possible in gamemode1 (creative) to make sure users don't abuse this system.
The build tool would then display it as well in the rendered area and allow to select even to display several levels.
As always it starts with a block. This one allows horizontal orientations.
And implements two classes to make sure it is anchored to the decoration and to make sure the builder won't destroy it.
For each possible orientation, it needs an extra bounding box to make it nicely clickable.
No collision effect.
Opening it's GUI on right click.
Additionally, it has a mirror property we need to allow to mirror the decorations as well.
So, we have to read the values correctly.
And apply rotation as well as the mirror.
As always I gotta add it to the mod blocks class.
And register the block and item.
Then, since it has a GUI I gotta create a window class for it.
On creation, the window sets up the buttons and text fields.
And then check if the closest colony already has a work order for this decoration.
This check is important since we have to check whether to display build/upgrade/repair or cancel.
To make it possible I had to add the position of the work order for decorations.
(Also in the view)
And finally, we gotta check if the player is in creative mode to disable certain GUI elements.
Which we previously stored as a field.
If in creative and done is clicked, we parse the values in the fields and send the data to the server side to set it in the class of the decoration controller.
On confirm or repair clicked we then sent the build orders to the server side of the colony.
To make sure the player doesn't try to place level 5 decorations straight away I restricted the placement of decorations which end with a number to "decoration1"
If the name is park2 it will go to park1
The actual request then from the GUI has its own message.
Which, as always first checks if there is a colony and the sending player has the permission.
Then it gets the object of the controller.
Following by another check for the work orders, if the order exists this means we're trying to cancel and thus cancel and return.
If none exists we get the facing of the controller and the default facing to calculate the direction the structure should face.
Case it is a level up we set that up as well.
Since I added some logic to the decoration work orders.
Which determine if the current build request is leveling up the decoration.
This is important because on complete we gotta increment the level.
Finally, we got the update message of the decoration.
Which, on reception, sets all the necessary values.
The central class is then the tile entity (extended storage for a block).
Which also has to be registered.
This tile entity takes care of the syncing to the client side already for us and takes care of persistence as well.
Also wanted to make sure the builder can place the deco block for free.
Correctly Rotate blocks:
Besides that, a very long term fix finally made it into the game. Up to now we always had the problem that the blocks of the buildings were rotated in a certain way independent of the rotation it should have in the structure since we were using the rotation to determine the general rotation of the entire structure.
But, this is, of course, bogus since we could just store the rotation of the structure in the building.
So, let's get rid of the old code.
And adapt it everywhere else.
First of all, any placing and pasting require the state of the block in the structure since we want to place it rotated correctly.
This, of course, has to follow the placement settings, so we gotta set the placement settings everywhere too.
And in a bunch of other places.
The messages handling the placement of the hut would then place the hut accordingly to the state (and not with the default state) and then apply rotation to it.
Finally, I had to make sure that the construction tape also follows the new rules.
So I moved it from the creation point to the addition point of buildings.
And added it also to the message, since with the build tool we have to apply the custom rotation to it.
I hope you enjoy these two changes, they will make our structure builders much happier and will also make sure that there are more possibilities for players to customize their colonies.
Besides that, having wrongly rotated blocks in a building is from now on also history.
Repository:
https://github.com/ldtteam/minecolonies
Pull Requests:
https://github.com/ldtteam/minecolonies/pull/3514
https://github.com/ldtteam/minecolonies/pull/3511
https://github.com/ldtteam/minecolonies/pull/3500