AgriCraft

AgriCraft

30M Downloads

Can't stack seemingly identical seeds. (Slightly different NBT depending on source.)

3DLudi opened this issue ยท 9 comments

commented

I was growing some crops today and noticed some seeds, which appeared identical, would not stack together. For a time I thought it was only a derpyness with wheat but I noted Hemp was also doing it -- and I suspect all the others would also. I think I found the cause. AgriCraft adds tag data to seeds to save the stats but depending on where the seed came from the stats are different.

Analysed wheat seed from grass:
minecraft:wheat_seeds.withTag({agri_analyzed: 1 as byte, agri_strength: 1 as byte, agri_gain: 1 as byte, agri_growth: 1 as byte})

Analysed wheat seed from harvesting via crop stick:
minecraft:wheat_seeds.withTag({agri_analyzed: 1 as byte, agri_strength: 1 as byte, agri_gain: 1 as byte, agri_seed: "wheat_plant", agri_growth: 1 as byte})

The only difference is the tag agri_seed: "wheat_plant" which does not get added to seeds from grass. Note it only effects stacking. I was able to replant both kinds in crop sticks regardless of type.

commented

I have the same issue, but i also can't crossbreed or mutate my crops at all. If i try all i get is weed.
I tried turning off weed in "...\config\agricraft\json\defaults\vanilla\plants\weed_plant.json"
But i still can't get my crops to crossbreed or mutate. Nothing wants to spread.
All i get is seeds that look the same in every way, but wont stack: https://imgur.com/a/OtNYi94
My modpack is pretty much just DireWolf20's 1.12 mod pack with agricraft-2.12.0-1.12.0-a4.jar
and few other mods. Also i'm on Win7 64-bit if that helps. Any idea how to fix this? Is more info needed?
Edit: Seems to work after i completely removed the mod, and configs, and then reinstalled it.
Weed still appeared way too frequently tho so just turned it off for now.

commented

Hmmm. I've had a save with a similar or identical problem. In my case, two seeds wouldn't stack, even though they both claimed to have zero NBT tags. I set it aside for testing, because I couldn't get the problem to occur intentionally at the time.

This is good data. And it does point to probable causes. Thanks! I'll look at some things. :)

Edit: That tag is separate from the stats, and also not part of the general format. So the analyzer only adds the four stat tags when it updates a seed. Meanwhile, the crop asks the plant to give it a seed when needed, and the JsonPlant manually adds the plant tag on line 98.

I haven't sorted out yet when that tag should get added elsewhere, where else it's missing. In fact, I wonder if actually maybe line 98 is unnecessary, and if it's actually read from anywhere else in the general code. I think the plant tag is only used by the AgriSeed item so that it can be configured to represent different seeds for different plants. And the registry already adds that entry. So, hmm.

commented

Hah. Glad you have a handle on it.

While removing it from line # 98 should solve the problem, it might be easier to instead add the tag when seeds are analyzed. Either way as long as it is consistent...

commented

I'm not sure what to do about this as we need the tag information in the crops, but I suppose we might set the baseline stats to serialize into no tag at all...

commented

The stat tags are necessary, and I think are fine. The trick I think is that only ItemAgriSeed needs the "agri_seed" NBT tag, to specify which plant it corresponds to, but currently the crops are putting that tag on all seeds. With the seeds from other mods, the item itself maps to what plant it is for, so they don't need that tag.

commented

You could refactor the code to remove the necessity of the tag and remove it, but I think you should add it to all seeds which are analysed. As long as all seeds carry the "agri_seed" tag they should stack.

commented

I think the tag is fine, because some mods, like ResourcefulCrops and IC2 add seeds which are all the same item, and the NBT on the stack determines which seed it is.

IMO the preferred fix, is to make sure that when agricraft's NBT is applied to a seed, it goes through a centralized method, regardless of where (applying to a crop, analyzing, ... etc)

commented

It goes through a centralized method already, I think the issue is that on planting the itemstack used is discarded after an AgriSeed is inferred from it, so that when the time comes for the seed to be removed from the crops a new itemstack has to be generated, that has no guarantee of matching the original.

commented

@RlonRyan Yup, that is what I was seeing too. The plant variable is set during planting, and the reference to the seed is not saved. Then whenever the crop needs a seed, the plant is asked to provide/create it. The crop also sets that NBT tag on the seed after that.