diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/inventory/SmithingMenu.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/inventory/SmithingMenu.java.patch | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/inventory/SmithingMenu.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/inventory/SmithingMenu.java.patch new file mode 100644 index 0000000000..7360f102ae --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/inventory/SmithingMenu.java.patch @@ -0,0 +1,70 @@ +--- a/net/minecraft/world/inventory/SmithingMenu.java ++++ b/net/minecraft/world/inventory/SmithingMenu.java +@@ -14,6 +13,8 @@ + import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.level.block.state.BlockState; + ++import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit ++ + public class SmithingMenu extends ItemCombinerMenu { + public static final int TEMPLATE_SLOT = 0; + public static final int BASE_SLOT = 1; +@@ -28,6 +30,9 @@ + @Nullable + private RecipeHolder<SmithingRecipe> selectedRecipe; + private final List<RecipeHolder<SmithingRecipe>> recipes; ++ // CraftBukkit start ++ private CraftInventoryView bukkitEntity; ++ // CraftBukkit end + + public SmithingMenu(int containerId, Inventory playerInventory) { + this(containerId, playerInventory, ContainerLevelAccess.NULL); +@@ -83,16 +99,20 @@ + + @Override + public void createResult() { +- List<RecipeHolder<SmithingRecipe>> recipesFor = this.level.getRecipeManager().getRecipesFor(RecipeType.SMITHING, this.inputSlots, this.level); +- if (recipesFor.isEmpty()) { +- this.resultSlots.setItem(0, ItemStack.EMPTY); ++ List<RecipeHolder<SmithingRecipe>> list = this.level.getRecipeManager().getRecipesFor(RecipeType.SMITHING, this.inputSlots, this.level); ++ ++ if (list.isEmpty()) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit + } else { +- RecipeHolder<SmithingRecipe> recipeHolder = recipesFor.get(0); +- ItemStack itemStack = recipeHolder.value().assemble(this.inputSlots, this.level.registryAccess()); +- if (itemStack.isItemEnabled(this.level.enabledFeatures())) { +- this.selectedRecipe = recipeHolder; +- this.resultSlots.setRecipeUsed(recipeHolder); +- this.resultSlots.setItem(0, itemStack); ++ RecipeHolder<SmithingRecipe> recipeholder = (RecipeHolder) list.get(0); ++ ItemStack itemstack = ((SmithingRecipe) recipeholder.value()).assemble(this.inputSlots, this.level.registryAccess()); ++ ++ if (itemstack.isItemEnabled(this.level.enabledFeatures())) { ++ this.selectedRecipe = recipeholder; ++ this.resultSlots.setRecipeUsed(recipeholder); ++ // CraftBukkit start ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack); ++ // CraftBukkit end + } + } + } +@@ -129,4 +144,18 @@ + .filter(i -> !this.getSlot(i).hasItem()) + .findFirst(); + } ++ ++ // CraftBukkit start ++ @Override ++ public CraftInventoryView getBukkitView() { ++ if (bukkitEntity != null) { ++ return bukkitEntity; ++ } ++ ++ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventorySmithing( ++ access.getLocation(), this.inputSlots, this.resultSlots); ++ bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this); ++ return bukkitEntity; ++ } ++ // CraftBukkit end + } |