craftbukkit/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch

51 lines
1.9 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/inventory/ContainerPlayer.java
+++ b/net/minecraft/world/inventory/ContainerPlayer.java
2024-12-04 03:20:00 +11:00
@@ -12,6 +12,12 @@
2023-09-22 02:40:00 +10:00
import net.minecraft.world.item.crafting.RecipeHolder;
2024-10-23 02:15:00 +11:00
import net.minecraft.world.level.World;
+// CraftBukkit start
2022-06-08 02:00:00 +10:00
+import net.minecraft.network.chat.IChatBaseComponent;
+import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
2016-11-17 12:41:03 +11:00
+
2024-10-23 02:15:00 +11:00
public class ContainerPlayer extends AbstractCraftingMenu {
2021-06-11 15:00:00 +10:00
public static final int CONTAINER_ID = 0;
2024-12-04 03:20:00 +11:00
@@ -38,9 +44,15 @@
2021-06-11 15:00:00 +10:00
private static final EnumItemSlot[] SLOT_IDS = new EnumItemSlot[]{EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET};
public final boolean active;
2016-03-01 08:32:46 +11:00
private final EntityHuman owner;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ // CraftBukkit end
2022-06-08 02:00:00 +10:00
public ContainerPlayer(PlayerInventory playerinventory, boolean flag, final EntityHuman entityhuman) {
2024-10-23 02:15:00 +11:00
- super((Containers) null, 0, 2, 2);
2016-03-01 08:32:46 +11:00
+ // CraftBukkit start
2024-10-23 02:15:00 +11:00
+ super((Containers) null, 0, 2, 2, playerinventory); // CraftBukkit - save player
2022-06-08 02:00:00 +10:00
+ setTitle(IChatBaseComponent.translatable("container.crafting")); // SPIGOT-4722: Allocate title for player inventory
2016-03-01 08:32:46 +11:00
+ // CraftBukkit end
2024-10-23 02:15:00 +11:00
this.active = flag;
this.owner = entityhuman;
this.addResultSlot(entityhuman, 154, 28);
2024-12-04 03:20:00 +11:00
@@ -190,4 +202,17 @@
2024-10-23 02:15:00 +11:00
protected EntityHuman owner() {
return this.owner;
}
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
2021-06-11 15:00:00 +10:00
+ CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftSlots, this.resultSlots);
2024-10-23 02:15:00 +11:00
+ bukkitEntity = new CraftInventoryView(this.owner.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
}