Add spell charge-up sound
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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
|
||||
// ===============================================================================================================
|
||||
|
||||
|
||||
@@ -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<EntityLivingBase> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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{
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user