Lazy evaluate ender chest inventory holder

This commit is contained in:
Bjarne Koll
2025-08-04 14:45:52 +02:00
parent c60f4436f0
commit e9380882f2
@@ -1,20 +1,28 @@
--- a/net/minecraft/world/inventory/PlayerEnderChestContainer.java
+++ b/net/minecraft/world/inventory/PlayerEnderChestContainer.java
@@ -13,8 +_,15 @@
@@ -12,9 +_,23 @@
public class PlayerEnderChestContainer extends SimpleContainer {
@Nullable
private EnderChestBlockEntity activeChest;
-
- public PlayerEnderChestContainer() {
- super(27);
+ // Paper start
+ // CraftBukkit start
+ private final Player owner;
+
+ @Override
+ public org.bukkit.inventory.InventoryHolder getOwner() {
+ return this.owner.getBukkitEntity();
+ }
+
+ @Override
+ public @Nullable org.bukkit.Location getLocation() {
+ return this.activeChest != null ? org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.activeChest.getBlockPos(), this.activeChest.getLevel().getWorld()) : null;
+ }
+
+ public PlayerEnderChestContainer(Player owner) {
+ super(27, owner.getBukkitEntity());
+ // Paper end
super(27);
+ this.owner = owner;
+ // CraftBukkit end
}
public void setActiveChest(EnderChestBlockEntity enderChestBlockEntity) {