我有一个程序来播放声音时,正则表达式是一个无格式的消息匹配
@SubscribeEvent
public void ChatRecieved(ClientChatReceivedEvent event) {
String message = event.message.getUnformattedText();
Matcher m = regex.matcher(message);
if (m.matches()) {
Minecraft.getMinecraft().thePlayer.playSound("BazaarAlert:sound", 1, 1);
}
}
但是,声音不会播放并且
[Client thread/WARN]: Unable to play unknown soundEvent: bazaaralert:sound
发送到控制台。以下是my sounds.json:
{
"sound": {
"category": "ambient",
"sounds": [
{
"name": "sound",
"stream": false
}
]
}
}
以下是我的项目在eclipse中的格式:
1条答案
按热度按时间o8x7eapl1#
尝试使用资源位置:
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("your/resource/here.ogg")));