From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 14 Mar 2023 18:55:56 -0700 Subject: [PATCH] Fix Jukeboxes diff --git a/src/main/java/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java @@ -0,0 +0,0 @@ public class JukeboxBlockEntity extends BlockEntity implements Clearable, Contai @Override public int getMaxStackSize() { - return 1; + return this.maxStack; // Paper } @Override @@ -0,0 +0,0 @@ public class JukeboxBlockEntity extends BlockEntity implements Clearable, Contai this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock()); this.setChanged(); } + + // Paper start + public java.util.List transaction = new java.util.ArrayList<>(); + private int maxStack = 1; + @Override + public java.util.List getContents() { + return this.items; + } + + @Override + public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity who) { + this.transaction.add(who); + } + + @Override + public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity who) { + this.transaction.remove(who); + } + + @Override + public java.util.List getViewers() { + return this.transaction; + } + + @Override + public void setMaxStackSize(int size) { + this.maxStack = size; + } + + @Override + public org.bukkit.Location getLocation() { + return new org.bukkit.Location(this.level.getWorld(), this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ()); + } + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java b/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java @@ -0,0 +0,0 @@ public class CraftJukebox extends CraftBlockEntityState impl jukebox.popOutRecord(); return result; } + // Paper start + @Override + public org.bukkit.inventory.Inventory getInventory() { + if (!this.isPlaced()) { + return this.getSnapshotInventory(); + } + return new org.bukkit.craftbukkit.inventory.CraftInventory(this.getTileEntity()); + } + + @Override + public org.bukkit.inventory.Inventory getSnapshotInventory() { + return new org.bukkit.craftbukkit.inventory.CraftInventory(this.getSnapshot()); + } + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -0,0 +0,0 @@ public class CraftInventory implements Inventory { return InventoryType.COMPOSTER; } else if (this instanceof CraftInventorySmithingNew) { return InventoryType.SMITHING_NEW; + // Paper start + } else if (this.inventory instanceof net.minecraft.world.level.block.entity.JukeboxBlockEntity) { + return InventoryType.JUKEBOX; + // Paper end } else { return InventoryType.CHEST; }