本文整理汇总了Java中net.minecraft.client.audio.MusicTicker.playMusic方法的典型用法代码示例。如果您正苦于以下问题:Java MusicTicker.playMusic方法的具体用法?Java MusicTicker.playMusic怎么用?Java MusicTicker.playMusic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.client.audio.MusicTicker
的用法示例。
在下文中一共展示了MusicTicker.playMusic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateScreen
import net.minecraft.client.audio.MusicTicker; //导入方法依赖的package包/类
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
MusicTicker musicticker = this.mc.getMusicTicker();
SoundHandler soundhandler = this.mc.getSoundHandler();
if (this.time == 0)
{
musicticker.stopMusic();
musicticker.playMusic(MusicTicker.MusicType.CREDITS);
soundhandler.resumeSounds();
}
soundhandler.update();
++this.time;
float f = (float)(this.totalScrollLength + this.height + this.height + 24) / 0.5F;
if ((float)this.time > f)
{
this.sendRespawnPacket();
}
}
示例2: execute
import net.minecraft.client.audio.MusicTicker; //导入方法依赖的package包/类
@Override
public String execute(CommandSender sender, String[] params) throws CommandException {
if (params.length > 0) {
if (params[0].equalsIgnoreCase("play")) {
if (!this.stopSound)
throw new CommandException("command.music.isplaying", sender);
this.stopSound = false;
Minecraft.getMinecraft().getMusicTicker().playMusic(Minecraft.getMinecraft().getAmbientMusicType());
sender.sendLangfileMessage("command.music.played");
}
else if (params[0].equalsIgnoreCase("next") || params[0].equalsIgnoreCase("skip")) {
MusicTicker musicTicker = Minecraft.getMinecraft().getMusicTicker();
stopMusic();
musicTicker.playMusic(Minecraft.getMinecraft().getAmbientMusicType());
this.stopSound = false;
sender.sendLangfileMessage("command.music.skipped");
}
else if (params[0].equalsIgnoreCase("stop")) {
stopMusic();
this.stopSound = true;
sender.sendLangfileMessage("command.music.stopped");
}
else if (params[0].equalsIgnoreCase("volume") && params.length > 1) {
try {
int volume = Integer.parseInt(params[1]);
if (volume < 0) volume = 0;
if (volume > 100) volume = 100;
Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.MUSIC, volume / 100.0F);
Minecraft.getMinecraft().getSoundHandler().setSoundLevel(SoundCategory.MUSIC, volume / 100.0F);
sender.sendLangfileMessage("command.music.volumeset");
}
catch (NumberFormatException nfe) {throw new CommandException("command.music.invalidArg", sender);}
}
else throw new CommandException("command.music.invalidUsage", sender);
}
return null;
}