Lunatrius / Stackie

Improves vanilla stacking and adds experience orb stacking.
MIT License
9 stars 3 forks source link

Items duplicate when tossed on an Applied Energistics Annihilation plane. #5

Closed piousminion closed 9 years ago

piousminion commented 9 years ago

It took me a while to figure out the cause, but it appears that the latest version of Stackie for 1.7.10 causes items to duplicate when tossed on the AE2 annhiliation plane and they have nowhere to be stored. The expected result is that the item remains in place. An older version of Stackie(1.5.1.31) caused the items to be deleted instead of duped.

I would include a log, but since there is no crash, nor output when this happens, I didn't think it was necessary.

Lunatrius commented 9 years ago

Looked at the related code in both mods and the setup posted in the AE2 issue but I have no idea what could be going wrong. Both mods properly check for entity.isDead and Stackie kills any zero size stack that was merged into another stack.

Lunatrius commented 9 years ago

I'd suggest turning off item stacking in the config. It has been set to default to off in the latest version anyway, due to all the random dupe/item loss bugs popping up.

yueh commented 9 years ago

I think there is a small race condition, we only mark the entity as dead after it is actually imported into the system. But in the same time it already had spawned any overflow.

So both will exist for a tiny amount of time as living and just watching for EntityJoinWorldEvent to stack them immediately could potentially dupe them. But this is probably not an extremly rare case and can happen with all sorts of mods as it purely relying on marking the entities as dead in a very specific order.

We can probably fix this on AE2 sides, but a more generic solution might be to only mark newly entities to be joined with the next tick, so this can run exclusively without any interaction with other mods not obey the required order.

Overflow in the context of AE2 means also entities which could not inserted into the system at all. This is way easier and not as heavy on the computational side than simulating an insertion for each entity and then perform the actual insertion. Especially as inserting a stick with 1 item is as complex as one with 64. So just spawning it again and blocking the plane from accepting any item at all for about 2 minutes is way better for us than put the pressure of hundreds of entities each tick on the system just to check, if the can be inserted. If course this will keep a single entity spawned forever, but any further entities will despawn just normally.

Lunatrius commented 9 years ago

Gotcha. I'll most likely just remove the spawn based stacking altogether. All the dupe bugs have been related to that event in one way or another and trying to come up with a general solution is close to impossible. The tick based merging should be more than enough.

Lunatrius commented 9 years ago

"Fixed" in f9aa1c72b189b0060d1d25a6f4e8cae6a7d52524 / da89d2b58f8282a289bb176f7965ba7f3b5038e3.