关于声音事件的注册,首先需要根据这个网站在resource文件夹下写sounds.json。https://forge-doc-119x-zh-cn.readthedocs.io/zh-cn/latest/gameeffects/sounds/
不能使用DeferredRegister注册声音事件,要用SoundEvent.createVariableRangeEvent方法注册
1 | private static SoundEvent makeSoundEvent(String name) { |
使用这个方法进行注册音乐事件的注册
1 | public static final List<SoundEvent> EVENTS = new ArrayList<>(); |
然后遍历整个列表注册
1 | public static void init(BiConsumer<SoundEvent, ResourceLocation> r) { |
最后把这个注册放进主线中
1 | bind(eventBus,Registries.SOUND_EVENT,SoundRegistry::init); |