PneumaticCraft: Repressurized

PneumaticCraft: Repressurized

43M Downloads

Programmer not counting parts properly in Factory Tech machines

wrincewind opened this issue ยท 6 comments

commented

Minecraft Version
1.12.2

Forge Version
14.23.3.2676

Mod Version
PNC: 1.12.2-0.5.1-163
Factory Tech: 1.3.5 (1.1.5)

Describe your problem, including steps to reproduce it
Set up a machine from Factory Tech that uses a stock of replacement parts. (I used the Grindstone and Iron Gears)
Set up a Drone program to check the stock of parts in the machine, and if it falls below a certain threshold, restock it.

(I used 'condition >= 1' to check if the machine took gears, then 'condition =>3' to see if it had 3 or more gears in it. If it has 1 or 2 gears, then it needs restocking.)

The drone will evaluate 'true' for >=1 if there's 1 gear in there... but it will also evaluate true for >=3 gears, as well. Some debugging came to show that the drone believes there to be no less than seven gears within the Grindstone. Maybe 8, it's 3:30 am and i'm too tired to debug this any more exhaustively than I already have.

Admittedly my test program is... complex... but I'll attach the whole thing for completeness' sake. (I'm being rather... extensive with my drone programming)

It's currently set to see how many gears are in the inventory, and if it's less than 7, go into an infinite loop.

https://pastebin.com/A43tBRdB

I'm not sure what debug options are otherwise avaliable, but i'd be supremely grateful for any help you can offer. Cheers!

commented

Using F3+H, I can see the item name /meta for "Basic Gear" is "factorytech:machinepart" / 11.

However, I can see a puzzle piece matching Basic Gears where you have "Use metadata/damage values" ON, and "Specific block/metadata" set to 0. That would look for items of the same item type (factorytech:machinepart) but with a meta of 0, which appears to be the "Stone Saw Blade".

Never mind that, see my comment below. Metadata's not the issue.

commented

... Okay, that definitely sounds like it was me being stupid.

I would say though, that means the 'pick item from inventory' is not respecting meta data, as I selected the gear from my inventory and I'd expect the meta data to be copied over.

Thanks for the help though! That should be a quick fix on my end.

However... Why is the code saying there's more than three stone gears in the machine? I'll try tweaking the code when I get home and see if that fixes my issues.

commented

OK, I know what's happening, and it's down to some bizarre (but not strictly wrong) behaviour by Factory Tech:

Your puzzle piece is set to check all six sides of the blocks (which is the default behaviour for the piece). So the drone will get the inventories on all six faces of the target, and store them in a Set<IItemHandler>. Don't know what your Java experience is like, but a Set stores only unique objects.

Now, the vast majority (read: all except Factory Tech) of mods and vanilla would return the same IItemHandler object for every side, assuming it's actually the same inventory. So scanning a vanilla chest, or a storage drawer, or a PneumaticCraft Omni Hopper for example would get a Set with one member only - the IItemHandler which gives access to the block's inventory.

Factory Tech, weirdly, returns a different IItemHandler for each side checked, so we end up with a Set containing six distinct IItemHandler objects, each with a copy of the inventory. So when we count up, we end up with 6 times as many items as we should...

The workaround here is alter your Condition: Items pieces just to check one side of the Factory Tech machine. You could try reporting this to the mod author but as I said it's not strictly wrong... just weird.

commented

Gah, that is freaky nonsense. Okay, well, another easy fix! Thanks for the help.
I assume it's because one side of the machine is the input/output slot for replacement parts, and the other five sides are the I/O for all other item and fluid inputa/outputs. But thanks again!

commented

No worries. Gonna close this, not much else we can do here.

commented

Just leaving his here as I am running into the same issue with IC2 storage boxes. Limiting the check to one side appears to fix the issue. Thanks!