90 lines
3.0 KiB
Diff
90 lines
3.0 KiB
Diff
--- a/net/minecraft/world/level/block/entity/TileEntityJukeBox.java
|
|
+++ b/net/minecraft/world/level/block/entity/TileEntityJukeBox.java
|
|
@@ -20,12 +20,56 @@
|
|
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 {
|
|
|
|
public static final String SONG_ITEM_TAG_ID = "RecordItem";
|
|
public static final String TICKS_SINCE_SONG_STARTED_TAG_ID = "ticks_since_song_started";
|
|
private ItemStack item;
|
|
private final JukeboxSongPlayer jukeboxSongPlayer;
|
|
+ // 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);
|
|
@@ -134,7 +178,7 @@
|
|
|
|
@Override
|
|
public int getMaxStackSize() {
|
|
- return 1;
|
|
+ return maxStack; // CraftBukkit
|
|
}
|
|
|
|
@Override
|
|
@@ -153,12 +197,17 @@
|
|
}
|
|
|
|
@VisibleForTesting
|
|
- public void setSongItemWithoutPlaying(ItemStack itemstack) {
|
|
+ public void setSongItemWithoutPlaying(ItemStack itemstack, long ticksSinceSongStarted) { // CraftBukkit - add argument
|
|
this.item = itemstack;
|
|
+ this.jukeboxSongPlayer.song = null; // CraftBukkit - reset
|
|
JukeboxSong.fromStack(this.level.registryAccess(), itemstack).ifPresent((holder) -> {
|
|
- this.jukeboxSongPlayer.setSongWithoutPlaying(holder, 0L);
|
|
+ this.jukeboxSongPlayer.setSongWithoutPlaying(holder, ticksSinceSongStarted); // CraftBukkit - add argument
|
|
});
|
|
- 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();
|
|
}
|
|
|