Fix NPE for Jukebox#setRecord

Fallback to the global registry if no level exists
This commit is contained in:
Jake Potrebic 2024-06-17 17:41:09 -07:00
parent 164078cd2a
commit d9e3bee3b5

View File

@ -78,7 +78,7 @@
+ 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) -> {
+ JukeboxSong.fromStack(this.level != null ? this.level.registryAccess() : org.bukkit.craftbukkit.CraftRegistry.getMinecraftRegistry(), itemstack).ifPresent((holder) -> { // Paper - fallback to other RegistyrAccess if no level
+ this.jukeboxSongPlayer.setSongWithoutPlaying(holder, ticksSinceSongStarted); // CraftBukkit - add argument
});
- this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock());