SoundEventLayer class

Пакет: com.hypixel.hytale.server.core.asset.type.soundevent.config

Файл: com/hypixel/hytale/server/core/asset/type/soundevent/config/SoundEventLayer.java

implements: NetworkSerializable<com.hypixel.hytale.protocol.SoundEventLayer>

Поля (9)

МодификаторыТипИмя
final Codec<SoundEventLayer> CODEC
public static final Codec<SoundEventLayer.RandomSettings> CODEC
public static final SoundEventLayer.RandomSettings DEFAULT
protected transient float maxPitch
protected float maxStartOffset
protected transient float maxVolume
protected transient float minPitch
protected transient float minVolume
com.hypixel.hytale.protocol.SoundEventLayer var1

Методы (20)

МодификаторыВозвратСигнатура
public RandomSettingspublic RandomSettings()
for for(String var4 : var0.files)
public float getFadeInfloat getFadeIn()
public String[] getFilesString[] getFiles()
public int getHighestNumberOfChannelsint getHighestNumberOfChannels()
public float getMaxPitchpublic float getMaxPitch()
public float getMaxStartOffsetpublic float getMaxStartOffset()
public float getMaxVolumepublic float getMaxVolume()
public float getMinPitchpublic float getMinPitch()
public float getMinVolumepublic float getMinVolume()
public int getProbabilityint getProbability()
public float getProbabilityRerollDelayfloat getProbabilityRerollDelay()
public SoundEventLayer.RandomSettings getRandomSettingsSoundEventLayer.RandomSettings getRandomSettings()
public int getRoundRobinHistorySizeint getRoundRobinHistorySize()
public float getStartDelayfloat getStartDelay()
public float getVolumefloat getVolume()
if if(var0.files != null)
if if(var5 != null && var5.channels > var0.highestNumberOfChannels)
public boolean isLoopingboolean isLooping()
public String toStringpublic String toString()

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.asset.type.soundevent.config;

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.schema.metadata.ui.UIEditor;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.codec.validation.validator.ArrayValidator;
class="kw">import com.hypixel.hytale.common.util.AudioUtil;
class="kw">import com.hypixel.hytale.protocol.SoundEventLayerRandomSettings;
class="kw">import com.hypixel.hytale.server.core.asset.common.CommonAssetValidator;
class="kw">import com.hypixel.hytale.server.core.asset.common.OggVorbisInfoCache;
class="kw">import com.hypixel.hytale.server.core.io.NetworkSerializable;
class="kw">import java.util.Arrays;
class="kw">import javax.annotation.Nonnull;

