--- a/net/minecraft/world/inventory/InventoryMenu.java
+++ b/net/minecraft/world/inventory/InventoryMenu.java
@@ -1,6 +1,7 @@
 package net.minecraft.world.inventory;
 
 import com.mojang.datafixers.util.Pair;
+import net.minecraft.network.chat.Component;
 import net.minecraft.resources.ResourceLocation;
 import net.minecraft.world.Container;
 import net.minecraft.world.entity.EquipmentSlot;
@@ -12,8 +13,12 @@
 import net.minecraft.world.item.crafting.Recipe;
 import net.minecraft.world.item.crafting.RecipeHolder;
 import net.minecraft.world.item.enchantment.EnchantmentHelper;
+import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftInventoryCrafting;
+import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftInventoryView;
+// CraftBukkit end
 
 public class InventoryMenu extends RecipeBookMenu<CraftingContainer> {
+
     public static final int CONTAINER_ID = 0;
     public static final int RESULT_SLOT = 0;
     public static final int CRAFT_SLOT_START = 1;
@@ -31,31 +36,48 @@
     public static final ResourceLocation EMPTY_ARMOR_SLOT_LEGGINGS = new ResourceLocation("item/empty_armor_slot_leggings");
     public static final ResourceLocation EMPTY_ARMOR_SLOT_BOOTS = new ResourceLocation("item/empty_armor_slot_boots");
     public static final ResourceLocation EMPTY_ARMOR_SLOT_SHIELD = new ResourceLocation("item/empty_armor_slot_shield");
-    static final ResourceLocation[] TEXTURE_EMPTY_SLOTS = new ResourceLocation[]{EMPTY_ARMOR_SLOT_BOOTS, EMPTY_ARMOR_SLOT_LEGGINGS, EMPTY_ARMOR_SLOT_CHESTPLATE, EMPTY_ARMOR_SLOT_HELMET};
+    static final ResourceLocation[] TEXTURE_EMPTY_SLOTS = new ResourceLocation[]{InventoryMenu.EMPTY_ARMOR_SLOT_BOOTS, InventoryMenu.EMPTY_ARMOR_SLOT_LEGGINGS, InventoryMenu.EMPTY_ARMOR_SLOT_CHESTPLATE, InventoryMenu.EMPTY_ARMOR_SLOT_HELMET};
     private static final EquipmentSlot[] SLOT_IDS = new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET};
-    private final CraftingContainer craftSlots = new TransientCraftingContainer(this, 2, 2);
-    private final ResultContainer resultSlots = new ResultContainer();
+    // CraftBukkit start
+    private final TransientCraftingContainer craftSlots;
+    private final ResultContainer resultSlots;
+    // CraftBukkit end
     public final boolean active;
     private final Player owner;
