Skip to content

Commit bc59526

Browse files
fix: match sausage casing with the vanilla paper path (#36)
* fix: match sausage casing with the vanilla paper path v.paper is the TLibs check for real paper, so custom paper tools and scooped soup are no longer consumed as casing. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: ignore an empty paper stack when checking sausage casing v.paper does not look at stack size, so a sheet already reduced to zero must not count as casing. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 3444822 commit bc59526

1 file changed

Lines changed: 8 additions & 28 deletions

File tree

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,22 @@
11
package net.tfminecraft.cooking.sausagemaker;
22

3-
import org.bukkit.Material;
43
import org.bukkit.inventory.ItemStack;
5-
import org.bukkit.inventory.meta.ItemMeta;
64

7-
import net.tfminecraft.cooking.item.FoodItem;
8-
import net.tfminecraft.cooking.util.LegacyModelData;
5+
import net.tfminecraft.tlibs.TLibs;
96

107
/**
11-
* Sausage casing is plain vanilla paper. Cooking tools and scooped soup use
12-
* paper as their base item, and those must stay in the player's hand.
8+
* Sausage casing is vanilla paper. {@code v.paper} rejects custom items that
9+
* only use paper as their base, such as the masher and a scooped bowl of soup.
1310
*/
1411
final class CasingPaper {
1512

13+
static final String PATH = "v.paper";
14+
1615
private CasingPaper() {}
1716

1817
static boolean isCasing(ItemStack stack) {
19-
if (stack == null || stack.getType() != Material.PAPER || stack.getAmount() <= 0) {
20-
return false;
21-
}
22-
if (hasCustomIdentity(stack)) {
23-
return false;
24-
}
25-
return FoodItem.fromItem(stack) == null;
26-
}
27-
28-
private static boolean hasCustomIdentity(ItemStack stack) {
29-
if (!stack.hasItemMeta()) {
30-
return false;
31-
}
32-
ItemMeta meta = stack.getItemMeta();
33-
if (meta == null) {
34-
return false;
35-
}
36-
if (meta.hasDisplayName() || meta.hasItemName() || meta.hasItemModel()
37-
|| meta.hasCustomModelDataComponent() || LegacyModelData.has(meta)) {
38-
return true;
39-
}
40-
return !meta.getPersistentDataContainer().isEmpty();
18+
return stack != null
19+
&& stack.getAmount() > 0
20+
&& TLibs.getItemAPI().getChecker().checkItemWithPath(stack, PATH);
4121
}
4222
}

0 commit comments

Comments
 (0)