diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/inventory/CraftingMenu.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/inventory/CraftingMenu.java.patch | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/inventory/CraftingMenu.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/inventory/CraftingMenu.java.patch new file mode 100644 index 0000000000..168643e8b3 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/inventory/CraftingMenu.java.patch @@ -0,0 +1,75 @@ +--- a/net/minecraft/world/inventory/CraftingMenu.java ++++ b/net/minecraft/world/inventory/CraftingMenu.java +@@ -15,6 +15,9 @@ + import net.minecraft.world.item.crafting.RecipeType; + import net.minecraft.world.level.Level; + import net.minecraft.world.level.block.Blocks; ++import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting; ++import org.bukkit.craftbukkit.inventory.CraftInventoryView; ++// CraftBukkit end + + public class CraftingMenu extends RecipeBookMenu<CraftingContainer> { + public static final int RESULT_SLOT = 0; +@@ -24,10 +28,13 @@ + private static final int INV_SLOT_END = 37; + private static final int USE_ROW_SLOT_START = 37; + private static final int USE_ROW_SLOT_END = 46; +- private final CraftingContainer craftSlots = new TransientCraftingContainer(this, 3, 3); +- private final ResultContainer resultSlots = new ResultContainer(); +- private final ContainerLevelAccess access; ++ public final TransientCraftingContainer craftSlots; // CraftBukkit ++ public final ResultContainer resultSlots; ++ public final ContainerLevelAccess access; + private final Player player; ++ // CraftBukkit start ++ private CraftInventoryView bukkitEntity = null; ++ // CraftBukkit end + + public CraftingMenu(int containerId, Inventory playerInventory) { + this(containerId, playerInventory, ContainerLevelAccess.NULL); +@@ -35,6 +42,11 @@ + + public CraftingMenu(int containerId, Inventory playerInventory, ContainerLevelAccess access) { + super(MenuType.CRAFTING, containerId); ++ // CraftBukkit start - Switched order of IInventory construction and stored player ++ this.resultSlots = new ResultContainer(); ++ this.craftSlots = new TransientCraftingContainer(this, 3, 3, playerInventory.player); // CraftBukkit - pass player ++ this.craftSlots.resultInventory = this.resultSlots; ++ // CraftBukkit end + this.access = access; + this.player = playerInventory.player; + this.addSlot(new ResultSlot(playerInventory.player, this.craftSlots, this.resultSlots, 0, 124, 35)); +@@ -71,6 +90,7 @@ + } + } + } ++ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(container, result, itemstack, menu.getBukkitView(), optional.map(RecipeHolder::toBukkitRecipe).orElse(null) instanceof RepairItemRecipe); // CraftBukkit + + result.setItem(0, itemStack); + menu.setRemoteSlot(0, itemStack); +@@ -107,6 +131,7 @@ + + @Override + public boolean stillValid(Player player) { ++ if (!this.checkReachable) return true; // CraftBukkit + return stillValid(this.access, player, Blocks.CRAFTING_TABLE); + } + +@@ -191,4 +220,17 @@ + public boolean shouldMoveToInventory(int slotIndex) { + return slotIndex != this.getResultSlotIndex(); + } ++ ++ // CraftBukkit start ++ @Override ++ public CraftInventoryView getBukkitView() { ++ if (bukkitEntity != null) { ++ return bukkitEntity; ++ } ++ ++ CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftSlots, this.resultSlots); ++ bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this); ++ return bukkitEntity; ++ } ++ // CraftBukkit end + } |