Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/main/java/net/tfminecraft/cooking/cooking/PotReference.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,20 @@ public void interact(FurnitureInteractEvent e) {
return;
}
ItemStack item = p.getInventory().getItemInMainHand();
if (isHeldSoup(item)) {
e.setCancelled(true);
return;
}
if(ItemCache.isLadle(item)) {
scoop(p, item);
if (isSoup()) {
scoop(p, item);
e.setCancelled(true);
}
return;
}
if(ItemCache.isMasher(item)) {
mash(p);
e.setCancelled(true);
return;
}
if (!secondaries.containsKey("liquid")) {
Expand All @@ -411,6 +419,7 @@ public void interact(FurnitureInteractEvent e) {
danger = 0;
temperature = 0;
f.getLoc().getWorld().playSound(f.getLoc(), Sound.ITEM_BUCKET_FILL, 1f, 1f);
e.setCancelled(true);
return;
}
}
Expand All @@ -419,19 +428,30 @@ public void interact(FurnitureInteractEvent e) {
String extraKey = incoming == null ? null : extraSlotKey(incoming.getCategory());
if (extraKey != null) {
acceptExtra(p, item, extraKey);
e.setCancelled(true);
return;
}
for(String slot : f.getType().getSlots().keySet()) {
if(add(slot, item)) {
updateModel();
p.swingMainHand();
thickenSoup();
e.setCancelled(true);
break;
}
}
}
}

/** Scooped soup keeps the ladle's paper item, so it must not be used as a ladle. */
private static boolean isHeldSoup(ItemStack item) {
FoodItem food = FoodItem.fromItem(item);
if (food == null) {
return false;
}
return "soup".equalsIgnoreCase(food.getId()) || "soup".equalsIgnoreCase(food.getCategory());
}

private void acceptExtra(Player p, ItemStack item, String extraKey) {
ItemStack stored = item.clone();
stored.setAmount(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package net.tfminecraft.cooking.sausagemaker;

import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import net.tfminecraft.cooking.item.FoodItem;
import net.tfminecraft.cooking.util.LegacyModelData;

/**
* Sausage casing is plain vanilla paper. Cooking tools and scooped soup use
* paper as their base item, and those must stay in the player's hand.
*/
final class CasingPaper {

private CasingPaper() {}

static boolean isCasing(ItemStack stack) {
if (stack == null || stack.getType() != Material.PAPER || stack.getAmount() <= 0) {
return false;
}
if (hasCustomIdentity(stack)) {
return false;
}
return FoodItem.fromItem(stack) == null;
}

private static boolean hasCustomIdentity(ItemStack stack) {
if (!stack.hasItemMeta()) {
return false;
}
ItemMeta meta = stack.getItemMeta();
if (meta == null) {
return false;
}
if (meta.hasDisplayName() || meta.hasItemName() || meta.hasItemModel()
|| meta.hasCustomModelDataComponent() || LegacyModelData.has(meta)) {
return true;
}
return !meta.getPersistentDataContainer().isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,21 +272,19 @@ private static boolean hasAllMeats(Furniture furniture) {

private static boolean hasPaper(Player player) {
PlayerInventory inv = player.getInventory();
ItemStack main = inv.getItemInMainHand();
ItemStack off = inv.getItemInOffHand();
return (main != null && main.getType() == Material.PAPER)
|| (off != null && off.getType() == Material.PAPER);
return CasingPaper.isCasing(inv.getItemInMainHand())
|| CasingPaper.isCasing(inv.getItemInOffHand());
}

private static void consumePaper(Player player) {
PlayerInventory inv = player.getInventory();
ItemStack main = inv.getItemInMainHand();
if (main != null && main.getType() == Material.PAPER) {
if (CasingPaper.isCasing(main)) {
main.setAmount(main.getAmount() - 1);
return;
}
ItemStack off = inv.getItemInOffHand();
if (off != null && off.getType() == Material.PAPER) {
if (CasingPaper.isCasing(off)) {
off.setAmount(off.getAmount() - 1);
}
}
Expand Down