craftbukkit/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch

52 lines
2 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/inventory/ContainerSmithing.java
+++ b/net/minecraft/world/inventory/ContainerSmithing.java
2024-10-23 02:15:00 +11:00
@@ -18,6 +18,8 @@
2021-03-16 09:00:00 +11:00
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
2020-06-25 10:00:00 +10:00
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
+
public class ContainerSmithing extends ContainerAnvilAbstract {
2023-03-15 03:30:00 +11:00
public static final int TEMPLATE_SLOT = 0;
2024-10-23 02:15:00 +11:00
@@ -34,6 +36,9 @@
private final RecipePropertySet templateItemTest;
private final RecipePropertySet additionItemTest;
private final ContainerProperty hasRecipeError;
2020-06-25 10:00:00 +10:00
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity;
+ // CraftBukkit end
public ContainerSmithing(int i, PlayerInventory playerinventory) {
2021-06-11 15:00:00 +10:00
this(i, playerinventory, ContainerAccess.NULL);
2024-10-23 02:15:00 +11:00
@@ -129,7 +134,9 @@
2024-06-14 01:05:00 +10:00
ItemStack itemstack = ((SmithingRecipe) recipeholder.value()).assemble(smithingrecipeinput, this.level.registryAccess());
2024-10-23 02:15:00 +11:00
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;
2020-06-25 10:00:00 +10:00
}
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventorySmithing(
2021-06-11 15:00:00 +10:00
+ access.getLocation(), this.inputSlots, this.resultSlots);
2020-06-25 10:00:00 +10:00
+ bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
}