FoodTweaker

FoodTweaker

9k Downloads

Unable to modify food items with metadata/damage value

luke-bravenboer opened this issue ยท 12 comments

commented

I'm unable to modify any food items that have metadata variants- not even the default (:0) version of the item when the data value is unspecified in the crafttweaker script.

Raw fish in vanilla minecraft are all metadata variants of the <minecraft:fish:*> item, and cooked fish/salmon use the <minecraft:cooked_fish:0> & <minecraft:cooked_fish:1> tags.

It doesn't seem like any of the vanilla fish are modifyable as a result; my test script here seems to do nothing at all, even though I'm able to edit other foods just fine:

import mods.foodtweaker.changeFoodStats;
changeFoodStats(<minecraft:fish:0>, 10, 1.0);
changeFoodStats(<minecraft:fish:1>, 10, 1.0);
changeFoodStats(<minecraft:fish:2>, 10, 1.0);
changeFoodStats(<minecraft:fish:3>, 10, 1.0);
changeFoodStats(<minecraft:cooked_fish>, 10, 1.0);
changeFoodStats(<minecraft:cooked_fish:1>, 10, 1.0);

Resulting screenshot:
fish

commented

Can you try again using 1.1? I've rewrote the mod to work better and I was able to differentiate the different Golden Apples just fine.

commented

For documentation about the new CraftTweaker implementation there's now a Wiki page on this github.

commented

Hmm- unfortunately, after rewriting my script to work with the new interface, it seems to be still unable to set the food values for any of the fish specifically. Both types of Golden Apples work correctly as you mentioned, as do any other regular foods- but for some reason, none of the four fish varients, nor the two cooked fish, seem to be modifyable.

(Test script used:)

import mods.foodtweaker.Tweaker.changeFoodStats;
import foodtweaker.FoodInfo;

changeFoodStats(<minecraft:fish>, FoodInfo(10, 5.0, true, false));
changeFoodStats(<minecraft:fish:0>, FoodInfo(10, 5.0, true, false));
changeFoodStats(<minecraft:fish:1>, FoodInfo(10, 5.0, true, false));
changeFoodStats(<minecraft:fish:2>, FoodInfo(10, 5.0, true, false));
changeFoodStats(<minecraft:fish:3>, FoodInfo(10, 5.0, true, false));
changeFoodStats(<minecraft:cooked_fish:0>, FoodInfo(10, 5.0, true, false));
changeFoodStats(<minecraft:cooked_fish:1>, FoodInfo(10, 5.0, true, false));

changeFoodStats(<minecraft:beef>, FoodInfo(10, 5.0, true, false));
changeFoodStats(<minecraft:cooked_beef>, FoodInfo(10, 5.0, true, false));
changeFoodStats(<minecraft:chicken>, FoodInfo(10, 5.0, true, false));
changeFoodStats(<minecraft:cooked_chicken>, FoodInfo(10, 5.0, true, false));

changeFoodStats(<minecraft:golden_apple>, FoodInfo(10, 5.0, true, false));
changeFoodStats(<minecraft:golden_apple:1>, FoodInfo(10, 5.0, true, false));
commented

I got it semi-working in 1.1.1
Technically they are changing. But mods like AppleSkin can't pick it up due to how the Fish item is setup in 1.12.

commented

Could you try 1.1.1?

commented

Vanilla overrides the ItemFood and overrides the getHealthAmount() and getSaturationModifier() methods to point to an Enum with values. I can't really change the outcome of that method without completely substituting it with my own code. Which would mean FoodTweaker would become incompatible with any mod overriding vanilla fish.

AppleSkin gets their values from calling the methods mentioned above. And since fish's override it to take in account different values for different metadata that's why it doesn't know about my changes.

commented

Good lord, I've heard stories about Minecraft's source but that's just silly :P

Thanks for everything! I've opened a new ticket with AppleSkin for this: squeek502/AppleSkin#60

commented

This isn't something AppleSkin can fix. I made FoodTweaker to change food and be compatible with the Sanity mod. I didn't know HungerTweaker existed.

commented

FoodTweaker was mostly a challenge I gave myself for 1.12 that I eventually rewrote in 1.14. But then got merged into Crafttweaker from 1.14 on.

commented

If you could test 1.1.2. It should add compat for AppleCore.

commented

Can confirm it's now working- very bizarre how AppleSkin still can't detect changes with the fish items, even though the notch apple works just fine. Thanks for addressing it so quickly!

I'm assuming this display issue won't be related to your implementation, and it's presumably just a problem on their end now, right? (If so I'll raise a new issue on AppleSkin's page, though I'm unsure if they're still actually pushing updates for 1.12)

~

By the way, there's a minor issue with one example in the new documentation- crafttweaker has issues with this line:
var customInfo = FoodInfo(<minecraft:apple>).setHeal(8).setAlwaysEdible(true);

I had to separate it out into something like this instead:

var customInfo = FoodInfo(<minecraft:apple>);
customInfo.setHeal(8);
customInfo.setAlwaysEdible(true);
commented

Interestingly enough, I've just noticed that Pam's Harvestcraft isn't able to modify the vanilla fish either. It has a default setting to 'rebalance' all vanilla food items to encourage using Harvestcraft foods instead, but it's actually just faking it for each of the the vanilla fish!

Pam's Harvestcraft (for 1.12 at least) creates new items with the names 'minecraft:cod', 'minecraft:cooked_cod', etc., and gives these 'fake' items the rebalanced food values (which might just be a unfortunate hangup of trying to support 1.13+). However, if you click these fake fish in JEI, you'll notice there's no way to get them- yet the original, actual 'minecraft:fish' items show up in JEI as well... It's just a bit of a mess really :S