Skip to content

Commit

Permalink
feat: make all Flesh Blob sounds resource pack driven
Browse files Browse the repository at this point in the history
  • Loading branch information
Elenterius committed Aug 1, 2023
1 parent 60971a0 commit a7d2cd4
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public void registerSounds() {

addSimpleRedirect(ModSoundEvents.FLESH_BLOB_JUMP, SoundEvents.SLIME_JUMP);
addSimpleRedirect(ModSoundEvents.FLESH_BLOB_HURT, ModSoundEvents.FLESH_BLOCK_BREAK.get(), 0.8f, 0.9f);
addSimpleRedirect(ModSoundEvents.FLESH_BLOB_DEATH, SoundEvents.GENERIC_DEATH);
addSimpleSounds(ModSoundEvents.FLESH_BLOB_AMBIENT, 3, 0.8f, 0.9f);
}

public String translationKey(RegistryObject<SoundEvent> soundHolder) {
Expand All @@ -97,13 +99,21 @@ public ResourceLocation extend(ResourceLocation rl, int variant) {
return new ResourceLocation(rl.getNamespace(), rl.getPath() + variant);
}

protected void addSimpleSounds(RegistryObject<SoundEvent> soundHolder, int variants) {
SoundDefinition soundDefinition = definition().subtitle(translationKey(soundHolder));
for (int i = 1; i <= variants; i++) {
soundDefinition.with(SoundDefinitionsProvider.sound(extend(soundHolder.getId(), i)));
}
add(soundHolder, soundDefinition);
}
protected void addSimpleSounds(RegistryObject<SoundEvent> soundHolder, int variants) {
SoundDefinition soundDefinition = definition().subtitle(translationKey(soundHolder));
for (int i = 1; i <= variants; i++) {
soundDefinition.with(SoundDefinitionsProvider.sound(extend(soundHolder.getId(), i)));
}
add(soundHolder, soundDefinition);
}

protected void addSimpleSounds(RegistryObject<SoundEvent> soundHolder, int variants, float volume, float pitch) {
SoundDefinition soundDefinition = definition().subtitle(translationKey(soundHolder));
for (int i = 1; i <= variants; i++) {
soundDefinition.with(SoundDefinitionsProvider.sound(extend(soundHolder.getId(), i)).volume(volume).pitch(pitch));
}
add(soundHolder, soundDefinition);
}

protected void addSimpleSounds(RegistryObject<SoundEvent> soundHolder, String... suffixes) {
SoundDefinition soundDefinition = definition().subtitle(translationKey(soundHolder));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,18 @@ protected SoundEvent getHurtSound(DamageSource damageSource) {
return ModSoundEvents.FLESH_BLOB_HURT.get();
}

@Nullable
@Override
protected SoundEvent getDeathSound() {
return ModSoundEvents.FLESH_BLOB_DEATH.get();
}

@Nullable
@Override
protected SoundEvent getAmbientSound() {
return ModSoundEvents.FLESH_BLOB_AMBIENT.get();
}

@Override
public boolean canSpawnSprintParticle() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public final class ModSoundEvents {
//# Mobs
public static final RegistryObject<SoundEvent> FLESH_BLOB_JUMP = registerSoundEvent("entity.flesh_blob.jump");
public static final RegistryObject<SoundEvent> FLESH_BLOB_HURT = registerSoundEvent("entity.flesh_blob.hurt");
public static final RegistryObject<SoundEvent> FLESH_BLOB_DEATH = registerSoundEvent("entity.flesh_blob.death");
public static final RegistryObject<SoundEvent> FLESH_BLOB_AMBIENT = registerSoundEvent("entity.flesh_blob.ambient");

private ModSoundEvents() {}

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit a7d2cd4

Please sign in to comment.