Animania Base

Animania Base

11M Downloads

Animals trying to reach inaccessible troughs

Lictor000 opened this issue · 9 comments

commented

Animals, or at least chickens, get stucked when searching for food, trying to get unreachable troughs instead of one they can actually get food from.
I saw starving to death a rooster that was starving a trough behind a fence wall, instead of getting food from the one behind him.
I believe it happened because it was nearer as the crow flies when it started searching for food.
In the screenshot attached you can see where it was the rooster that starved. For the whole time it kept being in that specific place (on the two-three blocks from the wall), staring at the trough in front of him behind and the fences.

Version of Minecraft, version of Animania, Single Player or Server

1.12.2, 1.6.1, Server

Screenshots encouraged

2018-11-17_19 52 57

commented

Ok, I now have written a blacklisting system which tries to blacklist positions that it cannot reach. The effect of this you can see in this clip. I will mark this one as fixed.

commented

Ooh that looks great @Tschipp

commented

Coincidentally, this also causes animals that are getting stuck at overcrouded eating/drinking places to search for another location to eat, which is also nice.

commented

No. The spruce in the image is the position of the entity. The entity always searches in a 16 block range around itself, so if it's standing in a corner of the pen and sees a trough outside of it that is in range, it will try to walk to it.

commented

Hmm, so leaving 14 spaces from fencing then... That's a lot, but doable for my farm.

commented

So for now it's better to put troughs at opposite sides of the adjacent fencings.
What if I organize my animal areas on different levels? Do you think they could get stuck searching for troughs on the floor above them? Floors being 4-5 blocks between each other.

Anyway thank you very much for your work!

commented

With how the AI currently works, the entity searches every block in a 16 block range on the y level that it's standing at, on y + 1 and on y - 1. So if you make the ceiling at least two blocks over the floor you will be fine.

commented

I've been working on this issue for the past few days and I'm not sure it can be done with vanilla's pathfinding. We depend on vanilla to give us the path for the animal to walk to the trough. I assumed that if there wasn't an available path (troughs being unreachable behind blocks), there would just not be a valid path returned.

This image shows the order when an animal searches for blocks:
img
The colors and their numbers represent the priority of the position. Lower numbers = higher search priority.
The animals search in (by default) a 16x3x16 block range. To try and prevent this issue, we will add a timer that cancels the AI if the entity is stuck in one place too long. What you can do to prevent this issue, is place the troughs more out of range from the other chickens. I'm sorry, I hope I still find a real fix.

commented

So, having a 16 by 17 pen fence with a trough in the center would always have a pathing inside the pen due to priority?