2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/inventory/ContainerPlayer.java
|
|
|
|
+++ b/net/minecraft/world/inventory/ContainerPlayer.java
|
2023-03-14 17:30:00 +01:00
|
|
|
@@ -13,6 +13,12 @@
|
2024-06-13 17:05:00 +02:00
|
|
|
import net.minecraft.world.item.crafting.RecipeCrafting;
|
2023-09-21 18:40:00 +02:00
|
|
|
import net.minecraft.world.item.crafting.RecipeHolder;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
2022-06-07 18:00:00 +02:00
|
|
|
+import net.minecraft.network.chat.IChatBaseComponent;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
|
|
|
+// CraftBukkit end
|
2016-11-17 02:41:03 +01:00
|
|
|
+
|
2024-06-13 17:05:00 +02:00
|
|
|
public class ContainerPlayer extends ContainerRecipeBook<CraftingInput, RecipeCrafting> {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
public static final int CONTAINER_ID = 0;
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -36,15 +42,28 @@
|
2024-06-13 17:05:00 +02:00
|
|
|
public static final MinecraftKey EMPTY_ARMOR_SLOT_SHIELD = MinecraftKey.withDefaultNamespace("item/empty_armor_slot_shield");
|
|
|
|
private static final Map<EnumItemSlot, MinecraftKey> TEXTURE_EMPTY_SLOTS = Map.of(EnumItemSlot.FEET, ContainerPlayer.EMPTY_ARMOR_SLOT_BOOTS, EnumItemSlot.LEGS, ContainerPlayer.EMPTY_ARMOR_SLOT_LEGGINGS, EnumItemSlot.CHEST, ContainerPlayer.EMPTY_ARMOR_SLOT_CHESTPLATE, EnumItemSlot.HEAD, ContainerPlayer.EMPTY_ARMOR_SLOT_HELMET);
|
2021-06-11 07:00:00 +02:00
|
|
|
private static final EnumItemSlot[] SLOT_IDS = new EnumItemSlot[]{EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET};
|
2023-06-07 17:30:00 +02:00
|
|
|
- private final InventoryCrafting craftSlots = new TransientCraftingContainer(this, 2, 2);
|
2021-06-11 07:00:00 +02:00
|
|
|
- private final InventoryCraftResult resultSlots = new InventoryCraftResult();
|
2019-04-23 04:00:00 +02:00
|
|
|
+ // CraftBukkit start
|
2023-06-07 17:30:00 +02:00
|
|
|
+ private final TransientCraftingContainer craftSlots;
|
2021-06-11 07:00:00 +02:00
|
|
|
+ private final InventoryCraftResult resultSlots;
|
2019-04-23 04:00:00 +02:00
|
|
|
+ // CraftBukkit end
|
2021-06-11 07:00:00 +02:00
|
|
|
public final boolean active;
|
2016-02-29 22:32:46 +01:00
|
|
|
private final EntityHuman owner;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ private CraftInventoryView bukkitEntity = null;
|
|
|
|
+ private PlayerInventory player;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
|
2022-06-07 18:00:00 +02:00
|
|
|
public ContainerPlayer(PlayerInventory playerinventory, boolean flag, final EntityHuman entityhuman) {
|
2019-04-23 04:00:00 +02:00
|
|
|
super((Containers) null, 0);
|
2021-06-11 07:00:00 +02:00
|
|
|
this.active = flag;
|
2016-02-29 22:32:46 +01:00
|
|
|
this.owner = entityhuman;
|
|
|
|
+ // CraftBukkit start
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.resultSlots = new InventoryCraftResult(); // CraftBukkit - moved to before InventoryCrafting construction
|
2023-06-07 17:30:00 +02:00
|
|
|
+ this.craftSlots = new TransientCraftingContainer(this, 2, 2, playerinventory.player); // CraftBukkit - pass player
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.craftSlots.resultInventory = this.resultSlots; // CraftBukkit - let InventoryCrafting know about its result slot
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.player = playerinventory; // CraftBukkit - save player
|
2022-06-07 18:00:00 +02:00
|
|
|
+ setTitle(IChatBaseComponent.translatable("container.crafting")); // SPIGOT-4722: Allocate title for player inventory
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit end
|
2021-11-21 23:00:00 +01:00
|
|
|
this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 154, 28));
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
int i;
|
2024-06-13 17:05:00 +02:00
|
|
|
@@ -73,7 +92,7 @@
|
2024-04-23 17:15:00 +02:00
|
|
|
this.addSlot(new Slot(playerinventory, i, 8 + i * 18, 142));
|
|
|
|
}
|
|
|
|
|
|
|
|
- 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) {
|
2024-06-13 17:05:00 +02:00
|
|
|
entityhuman.onEquipItem(EnumItemSlot.OFFHAND, itemstack1, itemstack);
|
|
|
|
@@ -230,4 +249,17 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
public boolean shouldMoveToInventory(int i) {
|
|
|
|
return i != this.getResultSlotIndex();
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ @Override
|
|
|
|
+ public CraftInventoryView getBukkitView() {
|
|
|
|
+ if (bukkitEntity != null) {
|
|
|
|
+ return bukkitEntity;
|
|
|
|
+ }
|
|
|
|
+
|
2021-06-11 07:00:00 +02:00
|
|
|
+ CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftSlots, this.resultSlots);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
|
|
|
|
+ return bukkitEntity;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|