refinedmods / refinedstorage

An elegant solution to your hoarding problem.
https://refinedmods.com/refined-storage
MIT License
355 stars 176 forks source link

Issue with external crafting making doubling the necessary ingredients #592

Closed utoc closed 7 years ago

utoc commented 7 years ago

Issue description:

Using external crafting for materials, RS will create twice as much material as needed to make the item. This is new behavior in 1.2.3 that didn't exist in 1.2.beta5 and friends

Lets say you need 10 of A which needs 80 of B and 10 of C total. C is a resource you have available and needs no crafting. B has external crafting that needs 8 of D and 4 of E to make 8 of B. RS will make 160 of B even though it only needed 80.

If you request autocrafting of B directly, any quantity, it crafts the correct number of items with no overflow If you request autocrafting of A, quantity of one, it crafts the correct number of items with no overflow. If you request autocrafting of A, >1, it will always double the amount requested for B.

The crafting preview ALWAYS shows the right number though!

What happens:

See here: http://i.imgur.com/cUAMnFn.gifv

its YUUUGE, just wait for it to load. RIP Mobile Data

The image shows some very weird blinky blinky behavior that may or may not be a clue to the issue. I'm a little stumped on this one

What you expected to happen:

It should not craft double the items.

Steps to reproduce:

See above. I don't have a vanilla case that works; these are using Mekanism as an example. This did work prior to 1.2.3 (beta5 was a known working example)

Version (Make sure you are on the latest version before reporting):

Does this issue occur on a server? [yes/no]

If a (crash)log is relevant for this issue, link it here:

[pastebin/gist/etc link here]

moRt1MC commented 7 years ago

@utoc Yea i posted it in the wrong page. I deleted the post sorry.

raoulvdberge commented 7 years ago

Can you reproduce this issue on a new world with just a 64k storage block as storage?

brad18 commented 7 years ago

Update: The bug is in beta 1.5(perhaps lower versions). I just ordered 64 steel casings from mekanism and its outputted about 2k extra steel than needed.

What would you like me to test?

raoulvdberge commented 7 years ago

Can you tell me the exact beta 1.2 where this bug starts?

brad18 commented 7 years ago

I've noticed that you have taken down the beta downloads, any chance you're still hosting them somewhere so I can test it?

raoulvdberge commented 7 years ago

Agh, that is true.. forgot about that :/ In fact, we might not need them anymore for testing. We know enough now that we know that this bug existed in the betas already.

brad18 commented 7 years ago

Ok. Thought I'd give 1.1.3 a quick try and can confirm it does work correctly in 1.1.3 so it is definitely something in 1.2.

brad18 commented 7 years ago

This might help in tracking down the bug. When I order the steel on it's own, it works fine. It's only when it needs to autocraft for something else (such as a steel casing) that it messes up. I've noticed that in the "Items crafting" section of the monitor, it will count down the steel despite the steel not actually being received. Once the steel reaches 0 on the counter, it will flicker and go back up to somewhere around the original amount. When it does this, it will spit out another load of iron and coal to craft even more steel.

way2muchnoise commented 7 years ago

@brad18 Is there for some reason something that just inserts steel for some reason? Cause you can see it go down in the monitor, at which point the autocrafting assumes it is in the systems. But when trying to do the next step it won't have the materials and reschedule thus making more steel (which was still processing).

Could you share your setup, cause I can't reproduce with mine. (That being a single alloy smelter processing steel dust to steel)

brad18 commented 7 years ago

http://imgur.com/a/nlVbl

This is the setup which makes steel for me. A crafter exports (via a pattern) 8 iron and 2 compressed carbon to craft 8 steel ingots.Note that the upper chest is the only place in the system where steel gets inserted. The setup then does its stuff and outputs to the upper chest with an importer on it. If I order 512 steel on its own, I will get 512 steel. If I was to order 64 steel casings which require 512 steel ingots then I get the 64 casings however the crafting goes insane. It will the output the initial amount of stuff, then it will wait and spit out some items then do that again and again and again until I end with about 2k more steel than I need.

Note that I also got this behaviour on many other things. Yesterday, I autocrafted 16 induction cells and ended up with abour 48k red alloy from mekanism.

way2muchnoise commented 7 years ago

As I said you can see the items go down in the monitor, right? That means somewhere there is steel being inserted. Or what ever other material for that matter. That causing a reschedule and inserting more into your input chest. Could there be any io flow of steel in your system that is messing up the status and thus causing reschedules?

brad18 commented 7 years ago

Yeah I can see the number of steel going down but that is the only place in the system where steel can get inserted and it looks like the number is going down faster than the setup can make it.

way2muchnoise commented 7 years ago

