PaperMC/paper-server/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch

60 lines
2.5 KiB
Diff
Raw Normal View History

2021-03-15 23:00:00 +01:00
--- a/net/minecraft/world/inventory/ContainerSmithing.java
+++ b/net/minecraft/world/inventory/ContainerSmithing.java
@@ -11,12 +11,17 @@
2021-03-15 23:00:00 +01:00
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<RecipeSmithing> recipes;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity;
+ // CraftBukkit end
public ContainerSmithing(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -61,7 +66,7 @@
List<RecipeSmithing> list = this.level.getRecipeManager().getRecipesFor(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 {
RecipeSmithing recipesmithing = (RecipeSmithing) list.get(0);
ItemStack itemstack = recipesmithing.assemble(this.inputSlots);
@@ -69,7 +74,9 @@
if (itemstack.isItemEnabled(this.level.enabledFeatures())) {
this.selectedRecipe = recipesmithing;
this.resultSlots.setRecipeUsed(recipesmithing);
- this.resultSlots.setItem(0, itemstack);
+ // CraftBukkit start
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack);
+ // CraftBukkit end
}
}
@@ -86,4 +93,18 @@
public boolean canTakeItemForPickAll(ItemStack itemstack, Slot slot) {
return slot.container != this.resultSlots && super.canTakeItemForPickAll(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
}