83 lines
2.5 KiB
Diff
83 lines
2.5 KiB
Diff
--- a/net/minecraft/world/level/block/entity/TileEntityJukeBox.java
|
|
+++ b/net/minecraft/world/level/block/entity/TileEntityJukeBox.java
|
|
@@ -24,6 +24,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.a {
|
|
|
|
private static final int SONG_END_PADDING = 20;
|
|
@@ -32,6 +40,42 @@
|
|
public long tickCount;
|
|
public long recordStartedTick;
|
|
public boolean isPlaying;
|
|
+ // CraftBukkit start - add fields and methods
|
|
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
|
+ private int maxStack = MAX_STACK;
|
|
+ public boolean opened;
|
|
+
|
|
+ @Override
|
|
+ public List<ItemStack> 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<HumanEntity> 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);
|
|
@@ -154,7 +198,7 @@
|
|
|
|
@Override
|
|
public int getMaxStackSize() {
|
|
- return 1;
|
|
+ return maxStack; // CraftBukkit
|
|
}
|
|
|
|
@Override
|
|
@@ -206,7 +250,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();
|
|
}
|
|
}
|