Files
ParchmentMC/patches/api/0010-Add-Furnace-Recipe-API.patch
Blast-MC 4c2ae38401 1.20.6
2024-05-19 16:31:52 -04:00

107 lines
3.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: lexikiq <noellekiq@gmail.com>
Date: Tue, 13 Jul 2021 17:27:45 -0400
Subject: [PATCH] Add Furnace Recipe API
Temporary API to get the result of smelting an item in a (type of) furnace.
Will eventually (hopefully) be replaced by a more extensive Paper PR with support for all recipes.
diff --git a/src/main/java/gg/projecteden/parchment/inventory/RecipeType.java b/src/main/java/gg/projecteden/parchment/inventory/RecipeType.java
new file mode 100644
index 0000000000000000000000000000000000000000..ea17d99c7a1d70d88e2c439399cdb376b9dedf47
--- /dev/null
+++ b/src/main/java/gg/projecteden/parchment/inventory/RecipeType.java
@@ -0,0 +1,50 @@
+package gg.projecteden.parchment.inventory;
+
+/**
+ * A type of crafting recipe.
+ */
+public enum RecipeType {
+ /**
+ * Recipes crafted in the standard crafting table.
+ */
+ CRAFTING(false),
+ /**
+ * Recipes for smelting an item inside a furnace.
+ */
+ SMELTING(true),
+ /**
+ * Recipes for smelting an item inside a blasting furnace.
+ */
+ BLASTING(true),
+ /**
+ * Recipes for smelting an item inside a smoker.
+ */
+ SMOKING(true),
+ /**
+ * Recipes for cooking an item on a campfire.
+ */
+ CAMPFIRE_COOKING(true),
+ /**
+ * Recipes for carving stones in a stonecutter.
+ */
+ STONECUTTING(true),
+ /**
+ * Recipes for smithing an item in a smithing table.
+ */
+ SMITHING(false),
+ ;
+
+ private final boolean singleInput;
+
+ RecipeType(boolean singleInput) {
+ this.singleInput = singleInput;
+ }
+
+ /**
+ * Determines if the recipe only accepts a single item for input.
+ * @return true if the recipe only accepts a single item for input
+ */
+ public boolean isSingleInput() {
+ return singleInput;
+ }
+}
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 97f97ea5c6aa513c439f86a9c82821e0f7d9cd1e..64c1287b7a668680e19f8c4c1a678abb0eb5d88e 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -52,6 +52,36 @@ import org.jetbrains.annotations.Nullable;
*/
public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient, Metadatable, PersistentDataHolder, Keyed, net.kyori.adventure.audience.ForwardingAudience { // Paper
+ // Parchment start
+ /**
+ * Returns the item that will result from smelting the input item, if applicable.
+ *
+ * @param toSmelt the item to simulate smelting
+ * @return the resulting item, or null
+ */
+ @Nullable
+ default ItemStack smeltItem(@NotNull ItemStack toSmelt) {
+ return smeltItem(toSmelt, gg.projecteden.parchment.inventory.RecipeType.SMELTING);
+ }
+
+ /**
+ * Returns the item that will result from smelting the input item, if applicable.
+ * <p>
+ * Applicable values for {@code recipeType} are
+ * {@link gg.projecteden.parchment.inventory.RecipeType#SMELTING SMELTING},
+ * {@link gg.projecteden.parchment.inventory.RecipeType#BLASTING BLASTING},
+ * {@link gg.projecteden.parchment.inventory.RecipeType#SMOKING SMOKING},
+ * and {@link gg.projecteden.parchment.inventory.RecipeType#CAMPFIRE_COOKING CAMPFIRE_COOKING}.
+ * An {@link IllegalArgumentException} will be thrown if another value is supplied.
+ *
+ * @param toSmelt the item to simulate smelting
+ * @param recipeType type of furnace to simulate smelting
+ * @return the resulting item, or null
+ */
+ @Nullable
+ ItemStack smeltItem(@NotNull ItemStack toSmelt, gg.projecteden.parchment.inventory.@NotNull RecipeType recipeType);
+ // Parchment end
+
// Paper start
/**
* @return The amount of Entities in this world