Expected
Only recognized foods should trigger the energy-bar eating logic. OldFood.java:76 getFood(ItemStack) should return heal amount >0 for actual consumables (steak, bread, potion, milk bucket, etc.) and 0 for non-foods (blocks, tools). Heal amount should match food balance (currently 6.0 default, 1.0 potion, 2.0 milk).
With Paper 26.1.2+ (MC 1.20.5+), consumability is defined by data components DataComponentTypes.FOOD / DataComponentTypes.CONSUMABLE, not just Material. New foods (e.g., honey bottle, enchanted golden apple variants, custom components) should be detected correctly.
What happens
OldFood.java:76 uses a hard-coded switch(item.getType()):
This means:
- Any item with a
Material falls to default and returns 6D, so right-clicking with a dirt block or sword at food 20 / health < max incorrectly triggers OldFood.java:41 getFood()>0 check and sets foodLevel=19 for non-food.
- Modern Paper
26.2 foods that rely on FOOD/CONSUMABLE components rather than distinct Material are not distinguished; the switch is stale and will mis-classify new consumables (or miss them if future materials are added). It also hard-codes heal values instead of deriving from component nutrition/saturation.
- Combined with
PlayerItemConsumeEvent copy-based semantics (1.20.5+), the event's getItem() is a copy; without checking components, logic may fire for items that vanilla wouldn't consider consumable, or fail for items vanilla does consider consumable.
File: OldFood.java | pom.xml:137 paper-api [26.1.2.build,)
Expected
Only recognized foods should trigger the energy-bar eating logic.
OldFood.java:76getFood(ItemStack)should return heal amount>0for actual consumables (steak, bread, potion, milk bucket, etc.) and0for non-foods (blocks, tools). Heal amount should match food balance (currently6.0default,1.0potion,2.0milk).With Paper
26.1.2+(MC 1.20.5+), consumability is defined by data componentsDataComponentTypes.FOOD/DataComponentTypes.CONSUMABLE, not justMaterial. New foods (e.g., honey bottle, enchanted golden apple variants, custom components) should be detected correctly.What happens
OldFood.java:76uses a hard-codedswitch(item.getType()):POTION -> 1D,MILK_BUCKET -> 2D,default -> 6DThis means:
Materialfalls todefaultand returns6D, so right-clicking with a dirt block or sword atfood 20 / health < maxincorrectly triggersOldFood.java:41getFood()>0check and setsfoodLevel=19for non-food.26.2foods that rely onFOOD/CONSUMABLEcomponents rather than distinctMaterialare not distinguished; the switch is stale and will mis-classify new consumables (or miss them if future materials are added). It also hard-codes heal values instead of deriving from component nutrition/saturation.PlayerItemConsumeEventcopy-based semantics (1.20.5+), the event'sgetItem()is a copy; without checking components, logic may fire for items that vanilla wouldn't consider consumable, or fail for items vanilla does consider consumable.File:
OldFood.java|pom.xml:137paper-api [26.1.2.build,)