class="kw">public class SoundEventLayer class="kw">implements NetworkSerializable<com.hypixel.hytale.protocol.SoundEventLayer> {
   class="kw">public class="kw">static class="kw">final Codec<SoundEventLayer> CODEC = BuilderCodec.builder(SoundEventLayer.class, SoundEventLayer::new)
      .append(
         new KeyedCodec<>("Volume", Codec.FLOAT),
         (var0, var1) -> var0.volume = AudioUtil.decibelsToLinearGain(var1),
         var0 -> AudioUtil.linearGainToDecibels(var0.volume)
      )
      .metadata(new UIEditor(new UIEditor.FormattedNumber(null, " dB", null)))
      .addValidator(Validators.range(-100.0F, 10.0F))
      .documentation("Volume offset for this layer in decibels.")
      .add()
      .<Float>append(new KeyedCodec<>("StartDelay", Codec.FLOAT), (var0, var1) -> var0.startDelay = var1, var0 -> var0.startDelay)
      .documentation("A delay in seconds from when the sound event starts after which this layer should begin.")
      .add()
      .<Float>append(new KeyedCodec<>("FadeIn", Codec.FLOAT), (var0, var1) -> var0.fadeIn = var1, var0 -> var0.fadeIn)
      .addValidator(Validators.range(0.0F, Float.MAX_VALUE))
      .documentation("A fade-in duration in seconds over which this layer ramps from silence to full volume once it begins (after any StartDelay).")
      .add()
      .<Boolean>append(new KeyedCodec<>("Looping", Codec.BOOLEAN), (var0, var1) -> var0.looping = var1, var0 -> var0.looping)
      .documentation("Whether this layer loops.")
      .add()
      .<Integer>append(new KeyedCodec<>("Probability", Codec.INTEGER), (var0, var1) -> var0.probability = var1, var0 -> var0.probability)
      .documentation("The probability of this layer being played when the sound event is triggered in percentage.")
      .add()
      .<Float>append(
         new KeyedCodec<>("ProbabilityRerollDelay", Codec.FLOAT), (var0, var1) -> var0.probabilityRerollDelay = var1, var0 -> var0.probabilityRerollDelay
      )
      .documentation("A delay in seconds before the probability of this layer playing can be rerolled to see if it will now play (or not play) again.")
      .add()
      .<SoundEventLayer.RandomSettings>append(
         new KeyedCodec<>("RandomSettings", SoundEventLayer.RandomSettings.CODEC), (var0, var1) -> var0.randomSettings = var1, var0 -> var0.randomSettings
      )
      .documentation("Randomization settings for parameters of this layer.")
      .add()
      .<String[]>append(new KeyedCodec<>("Files", Codec.STRING_ARRAY), (var0, var1) -> var0.files = var1, var0 -> var0.files)
      .addValidator(Validators.nonEmptyArray())
      .addValidator(new ArrayValidator<>(CommonAssetValidator.SOUNDS))
      .documentation("The list of possible sound files for this layer. One will be chosen at random.")
      .add()
      .<Integer>append(
         new KeyedCodec<>("RoundRobinHistorySize", Codec.INTEGER), (var0, var1) -> var0.roundRobinHistorySize = var1, var0 -> var0.roundRobinHistorySize
      )
      .addValidator(Validators.range(0, 32))
      .documentation("The same sound file will not repeat within this many plays. 0 disables round-robin behavior.")
      .add()
      .afterDecode(var0 -> {
         if (var0.files != null) {
            for (String var4 : var0.files) {
               OggVorbisInfoCache.OggVorbisInfo var5 = OggVorbisInfoCache.getNow(var4);
               if (var5 != null && var5.channels > var0.highestNumberOfChannels) {
                  var0.highestNumberOfChannels = var5.channels;
               }
            }
         }
      })
      .build();
   class="kw">protected class="kw">transient float volume = 1.0F;
   class="kw">protected float startDelay = 0.0F;
   class="kw">protected float fadeIn;
   class="kw">protected boolean looping = false;
   class="kw">protected int probability = 100;
   class="kw">protected float probabilityRerollDelay = 1.0F;
   class="kw">protected SoundEventLayer.RandomSettings randomSettings = SoundEventLayer.RandomSettings.DEFAULT;
   class="kw">protected String[] files;
   class="kw">protected int roundRobinHistorySize = 0;
   class="kw">protected class="kw">transient int highestNumberOfChannels = 0;

   class="kw">public SoundEventLayer(float var1, float var2, float var3, boolean var4, int var5, float var6, SoundEventLayer.RandomSettings var7, String[] var8, int var9) {
      this.volume = var1;
      this.startDelay = var2;
      this.fadeIn = var3;
      this.looping = var4;
      this.probability = var5;
      this.probabilityRerollDelay = var6;
      this.randomSettings = var7;
      this.files = var8;
      this.roundRobinHistorySize = var9;
   }

   class="kw">protected SoundEventLayer() {
   }

   class="kw">public float getVolume() {
      class="kw">return this.volume;
   }

   class="kw">public float getStartDelay() {
      class="kw">return this.startDelay;
   }

   class="kw">public float getFadeIn() {
      class="kw">return this.fadeIn;
   }

   class="kw">public boolean isLooping() {
      class="kw">return this.looping;
   }

   class="kw">public int getProbability() {
      class="kw">return this.probability;
   }

   class="kw">public float getProbabilityRerollDelay() {
      class="kw">return this.probabilityRerollDelay;
   }

   class="kw">public SoundEventLayer.RandomSettings getRandomSettings() {
      class="kw">return this.randomSettings;
   }

   class="kw">public String[] getFiles() {
      class="kw">return this.files;
   }

   class="kw">public int getRoundRobinHistorySize() {
      class="kw">return this.roundRobinHistorySize;
   }

   class="kw">public int getHighestNumberOfChannels() {
      class="kw">return this.highestNumberOfChannels;
   }

   @Nonnull
   class="kw">public com.hypixel.hytale.protocol.SoundEventLayer toPacket() {
      com.hypixel.hytale.protocol.SoundEventLayer var1 = new com.hypixel.hytale.protocol.SoundEventLayer();
      var1.volume = this.volume;
      var1.startDelay = this.startDelay;
      var1.fadeIn = this.fadeIn;
      var1.looping = this.looping;
      var1.probability = this.probability;
      var1.probabilityRerollDelay = this.probabilityRerollDelay;
      var1.randomSettings = new SoundEventLayerRandomSettings();
      var1.randomSettings.minVolume = this.randomSettings.minVolume;
      var1.randomSettings.maxVolume = this.randomSettings.maxVolume;
      var1.randomSettings.minPitch = this.randomSettings.minPitch;
      var1.randomSettings.maxPitch = this.randomSettings.maxPitch;
      var1.randomSettings.maxStartOffset = this.randomSettings.maxStartOffset;
      var1.files = this.files;
      var1.roundRobinHistorySize = this.roundRobinHistorySize;
      class="kw">return var1;
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "SoundEventLayer{volume="
         + this.volume
         + ", startDelay="
         + this.startDelay
         + ", fadeIn="
         + this.fadeIn
         + ", looping="
         + this.looping
         + ", probability="
         + this.probability
         + ", probabilityRerollDelay="
         + this.probabilityRerollDelay
         + ", randomSettings="
         + this.randomSettings
         + ", files="
         + Arrays.toString(this.files)
         + ", roundRobinHistorySize="
         + this.roundRobinHistorySize
         + ", highestNumberOfChannels="
         + this.highestNumberOfChannels
         + "}";
   }

