2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/inventory/ContainerSmithing.java
|
|
|
|
+++ b/net/minecraft/world/inventory/ContainerSmithing.java
|
2023-03-14 17:30:00 +01:00
|
|
|
@@ -12,6 +12,8 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.level.block.Blocks;
|
|
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
2020-06-25 02:00:00 +02:00
|
|
|
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
|
|
|
|
+
|
|
|
|
public class ContainerSmithing extends ContainerAnvilAbstract {
|
|
|
|
|
2023-03-14 17:30:00 +01:00
|
|
|
public static final int TEMPLATE_SLOT = 0;
|
|
|
|
@@ -27,6 +29,9 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
@Nullable
|
2023-03-14 17:30:00 +01:00
|
|
|
private SmithingRecipe selectedRecipe;
|
|
|
|
private final List<SmithingRecipe> recipes;
|
2020-06-25 02:00:00 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ private CraftInventoryView bukkitEntity;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
|
|
|
|
public ContainerSmithing(int i, PlayerInventory playerinventory) {
|
2021-06-11 07:00:00 +02:00
|
|
|
this(i, playerinventory, ContainerAccess.NULL);
|
2023-06-07 17:30:00 +02:00
|
|
|
@@ -96,7 +101,7 @@
|
2023-03-14 17:30:00 +01:00
|
|
|
List<SmithingRecipe> list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, this.inputSlots, this.level);
|
2020-07-22 10:21:45 +02:00
|
|
|
|
|
|
|
if (list.isEmpty()) {
|
2021-06-11 07:00:00 +02:00
|
|
|
- this.resultSlots.setItem(0, ItemStack.EMPTY);
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
2020-07-22 10:21:45 +02:00
|
|
|
} else {
|
2023-03-14 17:30:00 +01:00
|
|
|
SmithingRecipe smithingrecipe = (SmithingRecipe) list.get(0);
|
|
|
|
ItemStack itemstack = smithingrecipe.assemble(this.inputSlots, this.level.registryAccess());
|
2023-06-07 17:30:00 +02:00
|
|
|
@@ -104,7 +109,9 @@
|
2022-12-07 17:00:00 +01:00
|
|
|
if (itemstack.isItemEnabled(this.level.enabledFeatures())) {
|
2023-03-14 17:30:00 +01:00
|
|
|
this.selectedRecipe = smithingrecipe;
|
|
|
|
this.resultSlots.setRecipeUsed(smithingrecipe);
|
2022-12-07 17:00:00 +01:00
|
|
|
- this.resultSlots.setItem(0, itemstack);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack);
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2020-07-22 10:21:45 +02:00
|
|
|
}
|
|
|
|
|
2023-06-07 17:30:00 +02:00
|
|
|
@@ -132,4 +139,18 @@
|
2023-03-14 17:30:00 +01:00
|
|
|
return findSlotMatchingIngredient(smithingrecipe, itemstack);
|
|
|
|
}).anyMatch(Optional::isPresent);
|
2020-06-25 02:00:00 +02:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ @Override
|
|
|
|
+ public CraftInventoryView getBukkitView() {
|
|
|
|
+ if (bukkitEntity != null) {
|
|
|
|
+ return bukkitEntity;
|
|
|
|
+ }
|
|
|
|
+
|
2023-03-14 17:30:00 +01:00
|
|
|
+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventorySmithingNew(
|
2021-06-11 07:00:00 +02:00
|
|
|
+ access.getLocation(), this.inputSlots, this.resultSlots);
|
2020-06-25 02:00:00 +02:00
|
|
|
+ bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this);
|
|
|
|
+ return bukkitEntity;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|