@@ -4,12 +4,10 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.BlockJukeBox;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntityJukeBox;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Jukebox;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryJukebox;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemType;
|
||||
@@ -44,18 +42,11 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
|
||||
boolean result = super.update(force, applyPhysics);
|
||||
|
||||
if (result && this.isPlaced() && this.getType() == Material.JUKEBOX) {
|
||||
Material record = this.getPlaying();
|
||||
getWorldHandle().setBlock(this.getPosition(), data, 3);
|
||||
|
||||
TileEntity tileEntity = this.getTileEntityFromWorld();
|
||||
if (tileEntity instanceof TileEntityJukeBox jukebox) {
|
||||
CraftWorld world = (CraftWorld) this.getWorld();
|
||||
if (record.isAir()) {
|
||||
jukebox.setRecordWithoutPlaying(ItemStack.EMPTY);
|
||||
world.playEffect(this.getLocation(), Effect.IRON_DOOR_CLOSE, 0); // TODO: Fix this enum constant. This stops jukeboxes
|
||||
} else {
|
||||
world.playEffect(this.getLocation(), Effect.RECORD_PLAY, record);
|
||||
}
|
||||
jukebox.setTheItem(jukebox.getTheItem());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,9 +83,7 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
|
||||
ItemStack nms = CraftItemStack.asNMSCopy(record);
|
||||
|
||||
TileEntityJukeBox snapshot = this.getSnapshot();
|
||||
snapshot.setRecordWithoutPlaying(nms);
|
||||
snapshot.recordStartedTick = snapshot.tickCount;
|
||||
snapshot.isPlaying = !nms.isEmpty();
|
||||
snapshot.setSongItemWithoutPlaying(nms, snapshot.getSongPlayer().getTicksSinceSongStarted());
|
||||
|
||||
this.data = this.data.setValue(BlockJukeBox.HAS_RECORD, !nms.isEmpty());
|
||||
}
|
||||
@@ -104,7 +93,7 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
|
||||
requirePlaced();
|
||||
|
||||
TileEntity tileEntity = this.getTileEntityFromWorld();
|
||||
return tileEntity instanceof TileEntityJukeBox jukebox && jukebox.isRecordPlaying();
|
||||
return tileEntity instanceof TileEntityJukeBox jukebox && jukebox.getSongPlayer().isPlaying();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,9 +110,7 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
|
||||
return false;
|
||||
}
|
||||
|
||||
jukebox.isPlaying = true;
|
||||
jukebox.recordStartedTick = jukebox.tickCount;
|
||||
getWorld().playEffect(getLocation(), Effect.RECORD_PLAY, CraftItemType.minecraftToBukkit(record.getItem()));
|
||||
jukebox.tryForcePlaySong();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -136,8 +123,7 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
|
||||
return;
|
||||
}
|
||||
|
||||
jukebox.isPlaying = false;
|
||||
getWorld().playEffect(getLocation(), Effect.IRON_DOOR_CLOSE, 0); // TODO: Fix this enum constant. This stops jukeboxes
|
||||
jukebox.getSongPlayer().stop(tileEntity.getLevel(), tileEntity.getBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,7 +135,7 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
|
||||
|
||||
TileEntityJukeBox jukebox = (TileEntityJukeBox) tileEntity;
|
||||
boolean result = !jukebox.getTheItem().isEmpty();
|
||||
jukebox.popOutRecord();
|
||||
jukebox.popOutTheItem();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user