Add a sound to the beam

This commit is contained in:
Sollace 2022-01-11 20:42:50 +02:00
parent 1cfc01d1e6
commit bf413d36c0
5 changed files with 24 additions and 2 deletions

View file

@ -20,6 +20,7 @@ public class InteractionManager {
public static final int SOUND_BEE = 2;
public static final int SOUND_MINECART = 3;
public static final int SOUND_GLIDING = 4;
public static final int SOUND_MAGIC_BEAM = 5;
public static final int SCREEN_DISPELL_ABILITY = 0;

View file

@ -7,6 +7,7 @@ import com.minelittlepony.unicopia.FlightType;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.client.gui.DismissSpellScreen;
import com.minelittlepony.unicopia.client.sound.LoopedEntityTrackingSoundInstance;
import com.minelittlepony.unicopia.client.sound.LoopingSoundInstance;
import com.minelittlepony.unicopia.client.sound.MotionBasedSoundInstance;
import com.minelittlepony.unicopia.entity.effect.UEffects;
@ -54,7 +55,7 @@ public class ClientInteractionManager extends InteractionManager {
SoundManager soundManager = client.getSoundManager();
if (type == SOUND_EARS_RINGING && source instanceof LivingEntity) {
soundManager.play(new LoopingSoundInstance<>((LivingEntity)source, e -> e.hasStatusEffect(UEffects.SUN_BLINDNESS), USounds.ENTITY_PLAYER_EARS_RINGING, 1F, 1F));
soundManager.play(new LoopingSoundInstance<>((LivingEntity)source, e -> e.hasStatusEffect(UEffects.SUN_BLINDNESS), USounds.ENTITY_PLAYER_EARS_RINGING, 1, 1));
} else if (type == SOUND_BEE && source instanceof BeeEntity) {
soundManager.playNextTick(
((BeeEntity)source).hasAngerTime()
@ -70,6 +71,8 @@ public class ClientInteractionManager extends InteractionManager {
}, USounds.ENTITY_PLAYER_CHANGELING_BUZZ, 1F, 1F));
} else if (type == SOUND_GLIDING && source instanceof PlayerEntity) {
soundManager.play(new MotionBasedSoundInstance(SoundEvents.ITEM_ELYTRA_FLYING, (PlayerEntity)source));
} else if (type == SOUND_MAGIC_BEAM) {
soundManager.play(new LoopedEntityTrackingSoundInstance(USounds.SPELL_CAST_SHOOT, 0.3F, 1F, source));
}
});
}

View file

@ -0,0 +1,13 @@
package com.minelittlepony.unicopia.client.sound;
import net.minecraft.client.sound.EntityTrackingSoundInstance;
import net.minecraft.entity.Entity;
import net.minecraft.sound.SoundEvent;
public class LoopedEntityTrackingSoundInstance extends EntityTrackingSoundInstance {
public LoopedEntityTrackingSoundInstance(SoundEvent soundEvent, float volume, float pitch, Entity entity) {
super(soundEvent, entity.getSoundCategory(), volume, pitch, entity);
this.repeat = true;
this.repeatDelay = 0;
}
}

View file

@ -29,7 +29,6 @@ public class LoopingSoundInstance<T extends Entity> extends FadeOutSoundInstance
x = source.getX();
y = source.getY();
z = source.getZ();
return true;
}
}

View file

@ -1,11 +1,13 @@
package com.minelittlepony.unicopia.network.handler;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Owned;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
import com.minelittlepony.unicopia.client.ClientBlockDestructionManager;
import com.minelittlepony.unicopia.client.DiscoveryToast;
import com.minelittlepony.unicopia.client.gui.TribeSelectionScreen;
import com.minelittlepony.unicopia.entity.UEntities;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.network.MsgBlockDestruction;
import com.minelittlepony.unicopia.network.MsgCancelPlayerAbility;
@ -44,6 +46,10 @@ public class ClientNetworkHandlerImpl implements ClientNetworkHandler {
((Owned<Entity>) entity).setMaster(world.getEntityById(packet.getEntityData()));
}
if (entity.getType() == UEntities.MAGIC_BEAM) {
InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_MAGIC_BEAM);
}
world.addEntity(packet.getId(), entity);
}