Polymer

Polymer

763k Downloads

[bug] Bad AppleSkin interaction when forcing Vanilla foods through Polymer

Siphalor opened this issue · 1 comments

commented

When I force Vanilla foods through Polymer, e.g. with:

PolymerItemUtils.ITEM_CHECK.register(ItemStack::isFood);

...but only modify the stacks, without changing the item, Polymer will report food values of (0,0) to AppleSkin.

This is caused by the implementation of Polymer's AppleSkin plugin:

FoodValuesEvent.EVENT.register(event -> {
var id = PolymerItemUtils.getPolymerIdentifier(event.itemStack);
if (id != null) {
var item = InternalClientRegistry.ITEMS.get(id);
if (item != null) {
event.modifiedFoodValues = new FoodValues(item.foodValue(), item.saturation());
} else {
event.modifiedFoodValues = new FoodValues(0, 0);
}
}
});

PolymerItemUtils.getPolymerIdentifier will return the vanilla id, but InternalClientRegistry.ITEMS.get(id) won't find an item for it.
The else case around line 20 resets the modified food value to zero in these cases.

With my limited knowledge of Polymer, I can't explain why that else case is present and would suggest to just remove it.

I acknowledge that forcing Vanilla items through Polymer may not be properly supported, but alternatively I'd have to put in a bunch of custom mixins for my use case.


Workaround: As I use the AppleSkin API myself, I‌ can try to work around these issues a bit by relying on Polymer internals.
This is not a permanent solution though, as it relies on the load order of the mods.


Since I support Minecraft 1.18.2 as well as 1.19.2, it would be nice to get this merged on both branches.

commented

Fixed on both