2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/inventory/ContainerSmithing.java
|
|
|
|
+++ b/net/minecraft/world/inventory/ContainerSmithing.java
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -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;
|
2020-06-25 02:00:00 +02:00
|
|
|
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
|
|
|
|
+
|
|
|
|
public class ContainerSmithing extends ContainerAnvilAbstract {
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
private final World level;
|
2020-06-25 02:00:00 +02:00
|
|
|
@Nullable
|
2021-06-11 07:00:00 +02:00
|
|
|
private RecipeSmithing selectedRecipe;
|
|
|
|
private final List<RecipeSmithing> 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);
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -61,7 +66,7 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
List<RecipeSmithing> 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 {
|
2022-12-07 17:00:00 +01:00
|
|
|
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
|
|
|
|
}
|
2020-07-22 10:21:45 +02:00
|
|
|
}
|
|
|
|
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -86,4 +93,18 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
public boolean canTakeItemForPickAll(ItemStack itemstack, Slot slot) {
|
|
|
|
return slot.container != this.resultSlots && super.canTakeItemForPickAll(itemstack, slot);
|
2020-06-25 02:00:00 +02: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 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
|
|
|
|
}
|