0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2025-02-16 15:45:59 +00:00
2024-12-04 03:20:00 +11:00

60 lines
2.4 KiB
Diff

--- a/net/minecraft/world/inventory/ContainerPlayer.java
+++ b/net/minecraft/world/inventory/ContainerPlayer.java
@@ -12,6 +12,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;
@@ -38,9 +44,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);
@@ -54,7 +66,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);
@@ -190,4 +202,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
}