--- a/net/minecraft/world/inventory/ContainerSmithing.java +++ b/net/minecraft/world/inventory/ContainerSmithing.java @@ -11,12 +11,17 @@ 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 { private final World level; @Nullable private RecipeSmithing selectedRecipe; private final List recipes; + // CraftBukkit start + private CraftInventoryView bukkitEntity; + // CraftBukkit end public ContainerSmithing(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); @@ -61,13 +66,15 @@ List list = this.level.getCraftingManager().b(Recipes.SMITHING, this.inputSlots, this.level); if (list.isEmpty()) { - this.resultSlots.setItem(0, ItemStack.EMPTY); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit } else { this.selectedRecipe = (RecipeSmithing) list.get(0); ItemStack itemstack = this.selectedRecipe.a(this.inputSlots); this.resultSlots.setRecipeUsed(this.selectedRecipe); - this.resultSlots.setItem(0, itemstack); + // CraftBukkit start + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack); + // CraftBukkit end } } @@ -83,4 +90,18 @@ public boolean a(ItemStack itemstack, Slot slot) { return slot.container != this.resultSlots && super.a(itemstack, slot); } + + // 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 }