diff --git a/src/main/java/electroblob/wizardry/CommonProxy.java b/src/main/java/electroblob/wizardry/CommonProxy.java index a3d959b0..cf738200 100644 --- a/src/main/java/electroblob/wizardry/CommonProxy.java +++ b/src/main/java/electroblob/wizardry/CommonProxy.java @@ -197,6 +197,12 @@ public class CommonProxy { */ public void playMovingSound(Entity entity, SoundEvent sound, SoundCategory category, float volume, float pitch, boolean repeat){} + /** + * Plays the spell charge-up sound at the given entity. + * @param entity The source of the sound + */ + public void playChargeupSound(EntityLivingBase entity){} + /** * Plays a continuous spell sound which moves with the given entity. * diff --git a/src/main/java/electroblob/wizardry/client/ClientProxy.java b/src/main/java/electroblob/wizardry/client/ClientProxy.java index 68873c5c..0bf1c625 100644 --- a/src/main/java/electroblob/wizardry/client/ClientProxy.java +++ b/src/main/java/electroblob/wizardry/client/ClientProxy.java @@ -6,6 +6,7 @@ import electroblob.wizardry.block.BlockBookshelf; import electroblob.wizardry.client.animation.ActionAnimation; import electroblob.wizardry.client.animation.PlayerAnimator; import electroblob.wizardry.client.audio.MovingSoundEntity; +import electroblob.wizardry.client.audio.MovingSoundSpellCharge; import electroblob.wizardry.client.audio.SoundLoop; import electroblob.wizardry.client.audio.SoundLoopSpell; import electroblob.wizardry.client.gui.GuiLectern; @@ -200,25 +201,6 @@ public class ClientProxy extends CommonProxy { return entity == Minecraft.getMinecraft().getRenderViewEntity() && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0; } - @Override - public void playMovingSound(Entity entity, SoundEvent sound, SoundCategory category, float volume, float pitch, boolean repeat){ - Minecraft.getMinecraft().getSoundHandler().playSound(new MovingSoundEntity<>(entity, sound, category, volume, pitch, repeat)); - } - - @Override - public void playSpellSoundLoop(EntityLivingBase entity, Spell spell, SoundEvent start, SoundEvent loop, SoundEvent end, SoundCategory category, float volume, float pitch){ - SoundLoop.addLoop(new SoundLoopSpell.SoundLoopSpellEntity(start, loop, end, spell, entity, volume, pitch)); - } - - @Override - public void playSpellSoundLoop(World world, double x, double y, double z, Spell spell, SoundEvent start, SoundEvent loop, SoundEvent end, SoundCategory category, float volume, float pitch, int duration){ - if(duration == -1){ - SoundLoop.addLoop(new SoundLoopSpell.SoundLoopSpellDispenser(start, loop, end, spell, world, x, y, z, volume, pitch)); - }else{ - SoundLoop.addLoop(new SoundLoopSpell.SoundLoopSpellPosTimed(start, loop, end, spell, duration, x, y, z, volume, pitch)); - } - } - @Override public void playBlinkEffect(EntityPlayer player){ if(Minecraft.getMinecraft().player == player) RenderBlinkEffect.playBlinkEffect(); @@ -255,6 +237,33 @@ public class ClientProxy extends CommonProxy { } } + // Sound + // =============================================================================================================== + + @Override + public void playMovingSound(Entity entity, SoundEvent sound, SoundCategory category, float volume, float pitch, boolean repeat){ + Minecraft.getMinecraft().getSoundHandler().playSound(new MovingSoundEntity<>(entity, sound, category, volume, pitch, repeat)); + } + + @Override + public void playChargeupSound(EntityLivingBase entity){ + Minecraft.getMinecraft().getSoundHandler().playSound(new MovingSoundSpellCharge(entity, WizardrySounds.ITEM_WAND_CHARGEUP, WizardrySounds.SPELLS, 1.7f, 1.4f, false)); + } + + @Override + public void playSpellSoundLoop(EntityLivingBase entity, Spell spell, SoundEvent start, SoundEvent loop, SoundEvent end, SoundCategory category, float volume, float pitch){ + SoundLoop.addLoop(new SoundLoopSpell.SoundLoopSpellEntity(start, loop, end, spell, entity, volume, pitch)); + } + + @Override + public void playSpellSoundLoop(World world, double x, double y, double z, Spell spell, SoundEvent start, SoundEvent loop, SoundEvent end, SoundCategory category, float volume, float pitch, int duration){ + if(duration == -1){ + SoundLoop.addLoop(new SoundLoopSpell.SoundLoopSpellDispenser(start, loop, end, spell, world, x, y, z, volume, pitch)); + }else{ + SoundLoop.addLoop(new SoundLoopSpell.SoundLoopSpellPosTimed(start, loop, end, spell, duration, x, y, z, volume, pitch)); + } + } + // Items // =============================================================================================================== diff --git a/src/main/java/electroblob/wizardry/client/audio/MovingSoundSpellCharge.java b/src/main/java/electroblob/wizardry/client/audio/MovingSoundSpellCharge.java new file mode 100644 index 00000000..0384127d --- /dev/null +++ b/src/main/java/electroblob/wizardry/client/audio/MovingSoundSpellCharge.java @@ -0,0 +1,36 @@ +package electroblob.wizardry.client.audio; + +import electroblob.wizardry.item.ISpellCastingItem; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvent; + +/** A special type of moving sound that stops when the player stops charging up a spell, either by releasing the mouse + * button or when the charge-up time has elapsed. */ +public class MovingSoundSpellCharge extends MovingSoundEntity { + + public MovingSoundSpellCharge(EntityLivingBase entity, SoundEvent sound, SoundCategory category, float volume, float pitch, boolean repeat){ + super(entity, sound, category, volume, pitch, repeat); + } + + @Override + public void update(){ + + if(source.isHandActive()){ + + ItemStack stack = source.getActiveItemStack(); + + if(stack.getItem() instanceof ISpellCastingItem){ + + if(source.getItemInUseMaxCount() < ((ISpellCastingItem)stack.getItem()).getCurrentSpell(stack).getChargeup()){ + super.update(); + return; + } + } + } + + this.donePlaying = true; + } + +} diff --git a/src/main/java/electroblob/wizardry/item/ItemWand.java b/src/main/java/electroblob/wizardry/item/ItemWand.java index 5c9b4c92..a09a8300 100644 --- a/src/main/java/electroblob/wizardry/item/ItemWand.java +++ b/src/main/java/electroblob/wizardry/item/ItemWand.java @@ -364,6 +364,7 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem, player.setActiveHand(hand); // Store the modifiers for use later if(WizardData.get(player) != null) WizardData.get(player).itemCastingModifiers = modifiers; + if(chargeup > 0 && world.isRemote) Wizardry.proxy.playChargeupSound(player); return new ActionResult<>(EnumActionResult.SUCCESS, stack); } }else{ diff --git a/src/main/java/electroblob/wizardry/registry/WizardrySounds.java b/src/main/java/electroblob/wizardry/registry/WizardrySounds.java index 5cee59dd..a6d20fb6 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardrySounds.java +++ b/src/main/java/electroblob/wizardry/registry/WizardrySounds.java @@ -34,6 +34,7 @@ public final class WizardrySounds { public static final SoundEvent ITEM_WAND_SWITCH_SPELL = createSound("item.wand.switch_spell"); public static final SoundEvent ITEM_WAND_LEVELUP = createSound("item.wand.levelup"); public static final SoundEvent ITEM_WAND_MELEE = createSound("item.wand.melee"); + public static final SoundEvent ITEM_WAND_CHARGEUP = createSound("item.wand.chargeup"); public static final SoundEvent ITEM_ARMOUR_EQUIP_SILK = createSound("item.armour.equip_silk"); public static final SoundEvent ITEM_PURIFYING_ELIXIR_DRINK = createSound("item.purifying_elixir.drink"); public static final SoundEvent ITEM_MANA_FLASK_USE = createSound("item.mana_flask.use"); @@ -172,6 +173,7 @@ public final class WizardrySounds { event.getRegistry().register(ITEM_WAND_SWITCH_SPELL); event.getRegistry().register(ITEM_WAND_LEVELUP); event.getRegistry().register(ITEM_WAND_MELEE); + event.getRegistry().register(ITEM_WAND_CHARGEUP); event.getRegistry().register(ITEM_ARMOUR_EQUIP_SILK); event.getRegistry().register(ITEM_PURIFYING_ELIXIR_DRINK); event.getRegistry().register(ITEM_MANA_FLASK_USE); diff --git a/src/main/resources/assets/ebwizardry/sounds.json b/src/main/resources/assets/ebwizardry/sounds.json index afc1798f..f6224f68 100644 --- a/src/main/resources/assets/ebwizardry/sounds.json +++ b/src/main/resources/assets/ebwizardry/sounds.json @@ -8,6 +8,7 @@ "item.wand.switch_spell": {"category": "player", "sounds": ["ebwizardry:select"]}, "item.wand.levelup": {"category": "player", "sounds": ["random/levelup"]}, "item.wand.melee": {"category": "player", "sounds": ["ebwizardry:effect1", "ebwizardry:effect2"]}, + "item.wand.chargeup": {"category": "player", "sounds": ["ebwizardry:chargeup"]}, "item.armour.equip_silk": {"category": "player", "sounds": ["item/armor/equip_leather1", "item/armor/equip_leather2", "item/armor/equip_leather3", "item/armor/equip_leather4", "item/armor/equip_leather5", "item/armor/equip_leather6"]}, "item.purifying_elixir.drink": {"category": "player", "sounds": ["ebwizardry:buff_large"]}, "item.mana_flask.use": {"category": "player", "sounds": ["item/bottle/fill1", "item/bottle/fill2", "item/bottle/fill3", "item/bottle/fill4"]}, diff --git a/src/main/resources/assets/ebwizardry/sounds/chargeup.ogg b/src/main/resources/assets/ebwizardry/sounds/chargeup.ogg new file mode 100644 index 00000000..2ecb1a9a Binary files /dev/null and b/src/main/resources/assets/ebwizardry/sounds/chargeup.ogg differ