PaperMC/paper-server/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch
CraftBukkit/Spigot d3a23f42c3 Update to Minecraft 1.21.2
By: md_5 <git@md-5.net>
2024-10-23 02:15:00 +11:00

59 lines
2.4 KiB
Diff

--- a/net/minecraft/world/inventory/ContainerPlayer.java
+++ b/net/minecraft/world/inventory/ContainerPlayer.java
@@ -13,6 +13,12 @@
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.level.World;
+// CraftBukkit start
+import net.minecraft.network.chat.IChatBaseComponent;
+import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerPlayer extends AbstractCraftingMenu {
public static final int CONTAINER_ID = 0;
@@ -40,9 +46,15 @@
private static final EnumItemSlot[] SLOT_IDS = new EnumItemSlot[]{EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET};
public final boolean active;
private final EntityHuman owner;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ // CraftBukkit end
public ContainerPlayer(PlayerInventory playerinventory, boolean flag, final EntityHuman entityhuman) {
- super((Containers) null, 0, 2, 2);
+ // CraftBukkit start
+ super((Containers) null, 0, 2, 2, playerinventory); // CraftBukkit - save player
+ setTitle(IChatBaseComponent.translatable("container.crafting")); // SPIGOT-4722: Allocate title for player inventory
+ // CraftBukkit end
this.active = flag;
this.owner = entityhuman;
this.addResultSlot(entityhuman, 154, 28);
@@ -56,7 +68,7 @@
}
this.addStandardInventorySlots(playerinventory, 8, 84);
- this.addSlot(new Slot(this, playerinventory, 40, 77, 62) {
+ this.addSlot(new Slot(playerinventory, 40, 77, 62) { // CraftBukkit - decompile error
@Override
public void setByPlayer(ItemStack itemstack, ItemStack itemstack1) {
entityhuman.onEquipItem(EnumItemSlot.OFFHAND, itemstack1, itemstack);
@@ -192,4 +204,17 @@
protected EntityHuman owner() {
return this.owner;
}
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftSlots, this.resultSlots);
+ bukkitEntity = new CraftInventoryView(this.owner.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
}