Skip to content

Commit 1d09b61

Browse files
authored
Fix ItemType#isEdible to also check for DataComponents#CONSUMABLE (#13348)
1 parent c7a138b commit 1d09b61

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

paper-api/src/main/java/org/bukkit/Material.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3001,13 +3001,14 @@ public boolean isBlock() {
30013001
}
30023002

30033003
/**
3004-
* Checks if this Material is edible.
3004+
* Checks if this Material provides the {@link io.papermc.paper.datacomponent.DataComponentTypes#FOOD} and
3005+
* {@link io.papermc.paper.datacomponent.DataComponentTypes#CONSUMABLE} and, thereby, is edible by a player.
30053006
*
30063007
* @return true if this Material is edible.
30073008
*/
30083009
public boolean isEdible() {
30093010
ItemType type = asItemType();
3010-
return type == null ? false : type.isEdible();
3011+
return type != null && type.isEdible();
30113012
}
30123013

30133014
/**

paper-api/src/main/java/org/bukkit/inventory/ItemType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3189,7 +3189,8 @@ private static <M extends ItemType> M getItemType(@KeyPattern.Value final String
31893189
short getMaxDurability();
31903190

31913191
/**
3192-
* Checks if this item type is edible.
3192+
* Checks if this item type provides the {@link io.papermc.paper.datacomponent.DataComponentTypes#FOOD} and
3193+
* {@link io.papermc.paper.datacomponent.DataComponentTypes#CONSUMABLE} and, thereby, is edible by a player.
31933194
*
31943195
* @return true if this item type is edible.
31953196
*/

paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public short getMaxDurability() {
143143

144144
@Override
145145
public boolean isEdible() {
146-
return this.getHandle().components().has(DataComponents.FOOD);
146+
return this.getHandle().components().has(DataComponents.FOOD) && this.getHandle().components().has(DataComponents.CONSUMABLE);
147147
}
148148

149149
@Override

0 commit comments

Comments
 (0)