From 76b4f2f72f1ce45d32851d6a92f4feb6347043bc Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Tue, 14 Jan 2020 14:39:09 +0000 Subject: [PATCH] Change default behaviour of Spell#createSoundWithSuffix to point to assets/modid/sounds.json rather than assets/ebwizardry/sounds.json, so addons don't have to override it --- .../electroblob/wizardry/registry/WizardrySounds.java | 11 +++++++++-- src/main/java/electroblob/wizardry/spell/Spell.java | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/electroblob/wizardry/registry/WizardrySounds.java b/src/main/java/electroblob/wizardry/registry/WizardrySounds.java index 8aefe1e9..a0353429 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardrySounds.java +++ b/src/main/java/electroblob/wizardry/registry/WizardrySounds.java @@ -133,10 +133,17 @@ public final class WizardrySounds { public static final SoundEvent MISC_PAGE_TURN = createSound("misc.page_turn"); public static final SoundEvent MISC_FREEZE = createSound("misc.freeze"); - /** Trick borrowed from the Twilight Forest, makes things neater. */ + // Trick borrowed from the Twilight Forest, makes things neater. + + /** Overload for {@link WizardrySounds#createSound(String, String)} which assigns wizardry's mod ID automatically. */ public static SoundEvent createSound(String name){ + return createSound(Wizardry.MODID, name); + } + + /** Creates a sound with the given name, to be read from {@code assets/[modID]/sounds.json}. */ + public static SoundEvent createSound(String modID, String name){ // All the setRegistryName methods delegate to this one, it doesn't matter which you use. - return new SoundEvent(new ResourceLocation(Wizardry.MODID, name)).setRegistryName(name); + return new SoundEvent(new ResourceLocation(modID, name)).setRegistryName(name); } // For some reason, sound events seem to work even when they aren't registered, without even so much as a warning. diff --git a/src/main/java/electroblob/wizardry/spell/Spell.java b/src/main/java/electroblob/wizardry/spell/Spell.java index fb4fd3dd..047680c8 100644 --- a/src/main/java/electroblob/wizardry/spell/Spell.java +++ b/src/main/java/electroblob/wizardry/spell/Spell.java @@ -294,7 +294,7 @@ public abstract class Spell extends IForgeRegistryEntry.Impl implements C * @see Spell#createSoundsWithSuffixes(String[]) */ public final SoundEvent createSoundWithSuffix(String suffix){ - return WizardrySounds.createSound("spell." + this.getRegistryName().getPath() + "." + suffix); + return WizardrySounds.createSound(this.getRegistryName().getNamespace(), "spell." + this.getRegistryName().getPath() + "." + suffix); } /**