PlayLocation enum

Пакет: com.hypixel.hytale.builtin.triggervolumes.effect.builtin

Файл: com/hypixel/hytale/builtin/triggervolumes/effect/builtin/PlaySoundEffect.java

Поля (1)

МодификаторыТипИмя
private final EffectOrigin origin

Методы (1)

МодификаторыВозвратСигнатура
abstract PLAYER PLAYER(null)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.triggervolumes.effect.builtin;

class="kw">import com.hypixel.hytale.builtin.triggervolumes.YawRotation;
class="kw">import com.hypixel.hytale.builtin.triggervolumes.effect.EffectOrigin;
class="kw">import com.hypixel.hytale.builtin.triggervolumes.effect.TriggerContext;
class="kw">import com.hypixel.hytale.builtin.triggervolumes.effect.TriggerEffect;
class="kw">import com.hypixel.hytale.builtin.triggervolumes.effect.TriggerEventType;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.codecs.EnumCodec;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.math.vector.Vector3dUtil;
class="kw">import com.hypixel.hytale.protocol.SoundCategory;
class="kw">import com.hypixel.hytale.server.core.asset.type.soundevent.config.SoundEvent;
class="kw">import com.hypixel.hytale.server.core.universe.world.SoundUtil;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;

class="kw">public class PlaySoundEffect class="kw">extends TriggerEffect {
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<PlaySoundEffect> CODEC = BuilderCodec.builder(PlaySoundEffect.class, PlaySoundEffect::new, BASE_CODEC)
      .append(new KeyedCodec<>("SoundEvent", Codec.STRING), (var0, var1) -> var0.soundEventId = var1, var0 -> var0.soundEventId)
      .add()
      .append(new KeyedCodec<>("Volume", Codec.FLOAT, false), (var0, var1) -> var0.volumeModifier = var1, var0 -> var0.volumeModifier)
      .add()
      .append(new KeyedCodec<>("Pitch", Codec.FLOAT, false), (var0, var1) -> var0.pitchModifier = var1, var0 -> var0.pitchModifier)
      .add()
      .append(
         new KeyedCodec<>("Location", new EnumCodec<>(PlaySoundEffect.PlayLocation.class), false), (var0, var1) -> var0.location = var1, var0 -> var0.location
      )
      .add()
      .append(new KeyedCodec<>("Offset", Vector3dUtil.CODEC, false), (var0, var1) -> var0.offset = var1, var0 -> var0.offset)
      .add()
      .build();
   class="kw">private String soundEventId;
   class="kw">private float volumeModifier = 1.0F;
   class="kw">private float pitchModifier = 1.0F;
   @Nonnull
   class="kw">private PlaySoundEffect.PlayLocation location = PlaySoundEffect.PlayLocation.VOLUME_CENTER;
   @Nonnull
   class="kw">private Vector3d offset = new Vector3d();

   class="kw">public PlaySoundEffect() {
   }

   @Nonnull
   class="kw">public class="kw">static PlaySoundEffect create(@Nonnull TriggerEventType var0, @Nonnull String var1) {
      PlaySoundEffect var2 = new PlaySoundEffect();
      var2.setEventType(var0);
      var2.soundEventId = var1;
      class="kw">return var2;
   }

   @Override
   class="kw">public void execute(@Nonnull TriggerContext var1) {
      if (this.soundEventId != null) {
         int var2 = SoundEvent.getAssetMap().getIndex(this.soundEventId);
         if (var2 != Integer.MIN_VALUE && var2 != 0) {
            Store var3 = var1.getStore();
            if (this.location.origin == null) {
               SoundUtil.playSoundEvent2d(var1.getEntityRef(), var2, SoundCategory.SFX, this.volumeModifier, this.pitchModifier, var3);
            } else {
               Vector3d var4 = var1.resolveOrigin(this.location.origin, this.offset, TriggerContext.MissingActor.SKIP);
               if (var4 != null) {
                  SoundUtil.playSoundEvent3d(var2, SoundCategory.SFX, var4.x(), var4.y(), var4.z(), this.volumeModifier, this.pitchModifier, var3);
               }
            }
         }
      }
   }

   @Override
   class="kw">public void rotateInPlace(float var1, @Nonnull Vector3d var2) {
      if (this.location == PlaySoundEffect.PlayLocation.VOLUME_CENTER && this.offset != null) {
         YawRotation.rotate(this.offset, var1);
      }
   }

   class="kw">public enum PlayLocation {
      VOLUME_CENTER(EffectOrigin.VOLUME_ORIGIN),
      ENTITY(EffectOrigin.ENTITY),
      EVENT(EffectOrigin.EVENT),
      PLAYER(null);

      @Nullable
      class="kw">private class="kw">final EffectOrigin origin;

      PlayLocation(@Nullable EffectOrigin nullxx) {
         this.origin = nullxx;
      }
   }
}