Farmers not farming?

Discussion in 'Empire Help & Support' started by taleden, Mar 23, 2017.

  1. According to the wiki, mobs go dormant unless a player is within 16 blocks. I've seen mention that Villagers are exempt from this, but I have routinely seen a Farmer standing completely motionless in the middle of a fully grown field of crops, only to suddenly spring to life as soon as I get within 16 blocks.

    So it doesn't seem like Villagers are exempt, but is there any chance they could be? Or at least Farmers in particular, since the other professions don't do anything significant on their own anyway? Minecraft v1.8 added the new Farmer AI which opens up exciting new automation possibilities, but if the Farmers just stand around unless you babysit them all the time, that kind of defeats the purpose.
    Equinox_Boss likes this.
  2. Equinox_Boss likes this.
  3. Yes, that is indeed the page and the exact section that I linked to in my post. :)

    I am aware of what it says on that page, but I was wondering if Farmer Villagers were supposed to be exempt because of their new farming AI, just the same way that babies are exempt (so they can grow on their own) and naked sheep are exempt (so they can regrow wool on their own). It seems like Farmers should also be exempt so they can farm on their own, but if that was the intention, it doesn't seem to be working.
    jkjkjk182 and Equinox_Boss like this.
  4. I have a few farms ran by farmers that auto farm for me. most of the time when I have ran into this issue its do to their inventory being full of wheat or other unplantible things. i have had it happen every now and then when that was not the case. you just have to afk for a little bit and they start right back up
    Equinox_Boss likes this.
  5. I took this up with Aikar a while back, he added it when we updated to 1.11.2; farmer villagers are exempt from the entity activation range. However, I wouldn't think they're exempt from the vanilla loading range, they just don't have as ridiculously tiny range as they used to anymore. I noticed soon after 1.11 my crop farms started producing crops many times faster than they used to, this is why.

    Sorry if the above post doesn't make sense; my mind isn't focused today.
    Equinox_Boss likes this.
  6. I don't think it's an inventory issue because it happens to brand new Farmers that were just spawned from the egg (and allowed to grow in containment, with no access to pick anything up).

    It's good to know that they're supposed to be exempt, it just doesn't seem to jive with what I'm seeing. If I stand 20 blocks away and watch them, they're completely motionless even with tons of fully grown crops surrounding them; when I get close (like within 6 blocks) suddenly they start harvesting. I back off, they stop. I approach, they start again.

    Edit: the range is definitely exactly 6 blocks. When they go into harvest mode they prefer to go south, so if I stand north of a farmer in a grown field, he'll start harvesting and moving away from me. Within 6 blocks he's fine, but as soon as he's exactly 7 blocks away, he harvests but does not re-plant, he just stands there doing nothing. If I take one step toward him, suddenly he plants, steps away, harvests the next one, and then stops again. I can keep doing this and as long as I follow 6 blocks behind he keeps going, but if I let him get further he stops.
    Equinox_Boss likes this.
  7. My setup has several Villagers but I can only view one at a time. If I watch from nearby, there are long periods where they are inactive then they will do something like move or harvest and replant then they go back to inactivity. I have each module's output running into the same Chest though, and if I watch it the Wheat trickles in a few items at a time so I know they are doing what they are supposed to. I have not tried the same build elsewhere so I haven't compared the output to SP or another server but I am mostly happy with the output I am getting.

    The model I have made up to explain their behavior to myself is that in addition to being activated by my presence they have a "time slot" each Villager shares with all the rest in range or maybe on the server or perhaps a maximum number that can be active at any one time. When I see them move it is because it is their turn. I have noticed behavior that kind of fits with this model from Iron and Squid farms where there are periods of nothing then it rains Golems or Squid.

    I think about all we can do about it is learn as much as we can from the documentation, ask questions, watch for bugs, and experiment. If you are unhappy with your output I would be glad to meet with you to compare farms to see if there are any improvements we can come up with. You could also share your build here to see what others can think of to help. Your information could possibly help others too.
  8. Any chance a dev could double check and comment on this? The wiki claims that Villagers should activate normally out to 16 blocks from the player, but I've tested it several times now and every time, a Farmer will behave normally only out to 6 blocks, beyond which they get super sluggish (like 10x slower to harvest/plant).

    So if that's not intended then maybe there's a bug, but even if it is, it would be nice to know for certain how it's supposed to work and have it documented on the wiki so that we can design accordingly.
    Giselbaer likes this.
  9. Villagers can be in "harvest and replant" mode, or in "do nothing/feed a friend" mode. In "harvest and replant" mode, they'll keep harvesting stuff and replanting until one of several things happens:
    • they get attacked by something
    • they can't find crops to harvest or farmland to replant
      • if they are in a village, crops/farmland outside that village won't interest them
    • they find a friend who's hungry and they have enough food themselves
    • a plan he has "move to X, harvest, replant" fails because he bumps into something else on the way, or a different villager has already harvested where he wanted to, or similar
    • maybe something else I didn't think of right now
    When they're not in "harvest and replant" mode, they will, occasionally, throw food at that friend. Also, they have a chance of re-entering "harvest and replant" mode when there is no hungry friend around, or their own food level is below what they need to feed a friend. However, they do not re-enter "harvest and replant" mode immediately. So, once they start standing around doing nothing, they may keep doing (or not-doing?) so for several minutes.

    Another thing that minecraft uses to reduce lag is a value called entity activation range; mobs and villagers become inactive if they aren't within activation range of a player.

    Once they're out of minecraft's entity activation range, they'll stand there doing nothing even when they're in "harvest and replant" mode. In normal minecraft, this activation range is 64 blocks (not 100% sure about that number), in Spigot (which is the server software that runs 90% of all public servers) it's tunable but with a lower default (I think 32), and unfortunately this range is shared with all other entities. So when a server tunes down that range (which many servers do as it helps to prevent lag because mob AI is quite expensive in computing cycles), it gets turned down for animals and villagers alike. There was a request on the spigot forum once to have two different tunable values for villagers and animals (https://www.spigotmc.org/threads/villagers-activation-range.1316/) but that got never implemented.

    Anyway, due to entity activation range, people have often witnessed, and are used to, "villagers stop harvesting when you move away, but they restart when you come closer". However, this is only half the truth, they restart when you're close enough and they are in harvest and replant mode. And what makes the whole thing even more difficult to observe correctly is that it seems like minecraft does a "check if a villager should go into harvest/replant mode" when a chunk is loaded; I've seen (on other servers) several times how a villager was doing nothing, I teleported away, tp'ed back after a few seconds (so the chunk was unloaded and loaded), and the villager immediately started planting. I had the same on EMC when I switched server and came back (and no other player was close to me).

    Everything up to here was vanilla minecraft behaviour.

    I don't know any of EMCs source code, but it seems to me like Aikar split the entity activation range into two values. There's one low value, probably 5, that is the "full enitity speed" range; mob AI runs every tick as long as a player is that close to a mob (with Y being ignored and only X and Z counting). And there's a second value "the entity freeze range", beyond which entities won't move/get their AI run. As long as entities are between those two values, they slow down; their AI doesn't run every tick, but it does every 10th (value is questionable again) tick. So when you're standing in the wild somewhere, and watch a sheep moving from A to B that's 20 blocks away from you, you'll see it move 10 times slower than it normally would. Also, a villager will harvest/plant/move, but much slower than he would if you were directly next to it.

    To muddy the waters further, there seems to be some kind of special behaviour for farmers: it seems like once a farmer between both ranges has decided on what to do next (move to some place, harvest, replant) he will do that at full speed. However, when he's done with that single block, and has to decide what to do next, he'll slow down again until he made a decision. Once the decicion has been made, he moves to the next block at full speed, only to slow down again until he finds the next block to harvest.

    See this video: https://youtu.be/U4MUz6llTDw

    TL,DR: you will see a villager work if he's very close to you; you'll see him work slowly if he's farther away from you, but if he's not working at all, it's because he isn't in plant and harvest mode. Unloading and re-loading the chunk may help.
  10. In my testing I have managed to be fairly successful with keeping all villagers inside of "18" total blocks x+z from where I am. Anything outside that becomes both questionable and likely inactive for both farming and non-farming villagers. In that range I personally have not noticed any real slow down but I keep the "farm" portion of my villager automation farms and villager spawners even closer like a max 10-12 blocks. Since Y is ignored my automation farmers are all below ground and my spawner above to help build door counts.