Insane96 / IguanaTweaksReborn

Repository for ported and maintained version of IguanaTweaks
https://www.curseforge.com/minecraft/mc-mods/iguanatweaks-reborn
13 stars 12 forks source link

Changing `food_properties.json` for `betterend:cave_pumpkin_pie`, but it also applies to `minecraft:pumpkin_pie` #322

Closed LTCatt closed 2 weeks ago

LTCatt commented 2 weeks ago

Versions:

What Happens:
image

It looks like IdTagMatcher did something weird. https://github.com/Insane96/IguanaTweaksReborn/blob/29d1693243c807332d9d7aab9270ce26ba8822c9/src/main/java/insane96mcp/iguanatweaksreborn/module/hungerhealth/fooddrinks/CustomFoodProperties.java#L20

Config:
\config\iguanatweaksreborn\Hunger & Health\Foods & Drinks\food_properties.json

[{"food": "betterend:cave_pumpkin_pie", "nutrition": 20}]
Insane96 commented 2 weeks ago

I can't really test this. There's no way to run fabric mods in a forge dev environment. Do the items actually give 20 health or is just visual? Did you try eating them?

LTCatt commented 2 weeks ago

hmm let me see if there's any other way to reproduce

LTCatt commented 2 weeks ago

I investigated a bit more and this should be because Better End is using the same instance of FoodProperties when registering food, causing one to be modified when the other is modified.

Code

    public final static Item CAVE_PUMPKIN_PIE = registerEndFood("cave_pumpkin_pie", Foods.PUMPKIN_PIE);
    public static Item registerEndFood(String name, FoodProperties foodComponent) {
        return getItemRegistry().registerFood(BetterEnd.makeID(name), foodComponent);
    }

Perhaps this can be circumvented by creating a clone of the FoodProperties and making changes to the cloned instance when it is modified?

Insane96 commented 2 weeks ago

So BetterEnd is needed?

LTCatt commented 2 weeks ago

Yes, I can't reproduce this with other mods.

Insane96 commented 2 weeks ago

I investigated a bit more and this should be because Better End is using the same instance of FoodProperties when registering food, causing one to be modified when the other is modified.

Code

  public final static Item CAVE_PUMPKIN_PIE = registerEndFood("cave_pumpkin_pie", Foods.PUMPKIN_PIE);
  public static Item registerEndFood(String name, FoodProperties foodComponent) {
      return getItemRegistry().registerFood(BetterEnd.makeID(name), foodComponent);
  }

Perhaps this can be circumvented by creating a clone of the FoodProperties and making changes to the cloned instance when it is modified?

Then this is exactly the problem. It's up to them to use a new instance of the food component.