Minecolonies & Refactoring and Fixes

in #utopian-io6 years ago

Hey everyone, this weekend I was able to get a few things done again.

Therefore, I delivered a bunch of important fixes which were long due.

Fixes:

In a previous PR we added to consider the distance variables in the configurations when placing a colony.

There were to problems with it:

  1. Some people didn't want it.
  2. Issues with big numbers.

First thing, we added a new config value to ignore this:

Then, we noticed we had used ints to compare distances, but since those become easily very big they became negative which caused these issues.

Besides that we noticed we were taking a 3 dimensional distance but we only care about 2 dimensions (x, z).

So, first we check if we want to consider it.

Then we take the square root of the 2dimensional distance and then we use a double to compare it which also solves the second problem.


Another issue we had was that people weren't able to move their townhalls and warehouse since there only can be one per colony.

The solution was simple, we had to unregister those form the townhall before moving them.

And for that add these methods to the Buildingmanager.


Then we had an issue with log spam with the miner. Which happens because the miner validly uses not existing structure to check if they exist.

So I removed that log.


Another issue was that colonists didn't teleport anymore when unable to move to a target.

So we increased the time it needs to reset the moved away timer.
And set the variable correctly after moving away.

Which results in triggering the teleport again when necessary.


The last issue was that we had a bunch of dupes (Citizens duplicating).
This has been due to a fix of citizens getting lost and also due to minecraft duplicating and losing them themselves.
So I made a complexer system.

For that I had to do two things:

a) When a citizen gets unloaded or reloaded we don't need to notify the colony about that.

So I deleted the mark dirty there.

Then b)

When a citizen is missing we want to check if the location is loaded. For that I created a variable which takes track of where the citizen last was.

Which gets set every few seconds.

Then I added a check for this before we actually try to reload a worker and then try to respawn him.

Finally c)

If the citizen has no entity connected it will go into the above and check if its loaded, if not it will try respawning it.

If the citizen has one, it will check if the one it is connected to really exists in the world.

For that we go through all citizens in the world matching this citizens description and then set the right one.

If the list is empty that means we need to try to respawn it (if, as previously, its block is loaded).

Following that we remove all duplicates by iterating through all entities which are not the first in the list and remving them from the world.

Pull-Requests:

https://github.com/Minecolonies/minecolonies/pull/2458
https://github.com/Minecolonies/minecolonies/pull/2461

Sort:  

I really like how you are handling your github issues, it is clear in your pull request comments.

Your contribution has been evaluated according to Utopian rules and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post,Click here


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Woow!! Great coding skills you got there, I usually find Java challenginging and greatly sensational. Have fun and I wish you luck @raycoms

Hey @raycoms
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Contributing on Utopian
Learn how to contribute on our website or by watching this tutorial on Youtube.

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

just wondering, what game is this? :D

It's Minecraft and the project is an open source mod to it.

Coin Marketplace

STEEM 0.29
TRX 0.12
JST 0.032
BTC 63524.02
ETH 3069.67
USDT 1.00
SBD 3.84