So for some reason it thinks more gets inserted that actually is. Hmmm, no clue where that is coming from. Also kinda related to #597 now.

brad18 commented 7 years ago

If it's any help, I was playing about with the betas a while ago(compiled myself) and I noticed that the initial issue existed in beta 1 where it would make approximately double what was needed. Then I believe the transition from beta 3-beta 4 or beta 4 -beta 5 introduced the run away crafting where it made tons of items.

way2muchnoise commented 7 years ago

I can't recall when I implemented the rescheduling, but that is for sure causing the extras here. Although the root of the problem is the system reporting that more ingots are done than really are. If the calculation preview shows the correct numbers that it isn't related to the calculation, but further down the line.

brad18 commented 7 years ago

I can confirm that the calculation preview does report the right numbers. Although I have noticed that on very large, multiple stage crafts that it will be fine and calculate the number of items properly if I enter a small number of items however if I enter a large number of items to craft, it will freeze trying to open the calculation screen. For example, I am unable to make a stack of mekanism induction cells as it gets stuck but I can craft 16 of them. Want that in another bug report?

way2muchnoise commented 7 years ago

If there is anything in the log than yes, but tbh mekanism is really buggy and unstable. We already have lot of hacky fixes just for it to work with the horrible mekanism state atm.

brad18 commented 7 years ago

ok. I'll have to wait for utoc to get back to see if there is anything in the logs.

utoc commented 7 years ago

Still hunting @brad18 but you can get with @3pixel for log in the meantime.

It sounds like we need to find a mis-scheduling of ingots in a non Mekanism route though to confirm if this is Mek issue or RS. I have some ideas we can test after Thanksgiving @brad18

On Nov 20, 2016 2:20 PM, "brad18" notifications@github.com wrote:

ok. I'll have to wait for utoc to get back to see if there is anything in the logs.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/raoulvdberge/refinedstorage/issues/592#issuecomment-261802675, or mute the thread https://github.com/notifications/unsubscribe-auth/ALcLNNZYbDUWoYhkGArL33FL-VaYFDLpks5rAKuEgaJpZM4KqsC8 .

brad18 commented 7 years ago

Been testing a bit more and the results are interesting. This is going to be a long one :) .

Let's start off with the original problem. 8 compressed iron and 2 compressed carbon goes to 8 steel ingots in a crafting pattern. Crafting steel on its own is fine but when nested inside another recipe, the craft will produce significantly more steel than necessary.

First, I have located the reason for the significant extra amount of items. The problem is not really the rescheduling. Let me start by explaining my testing process. I recreated the recipe for the steel casing using vanilla-ish items. I made a recipe containing 8 stone and 1 crafting table goes to a Terraqueous CraftBench where the stone is acquired via a 1 cobble -> 1 stone external crafting process. This worked perfectly to make 64 CraftBench's. Then I realised that I didn't recreate the recipe properly so I recreated it to be 2 compressed carbon and 8 cobble -> 8 stone where the carbon just sits in a chest. Now this is where it gets interesting, this recreated the problem with the steel ingots. I noticed in the crafting monitor that when the recipe is 1 - 1, it monitors incoming items correctly however when the recipe is something like 2 items + 8 items -> 8 items, the system is grossly overestimating the incoming items.This would be fine on a single craft as the items will just flow in after RS thinks the craft done however in a nested craft, the system thinks everything has arrived, realises it has nothing to craft with and then spits out another batch of items. So say I order 64 CraftBench's, it will make the first one, spit out items for 63 benchs, make the next one then spit out enough items for 62 CraftBench's and so on.

brad18 commented 7 years ago

Found the problem. If you set a pattern to return anything other than a single item, it will count a single item as x number of items defined in the craft. For example, if the craft returns 1 steel, it will count each item correctly, if the craft returns 8 steel, it will count each steel coming in as 8 steel in the monitor. A craft returning 16 items will count each incoming item as 16 of that item thus making the count in the monitor decrease rapidly.

Going to guess its some extra code needed in the fix for #528

way2muchnoise commented 7 years ago

Yeah, I noticed and I might have a fix ready soon™ :D

way2muchnoise commented 7 years ago

Didn't really wanna close it with that commit, but it should be gone 💯

way2muchnoise commented 7 years ago

Would also like to give my humble thanks for the great debugging work you guys did on this. This is an example bug report and interaction.

Making RS great again!

brad18 commented 7 years ago

Not a problem. Keep up the good work 👍

brad18 commented 7 years ago

Just tested the build and I can confirm that the problem has been fixed @way2muchnoise Thank you 👍

You can probably close #597 now.

raoulvdberge commented 7 years ago

Yay! Thanks @way2muchnoise