Hey everyone, I finally got some time again to write what I was up to the last days. I brought a bunch of fixes and improvements to minecolonies again.
You might be asking: "Dude, why so many fixes, is the mod so broken?"
But developing an integration within the world of Minecraft is extremely complex especially since there are a ton of other mods which change the world. Most of the fixes are cases we didn't think of when coding the AI or parts of the mod others are workarounds for things which are broken on the side of Minecraft itself. Others again are mod integrations and a bunch of them are really bugs in our code.
The first batch of fixes added that when a player tries to upgrade a building the builder can't build yet he will be notified.
For that, we created a method "canBeResolved" to each workOrder which checks if any builder in the colony can take care of this building.
/**
* Check if this workOrder can be resolved by an existing builder.
* @param colony the colony to check in.
* @param level the new level of the building.
* @return true if so.
*/
public boolean canBeResolved(final Colony colony, final int level)
{
return colony.getBuildingManager().getBuildings().values().stream().anyMatch(building -> building instanceof BuildingBuilder && building.getMainCitizen() != null && building.getBuildingLevel() >= level);
}
We would call this on request of the player and if not possible cancel the request.
Later I noticed that I didn't enable the builder to build his own hut which got an extra method called "canBeBuiltByBuilder".
@Override
public boolean canBeBuiltByBuilder(final int newLevel)
{
return getBuildingLevel() + 1 == newLevel;
}
Which a building can override to guarantee that the building can be built.
So I added "!canBeBuiltByBuilder(level)" to the if above.
Afterward, I made sure that invalid miner requests get sorted out since some colonies were reporting they were flowing over.
Then, there was a mod which called out getCitizenData() indirectly very early in the loading process before we finished instantiating the citizen resulting in a null pointer exception.
Then, I improved the deliveryman integration to better recognize all storage in a building.
By getting the building and not only the tileEntity.
On the way, I also made sure that if there was an issue when dumping he would dump the remaining request into the warehouse.
Then, I fixed the bed requesting for old beds (Scanned in Minecraft 1.10)
Finally, I added the composter string to the localization strings.
Assigning the new town hall to the colony when moving:
Caused citizens teleport into void since they didn't find it anymore when going to sleep there.
At the same time avoiding void teleport in any possible manner.
By not executing the code when trying to path to origin.
Never trying to path into the void to be sure:
And never teleporting somewhere where there is no solid ground under them.
Then I guaranteed a max level for citizens.
After that, we had a bunch of reports of people crashing their worlds by claiming way too many chunks for their colony (over 1000) which would try to manipulate 2000*2000 blocks (which is madness)
So I made sure that there is a max size and that never too many chunks are queued.
Afterward, I improved the archer target detection code since they were trying to shoot enemies which were out of range. Someone had the operators messed up.
Improved the detection of trees within a colony.
Then I came to fixing the barbarians a bit. They had two issues:
For the first one, I created a method which checks if they are stuck and if so they would apply no collision to not push each other off.
@Override
public void applyEntityCollision(@NotNull final Entity entityIn)
{
if (entityIn instanceof AbstractEntityBarbarian
&& ((stuckCounter > 0 || ladderCounter > 0 || ((AbstractEntityBarbarian) entityIn).stuckCounter > 0 || ((AbstractEntityBarbarian) entityIn).ladderCounter > 0)))
{
return;
}
super.applyEntityCollision(entityIn);
}
Then I would make their code more efficient to not call it every tick.
Added better and earlier detection if they are stuck at all.
And if they'd not be stuck for a while I'd reset their stuck counters.
Additionally, I created some code to spawn a platform under them if their spawn point would be somewhere in the air.
I'd also put the spawn point on townhall level if I would detect that they are in the void.
Finally, I fixed that entities do not get stuck at too high blocks anymore by taking the collision bounding box into account.
Finally, we had some issues with the request system after the colonymanager rework since the request system wouldn't have the world on load.
For that I added the remote check in the colony interface.
and would then add the implementation if the world is remote or not on each side of the server.
For the server side colony.
For the client side colony.
And would then check if the colony is remote and not the world which would then finally correctly reset the system.
https://github.com/ldtteam/minecolonies
https://github.com/ldtteam/minecolonies/pull/2944
https://github.com/ldtteam/minecolonies/pull/2945
https://github.com/ldtteam/minecolonies/pull/2956
https://github.com/ldtteam/minecolonies/pull/2972