mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
8a3c8cfcd4
By: md_5 <git@md-5.net>
64 lines
3.2 KiB
Diff
64 lines
3.2 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.item.enchantment.EnchantmentManager;
|
|
|
|
+// 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 ContainerRecipeBook<InventoryCrafting> {
|
|
|
|
public static final int CONTAINER_ID = 0;
|
|
@@ -34,15 +40,28 @@
|
|
public static final MinecraftKey EMPTY_ARMOR_SLOT_SHIELD = new MinecraftKey("item/empty_armor_slot_shield");
|
|
static final MinecraftKey[] TEXTURE_EMPTY_SLOTS = new MinecraftKey[]{ContainerPlayer.EMPTY_ARMOR_SLOT_BOOTS, ContainerPlayer.EMPTY_ARMOR_SLOT_LEGGINGS, ContainerPlayer.EMPTY_ARMOR_SLOT_CHESTPLATE, ContainerPlayer.EMPTY_ARMOR_SLOT_HELMET};
|
|
private static final EnumItemSlot[] SLOT_IDS = new EnumItemSlot[]{EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET};
|
|
- private final InventoryCrafting craftSlots = new TransientCraftingContainer(this, 2, 2);
|
|
- private final InventoryCraftResult resultSlots = new InventoryCraftResult();
|
|
+ // CraftBukkit start
|
|
+ private final TransientCraftingContainer craftSlots;
|
|
+ private final InventoryCraftResult resultSlots;
|
|
+ // CraftBukkit end
|
|
public final boolean active;
|
|
private final EntityHuman owner;
|
|
+ // CraftBukkit start
|
|
+ private CraftInventoryView bukkitEntity = null;
|
|
+ private PlayerInventory player;
|
|
+ // CraftBukkit end
|
|
|
|
public ContainerPlayer(PlayerInventory playerinventory, boolean flag, final EntityHuman entityhuman) {
|
|
super((Containers) null, 0);
|
|
this.active = flag;
|
|
this.owner = entityhuman;
|
|
+ // CraftBukkit start
|
|
+ this.resultSlots = new InventoryCraftResult(); // CraftBukkit - moved to before InventoryCrafting construction
|
|
+ this.craftSlots = new TransientCraftingContainer(this, 2, 2, playerinventory.player); // CraftBukkit - pass player
|
|
+ this.craftSlots.resultInventory = this.resultSlots; // CraftBukkit - let InventoryCrafting know about its result slot
|
|
+ this.player = playerinventory; // CraftBukkit - save player
|
|
+ setTitle(IChatBaseComponent.translatable("container.crafting")); // SPIGOT-4722: Allocate title for player inventory
|
|
+ // CraftBukkit end
|
|
this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 154, 28));
|
|
|
|
int i;
|
|
@@ -259,4 +278,17 @@
|
|
public boolean shouldMoveToInventory(int i) {
|
|
return i != 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.player.getBukkitEntity(), inventory, this);
|
|
+ return bukkitEntity;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|