--- a/net/minecraft/world/level/block/entity/TileEntityJukeBox.java +++ b/net/minecraft/world/level/block/entity/TileEntityJukeBox.java @@ -22,6 +22,14 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.ticks.ContainerSingleItem; +// CraftBukkit start +import java.util.Collections; +import java.util.List; +import org.bukkit.Location; +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; +// CraftBukkit end + public class TileEntityJukeBox extends TileEntity implements Clearable, ContainerSingleItem { private static final int SONG_END_PADDING = 20; @@ -30,6 +38,42 @@ public long tickCount; public long recordStartedTick; public boolean isPlaying; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + public boolean opened; + + @Override + public List getContents() { + return Collections.singletonList(item); + } + + @Override + public void onOpen(CraftHumanEntity who) { + transaction.add(who); + } + + @Override + public void onClose(CraftHumanEntity who) { + transaction.remove(who); + } + + @Override + public List getViewers() { + return transaction; + } + + @Override + public void setMaxStackSize(int size) { + maxStack = size; + } + + @Override + public Location getLocation() { + if (level == null) return null; + return new org.bukkit.Location(level.getWorld(), worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()); + } + // CraftBukkit end public TileEntityJukeBox(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.JUKEBOX, blockposition, iblockdata); @@ -150,7 +194,7 @@ @Override public int getMaxStackSize() { - return 1; + return maxStack; // CraftBukkit } @Override @@ -203,7 +247,11 @@ @VisibleForTesting public void setRecordWithoutPlaying(ItemStack itemstack) { this.item = itemstack; - this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock()); + // CraftBukkit start - add null check for level + if (level != null) { + this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock()); + } + // CraftBukkit end this.setChanged(); } }