Forestry

Forestry

65M Downloads

Arboretums receiving saplings from other Arboretums (Multifarms and Managed Farms)

Steampunk-Wizard opened this issue ยท 15 comments

commented

Possibly the weirdest bug I've ever seen in a mod -

Forestry version - 5.8.1.322 : Minecraft Version - 1.12.2 : Modpack Version - FTB Revelations 2.5.0

Presently on a multiplayer server, 3 different players have some form of Arboretum, (I'm using a 50/50 Arboretum/Orchard Multifarm, and my friends are using the single block Managed Farms) and for some strange reason, we will find saplings in our farms' output slots that shouldn't be there.

I'm harvesting Red Maple (From Binne's Extra Trees), Friend A is harvesting generic Oak trees, and friend B is harvesting Rubber saplings (From IC2) and all three of us are receiving saplings that the other is harvesting, alongside what we should be getting.

All 3 farms are presently chunkloaded, and being automated with different methods (Applied Energistics 2 and EnderIO) And these farms range from 300 to 500 blocks away from one another.

This bug appears to be infrequent, but incredibly constant, as we are each getting about 50-100 saplings from each other's farm per 24 hour period.

commented

How did it happen that this issue was closed as completed?
As it seems to me the issue is still there, in 1.12.2 version of the mod at least

commented

I can verify that this is happening. Forestry 5.8.2.374
I have two managed farms, one is growing giant sequoia and the other is growing blue mahoe. They are about 4-5 chunks apart from one another and have no input of items except power. Several times over the course of a day I will find both farms have stopped because they are clogged with the saplings of the other.

commented

I can definitely verify this bug. But I will need some time to fix it because it is a very complex bug and I don't have much time at the moment.
2018-12-23_14 04 54

commented

Just checking in on this, thanks

commented

I can confirm this was a thing too. Our users (for Infitech 3) complained about it and I thought they were nuts til I reproduced it myself. Save us please Nedelosk :(

commented

Here is what I think happens: I don't think the produce field here is unique to each farm. In fact, from what I can see every arboretum uses the same FarmLogicArboreal. So the saplings and fruit picked up by the farms are shared.

public NonNullList<ItemStack> collect(World world, IFarmHousing farmHousing) {
NonNullList<ItemStack> products = produce;
produce = collectEntityItems(world, farmHousing, true);
return products;

EDIT: hmm, I'm not sure. Things seem dodgy in this area though.

commented

@temp1011 Seems like mezz reduced the number of logics but forgot to change this field.
afbde2d

commented

I've opened a PR with a (hopefully) suitable fix.

commented

The logic seems to persist lots over farming cycles in order to cope with running out of inventory/power mid harvest (I would guess). So things like lastExtentsHarvest are also shared for every arboretum as far as I can tell.

commented

Removing all shared state from the farm logic is also a valid fix, but I think it's a lot harder to do and I think there are reasons that the shared state exists.

commented

The shared states are useless if you have a new instance for every farm side. So it makes no difference if we remove them or if we create a new instance ๐Ÿ˜„

commented

For lastExtentsHarvest the shared state makes sense yes, but produce has absolutely no function else than save it for one cycle which is not needed because if the inventory is full, it gets on a pending list anyway.

for (ItemStack produce : collected) {
inventory.addProduce(produce);
pendingProduce.push(produce);
}

commented

What about just return collectEntityItems directly?

commented

I agree we can return collectEntityItems directly, but surely there's a similar bug with lastExtentsHarvest that's just never triggered because there's a check further on for the farm somewhere

commented

So I guess I don't mind if we just get rid of all the shared state. Also, I've just realised I'm commenting on the issue not the PR, sorry about that.