   class="kw">public class="kw">static class RandomSettings {
      class="kw">public class="kw">static class="kw">final Codec<SoundEventLayer.RandomSettings> CODEC = BuilderCodec.builder(
            SoundEventLayer.RandomSettings.class, SoundEventLayer.RandomSettings::new
         )
         .append(
            new KeyedCodec<>("MinVolume", Codec.FLOAT),
            (var0, var1) -> var0.minVolume = AudioUtil.decibelsToLinearGain(var1),
            var0 -> AudioUtil.linearGainToDecibels(var0.minVolume)
         )
         .addValidator(Validators.range(-100.0F, 0.0F))
         .documentation("Minimum additional random volume offset in decibels.")
         .add()
         .<Float>append(
            new KeyedCodec<>("MaxVolume", Codec.FLOAT),
            (var0, var1) -> var0.maxVolume = AudioUtil.decibelsToLinearGain(var1),
            var0 -> AudioUtil.linearGainToDecibels(var0.maxVolume)
         )
         .addValidator(Validators.range(0.0F, 10.0F))
         .documentation("Maximum additional random volume offset in decibels.")
         .add()
         .<Float>append(
            new KeyedCodec<>("MinPitch", Codec.FLOAT),
            (var0, var1) -> var0.minPitch = AudioUtil.semitonesToLinearPitch(var1),
            var0 -> AudioUtil.linearPitchToSemitones(var0.minPitch)
         )
         .addValidator(Validators.range(-12.0F, 0.0F))
         .documentation("Minimum additional random pitch offset in semitones.")
         .add()
         .<Float>append(
            new KeyedCodec<>("MaxPitch", Codec.FLOAT),
            (var0, var1) -> var0.maxPitch = AudioUtil.semitonesToLinearPitch(var1),
            var0 -> AudioUtil.linearPitchToSemitones(var0.maxPitch)
         )
         .addValidator(Validators.range(0.0F, 12.0F))
         .documentation("Maximum additional random pitch offset in semitones.")
         .add()
         .<Float>append(new KeyedCodec<>("MaxStartOffset", Codec.FLOAT), (var0, var1) -> var0.maxStartOffset = var1, var0 -> var0.maxStartOffset)
         .addValidator(Validators.range(0.0F, Float.MAX_VALUE))
         .documentation(
            "Maximum amount by which to offset the start of this sound event (e.g. start up to x seconds into the sound). This should only really be used for looping sounds to prevent phasing issues."
         )
         .add()
         .build();
      class="kw">public class="kw">static class="kw">final SoundEventLayer.RandomSettings DEFAULT = new SoundEventLayer.RandomSettings();
      class="kw">protected class="kw">transient float minVolume = 1.0F;
      class="kw">protected class="kw">transient float maxVolume = 1.0F;
      class="kw">protected class="kw">transient float minPitch = 1.0F;
      class="kw">protected class="kw">transient float maxPitch = 1.0F;
      class="kw">protected float maxStartOffset;

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

      class="kw">public float getMinVolume() {
         class="kw">return this.minVolume;
      }

      class="kw">public float getMaxVolume() {
         class="kw">return this.maxVolume;
      }

      class="kw">public float getMinPitch() {
         class="kw">return this.minPitch;
      }

      class="kw">public float getMaxPitch() {
         class="kw">return this.maxPitch;
      }

      class="kw">public float getMaxStartOffset() {
         class="kw">return this.maxStartOffset;
      }

      @Nonnull
      @Override
      class="kw">public String toString() {
         class="kw">return "RandomSettings{minVolume="
            + this.minVolume
            + ", maxVolume="
            + this.maxVolume
            + ", minPitch="
            + this.minPitch
            + ", maxPitch="
            + this.maxPitch
            + ", maxStartOffset="
            + this.maxStartOffset
            + "}";
      }
   }
}