+    // CraftBukkit start
+    private CraftInventoryView bukkitEntity = null;
+    private Inventory player;
+    // CraftBukkit end
 
     public InventoryMenu(Inventory inventory, boolean onServer, final Player owner) {
-        super((MenuType<?>)null, 0);
+        super((MenuType) null, 0);
         this.active = onServer;
         this.owner = owner;
+        // CraftBukkit start
+        this.resultSlots = new ResultContainer(); // CraftBukkit - moved to before InventoryCrafting construction
+        this.craftSlots = new TransientCraftingContainer(this, 2, 2, inventory.player); // CraftBukkit - pass player
+        this.craftSlots.resultInventory = this.resultSlots; // CraftBukkit - let InventoryCrafting know about its result slot
+        this.player = inventory; // CraftBukkit - save player
+        setTitle(Component.translatable("container.crafting")); // SPIGOT-4722: Allocate title for player inventory
+        // CraftBukkit end
         this.addSlot(new ResultSlot(inventory.player, this.craftSlots, this.resultSlots, 0, 154, 28));
 
-        for(int i = 0; i < 2; ++i) {
-            for(int j = 0; j < 2; ++j) {
+        int i;
+        int j;
+
+        for (i = 0; i < 2; ++i) {
+            for (j = 0; j < 2; ++j) {
                 this.addSlot(new Slot(this.craftSlots, j + i * 2, 98 + j * 18, 18 + i * 18));
             }
         }
 
-        for(int k = 0; k < 4; ++k) {
-            final EquipmentSlot equipmentSlot = SLOT_IDS[k];
-            this.addSlot(new Slot(inventory, 39 - k, 8, 8 + k * 18) {
+        for (i = 0; i < 4; ++i) {
+            final EquipmentSlot enumitemslot = InventoryMenu.SLOT_IDS[i];
+
+            this.addSlot(new Slot(inventory, 39 - i, 8, 8 + i * 18) {
                 @Override
                 public void setByPlayer(ItemStack stack, ItemStack previousStack) {
-                    InventoryMenu.onEquipItem(owner, equipmentSlot, stack, previousStack);
+                    InventoryMenu.onEquipItem(owner, enumitemslot, stack, previousStack);
                     super.setByPlayer(stack, previousStack);
                 }
 
@@ -66,30 +88,31 @@
 
                 @Override
                 public boolean mayPlace(ItemStack stack) {
-                    return equipmentSlot == Mob.getEquipmentSlotForItem(stack);
+                    return enumitemslot == Mob.getEquipmentSlotForItem(stack);
                 }
 
                 @Override
                 public boolean mayPickup(Player playerEntity) {
-                    ItemStack itemStack = this.getItem();
-                    return !itemStack.isEmpty() && !playerEntity.isCreative() && EnchantmentHelper.hasBindingCurse(itemStack) ? false : super.mayPickup(playerEntity);
+                    ItemStack itemstack = this.getItem();
+
+                    return !itemstack.isEmpty() && !playerEntity.isCreative() && EnchantmentHelper.hasBindingCurse(itemstack) ? false : super.mayPickup(playerEntity);
                 }
 
                 @Override
                 public Pair<ResourceLocation, ResourceLocation> getNoItemIcon() {
-                    return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.TEXTURE_EMPTY_SLOTS[equipmentSlot.getIndex()]);
+                    return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.TEXTURE_EMPTY_SLOTS[enumitemslot.getIndex()]);
                 }
             });
         }
 
-        for(int l = 0; l < 3; ++l) {
-            for(int m = 0; m < 9; ++m) {
-                this.addSlot(new Slot(inventory, m + (l + 1) * 9, 8 + m * 18, 84 + l * 18));
+        for (i = 0; i < 3; ++i) {
+            for (j = 0; j < 9; ++j) {
+                this.addSlot(new Slot(inventory, j + (i + 1) * 9, 8 + j * 18, 84 + i * 18));
             }
         }
 
-        for(int n = 0; n < 9; ++n) {
-            this.addSlot(new Slot(inventory, n, 8 + n * 18, 142));
+        for (i = 0; i < 9; ++i) {
+            this.addSlot(new Slot(inventory, i, 8 + i * 18, 142));
         }
 
         this.addSlot(new Slot(inventory, 40, 77, 62) {
@@ -151,64 +174,68 @@
 
     @Override
     public ItemStack quickMoveStack(Player player, int slot) {
-        ItemStack itemStack = ItemStack.EMPTY;
-        Slot slot2 = this.slots.get(slot);
-        if (slot2.hasItem()) {
-            ItemStack itemStack2 = slot2.getItem();
-            itemStack = itemStack2.copy();
-            EquipmentSlot equipmentSlot = Mob.getEquipmentSlotForItem(itemStack);
+        ItemStack itemstack = ItemStack.EMPTY;
+        Slot slot1 = (Slot) this.slots.get(slot);
+
+        if (slot1.hasItem()) {
+            ItemStack itemstack1 = slot1.getItem();
+
+            itemstack = itemstack1.copy();
+            EquipmentSlot enumitemslot = Mob.getEquipmentSlotForItem(itemstack);
+
             if (slot == 0) {
-                if (!this.moveItemStackTo(itemStack2, 9, 45, true)) {
+                if (!this.moveItemStackTo(itemstack1, 9, 45, true)) {
                     return ItemStack.EMPTY;
                 }
 
-                slot2.onQuickCraft(itemStack2, itemStack);
+                slot1.onQuickCraft(itemstack1, itemstack);
             } else if (slot >= 1 && slot < 5) {
-                if (!this.moveItemStackTo(itemStack2, 9, 45, false)) {
+                if (!this.moveItemStackTo(itemstack1, 9, 45, false)) {
                     return ItemStack.EMPTY;
                 }
             } else if (slot >= 5 && slot < 9) {
-                if (!this.moveItemStackTo(itemStack2, 9, 45, false)) {
+                if (!this.moveItemStackTo(itemstack1, 9, 45, false)) {
                     return ItemStack.EMPTY;
                 }
-            } else if (equipmentSlot.getType() == EquipmentSlot.Type.ARMOR && !this.slots.get(8 - equipmentSlot.getIndex()).hasItem()) {
-                int i = 8 - equipmentSlot.getIndex();
-                if (!this.moveItemStackTo(itemStack2, i, i + 1, false)) {
+            } else if (enumitemslot.getType() == EquipmentSlot.Type.ARMOR && !((Slot) this.slots.get(8 - enumitemslot.getIndex())).hasItem()) {
+                int j = 8 - enumitemslot.getIndex();
+
+                if (!this.moveItemStackTo(itemstack1, j, j + 1, false)) {
                     return ItemStack.EMPTY;
                 }
-            } else if (equipmentSlot == EquipmentSlot.OFFHAND && !this.slots.get(45).hasItem()) {
-                if (!this.moveItemStackTo(itemStack2, 45, 46, false)) {
+            } else if (enumitemslot == EquipmentSlot.OFFHAND && !((Slot) this.slots.get(45)).hasItem()) {
+                if (!this.moveItemStackTo(itemstack1, 45, 46, false)) {
                     return ItemStack.EMPTY;
                 }
             } else if (slot >= 9 && slot < 36) {
-                if (!this.moveItemStackTo(itemStack2, 36, 45, false)) {
+                if (!this.moveItemStackTo(itemstack1, 36, 45, false)) {
                     return ItemStack.EMPTY;
                 }
             } else if (slot >= 36 && slot < 45) {
-                if (!this.moveItemStackTo(itemStack2, 9, 36, false)) {
+                if (!this.moveItemStackTo(itemstack1, 9, 36, false)) {
                     return ItemStack.EMPTY;
                 }
-            } else if (!this.moveItemStackTo(itemStack2, 9, 45, false)) {
+            } else if (!this.moveItemStackTo(itemstack1, 9, 45, false)) {
                 return ItemStack.EMPTY;
             }
 
-            if (itemStack2.isEmpty()) {
-                slot2.setByPlayer(ItemStack.EMPTY, itemStack);
+            if (itemstack1.isEmpty()) {
+                slot1.setByPlayer(ItemStack.EMPTY, itemstack);
             } else {
-                slot2.setChanged();
+                slot1.setChanged();
             }
 
-            if (itemStack2.getCount() == itemStack.getCount()) {
+            if (itemstack1.getCount() == itemstack.getCount()) {
                 return ItemStack.EMPTY;
             }
 
-            slot2.onTake(player, itemStack2);
+            slot1.onTake(player, itemstack1);
             if (slot == 0) {
-                player.drop(itemStack2, false);
+                player.drop(itemstack1, false);
             }
         }
 
-        return itemStack;
+        return itemstack;
     }
 
     @Override
@@ -249,4 +276,17 @@
     public boolean shouldMoveToInventory(int index) {
         return index != this.getResultSlotIndex();
     }
+
+    // CraftBukkit start
+    @Override
+    public CraftInventoryView getBukkitView() {
+        if (this.bukkitEntity != null) {
+            return this.bukkitEntity;
+        }
+
+        CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftSlots, this.resultSlots);
+        this.bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+        return this.bukkitEntity;
+    }
+    // CraftBukkit end
 }
