0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-22 04:16:17 +00:00
craftbukkit/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch
2024-10-23 02:15:00 +11:00

61 lines
2.5 KiB
Diff

--- a/net/minecraft/world/inventory/ContainerSmithing.java
+++ b/net/minecraft/world/inventory/ContainerSmithing.java
@@ -18,6 +18,8 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
+
public class ContainerSmithing extends ContainerAnvilAbstract {
public static final int TEMPLATE_SLOT = 0;
@@ -34,6 +36,9 @@
private final RecipePropertySet templateItemTest;
private final RecipePropertySet additionItemTest;
private final ContainerProperty hasRecipeError;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity;
+ // CraftBukkit end
public ContainerSmithing(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -117,7 +122,7 @@
public void createResult() {
SmithingRecipeInput smithingrecipeinput = this.createRecipeInput();
World world = this.level;
- Optional optional;
+ Optional<RecipeHolder<SmithingRecipe>> optional; // CraftBukkit - decompile error
if (world instanceof WorldServer worldserver) {
optional = worldserver.recipeAccess().getRecipeFor(Recipes.SMITHING, smithingrecipeinput, worldserver);
@@ -129,7 +134,9 @@
ItemStack itemstack = ((SmithingRecipe) recipeholder.value()).assemble(smithingrecipeinput, this.level.registryAccess());
this.resultSlots.setRecipeUsed(recipeholder);
- this.resultSlots.setItem(0, itemstack);
+ // CraftBukkit start
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack);
+ // CraftBukkit end
}, () -> {
this.resultSlots.setRecipeUsed((RecipeHolder) null);
this.resultSlots.setItem(0, ItemStack.EMPTY);
@@ -149,4 +156,18 @@
public boolean hasRecipeError() {
return this.hasRecipeError.get() > 0;
}
+
+ // 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
}