--- a/net/minecraft/world/level/block/entity/TileEntityJukeBox.java +++ b/net/minecraft/world/level/block/entity/TileEntityJukeBox.java @@ -24,14 +24,57 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.ticks.ContainerSingleItem; +// CraftBukkit start +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; private final NonNullList items; private int ticksSinceLastEvent; - private long tickCount; - private long recordStartedTick; - private boolean isPlaying; + 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 this.items; + } + + @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 +193,7 @@ @Override public int getMaxStackSize() { - return 1; + return maxStack; // CraftBukkit } @Override @@ -203,7 +246,11 @@ @VisibleForTesting public void setRecordWithoutPlaying(ItemStack itemstack) { this.items.set(0, 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(); } }