NovaEngineering-Source / ModularMachinery-Community-Edition

Customize your machinery with more powerful features.
https://www.curseforge.com/minecraft/mc-mods/modularmachinery-community-edition
GNU General Public License v3.0
31 stars 15 forks source link

Multiple modifiers for single upgrade #56

Closed sainagh closed 10 months ago

sainagh commented 10 months ago

In base Modular Machinery the following JSON field would work to give multiple modifiers to one block machine upgrade, but in MMCE it only considers the first modifier, making it impossible to create upgrades that affect multiple aspects of a recipe.

If the following upgrade is added to a machine JSON, it will recognize the upgrade in the preview, but once the block is switched, the error 'no valid recipe' shows up in the controller GUI, and it prevents the machine from working.

"modifiers": [
        {
            "elements": "contenttweaker:mythic_coil_t2@0",
            "x": 0,
            "y": 3,
            "z": 1,
            "description": "Multiplies amounts processed by 16",
            "modifiers": [{
                "io": "output",
                "target": "modularmachinery:item",
                "operation": 1,
                "multiplier": 16
            },
            {
                "io": "input",
                "target": "modularmachinery:item",
                "operation": 1,
                "multiplier": 16
            }]
        }
    ],
jchung01 commented 10 months ago

I figured I would add onto this with a bit more context. It seems to have broke in r46. For an example, let's say we have a recipe 1 iron ore -> 1 iron dust. In older versions, the above modifiers would result in 16 iron ore -> 16 iron dust. Now, consider the following scenarios for r46 and up: a) Machine has modifier of only output with multiplier 16: 1 iron ore -> 16 iron dust, as expected. b) Machine has modifier of only input with multiplier 16: The recipe will not work, saying "Missing input item!" c) Machine has both modifiers: Same issue as b). d) Machine has both modifiers, but internal parallelism is set to 16: 1 iron ore -> 16 iron dust, but you must have at least 16 iron ore in the input hatch(es). e) Machine has both modifiers, but internal parallelism is set to 32: 2 iron ore -> 32 iron dust, still need 16 iron ore in the hatches, but can process 2 at a time.

So the output modifier works fine, but the input one does not. I don't believe it is an issue with the order of modifiers. To summarize the bug/change in behavior in newer MMCE versions:

As such, the new behavior seems very odd where it depends on the ratio between parallelism and the multiplier modifier.

KasumiNova commented 10 months ago

It seems to break some of the parallelization mechanisms...

TheTzdDark commented 10 months ago

Perhaps I should add some more consequences of the changes in r46. Namely, related to the operation of the "addItemModifier" method.

I have this code: var count = 8; var modifiedCount = 9; recipe.addItemOutput(<minecraft:dirt> * count).addItemModifier(function(ctrl as IMachineController, item as IItemStack) as IItemStack { return item * modifiedCount; }

OLD RESULT: item modifiedCount. That is, the original amount of the item from the recipe itself ( count) was not used. NEW RESULT: item `count modifiedCount`. Here, the ItemStack that the method returns is additionally multiplied by the original amount of the item in the recipe.

The bottom line is that the new logic of the method is very inconvenient from the point of view of controlling the number of items. After all, now you need to take into account the initial multiplier of items specified in the recipe. Yes, you can specify it as 1, but then there will be an ugly display in the JEI for this item.

KasumiNova commented 10 months ago

Some of the strange behavior mentioned above should be fixed in this commit, no problems in my own testing, but for security reasons I would like someone to test this fix.

Commit: https://github.com/NovaEngineering-Source/ModularMachinery-Community-Edition/commit/e1cdbe31cac576b6017287820e99c773f06f975d

Actions: https://github.com/NovaEngineering-Source/ModularMachinery-Community-Edition/actions/runs/6839871622

TheTzdDark commented 10 months ago

I checked my mechanisms, working with the usual modifiers at first glance has been corrected and everything is working normally. However, the problem with addItemModifier remained(

KasumiNova commented 10 months ago

Now fixed in R51.