Forester sapling issues
dhouck opened this issue · 3 comments
Prerequisites
- I am running the latest alpha version of MineColonies and Structurize for my Minecraft version.
- I checked the MineColonies/Structurize wiki and made sure my issue is not covered there.
- I made sure that this issue is not a duplicate of any existing issue.
Context
- Minecraft Version: 1.16.5
- MineColonies Version: 0.14.197
- Structurize Version: 0.13.175
- Related Mods and their Versions: n/a
Expected behavior
With replant on, the forester should keep saplings in stock either in their inventory or hut, and use hut saplings if they don't have enough in inventory, or failing that not put saplings in the hut inventory.
Actual behavior
- The forester will put many of their saplings in the hut inventory; I'm having trouble tracking down why this happens; maybe this only happens at low hut level level, since it looks like
BuildingLumberjack.getRequiredItemsAndAmount
should let them keep all the saplings at level 3+? In any case they sometimes run out of various saplings in their inventory, perhaps just from not collecting enough from dark oak trees. - Couriers will take saplings from the hut if the forester doesn't have that type on hand, making it not very effective as a backup sapling source. This is from
AbstractBuilding.buildingRequiresCertainAmountOfItem
calling the aforementionedgetRequiredItemsAndAmount
function, which won't return things the forester isn't holding. - The second point here doesn't really matter though, because forester won't use hut saplings. When they're done chopping and want to replant, if they don't have enough saplings, they will wait a while, then run to the hut to check for saplings. Unfortunately, this is just a check; they don't actually grab any from the hut even if present, because the relevant code in
EntityAIWorkLumberjack.plantSapling
is:
if (timeWaited >= MAX_WAITING_TIME / 2 && !checkedInHut && !walkToBuilding())
{
isInHut(job.getTree().getSapling());
checkedInHut = true;
}
- As I was writing this issue, I saw a forester skip the gathering step after chopping a tree. Not sure what's up there; he might have interrupted himself with eating and forgot to go back to gathering?
The rest (running to the building, running back, etc.) seems to work, although I'm not sure how; I'm probably missing something about how the AI system works or how timeWaited
is being calculated.
Steps to reproduce the issue
For the first part of the issue about running out of saplings, I don't have better reproduction steps than "have the forester harvest lots of dark oak trees and wait; they probably won't pick up as many saplings as they use in the long run".
For the second part:
- Put a type of sapling the forester doesn't have on hand in the hut inventory
- Request pickup
- Observe courier taking sapling from hut inventory
For the third part:
- Plant a tree of some type in range of the forester (while they're paused, or at night)
- Remove all but one leaf, or remove leaves after they start chopping the tree, careful not to let them pick up any relevant saplings
- Put saplings of that type in hut inventory and remove them from forester inventory (making sure the courier doesn't get it)
- Observe forester wait around a while, then walk to hut and back and wait more
- Check hut inventory; saplings are still present
- Look at base of just-chopped tree; no saplings planted
For the fourth part, I don't know; I just observed it the once. I'll see if it happens regularly when chopping the tree makes him hungry.
Logs
- latest.log: None of this shows up
- crashlog: N/A; no crash
Notes
My recommendations would be:
- For 1, document on wiki that foresters work best with only 2 types of tree per hut level, and maybe add option to cut all leaves with hoe after harvesting tree, or wait longer before gathering dark oak and jungle
- For 2, add override for
BuildingLumberjack.buildingRequiresCertainAmountOfItem
to require a stack of each of the saplings present - For 3, fix the excerpted code (not actually sure how myself in an efficient and idiomatic way; I'm sure there's a function for grabbing an item from hut inventory but I didn't see it)
- No suggestion for 4
Additionally, I did some tests before writing this issue, but for most of it I've had a forester with a level-5 hut and most stats manually maxed to 99 harvesting a rotation of trees of five of the six vanilla overworld types running in the background (the spruce was accidentally out of search range). I started him with a stack of each sapling, and he's down to 52 dark oak, 63 each of birch, oak, and jungle, and 64 acacia (and of course all the spruce). Then I added in the part about skipping gathering once, and checked again, and saw only 48 dark oak and the same numbers for the rest. Maybe everything but dark oak is sustainable already, but I wouldn't be surprised if the others can run down too, just slower.
Viewers
- Add a thumbs-up to the bug report if you are also affected. This helps the bug report become more visible to the team and doesn't clutter the comments.
- Add a comment if you have any insights or background information that isn't already part of the conversation.
Level 1 forester in version named above is not replanting saplings... the UI to replant saplings resets to off after turning it on. Tried several ways to get the option to stay on but whenever I closed the UI and reopened it it was off again.
@kinneja that was fixed in the latest.