MusicPlayerBlock class

Пакет: com.hypixel.hytale.builtin.audio.components

Файл: com/hypixel/hytale/builtin/audio/components/MusicPlayerBlock.java

implements: Component<ChunkStore>

Поля (1)

МодификаторыТипИмя
final BuilderCodec<MusicPlayerBlock> CODEC

Методы (10)

МодификаторыВозвратСигнатура
static ComponentType<ChunkStore, MusicPlayerBlock> getComponentTypeComponentType<ChunkStore, MusicPlayerBlock> getComponentType()
public int getInsertSoundIndexint getInsertSoundIndex()
public int getRemoveSoundIndexint getRemoveSoundIndex()
public float getStartDelaySecondsfloat getStartDelaySeconds()
public float getStopDelaySecondsfloat getStopDelaySeconds()
static int normalizeIndexint normalizeIndex(int var0)
private void resolveIndexesvoid resolveIndexes()
public void setObservedItemIdvoid setObservedItemId(@Nullable String var1)
public void setPendingRemoveSoundDeadlinevoid setPendingRemoveSoundDeadline(@Nullable Instant var1)
public void setPendingStartDeadlinevoid setPendingStartDeadline(@Nullable Instant var1)

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.audio.AudioPlugin;
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.validation.Validators;
class="kw">import com.hypixel.hytale.common.util.AudioUtil;
class="kw">import com.hypixel.hytale.component.Component;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.server.core.asset.type.item.config.ItemMusic;
class="kw">import com.hypixel.hytale.server.core.asset.type.soundevent.config.SoundEvent;
class="kw">import com.hypixel.hytale.server.core.asset.type.soundevent.validator.SoundEventValidators;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
class="kw">import java.time.Instant;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class MusicPlayerBlock class="kw">implements Component<ChunkStore> {
   class="kw">public class="kw">static class="kw">final BuilderCodec<MusicPlayerBlock> CODEC = BuilderCodec.builder(MusicPlayerBlock.class, MusicPlayerBlock::new)
      .appendInherited(
         new KeyedCodec<>("InsertSound", Codec.STRING),
         (var0, var1) -> var0.insertSoundId = var1,
         var0 -> var0.insertSoundId,
         (var0, var1) -> var0.insertSoundId = var1.insertSoundId
      )
      .addValidator(SoundEvent.VALIDATOR_CACHE.getValidator())
      .addValidator(SoundEventValidators.MONO)
      .addValidator(SoundEventValidators.ONESHOT)
      .documentation("SoundEvent played at the block when a music item is inserted, before the start delay.")
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("RemoveSound", Codec.STRING),
         (var0, var1) -> var0.removeSoundId = var1,
         var0 -> var0.removeSoundId,
         (var0, var1) -> var0.removeSoundId = var1.removeSoundId
      )
      .addValidator(SoundEvent.VALIDATOR_CACHE.getValidator())
      .addValidator(SoundEventValidators.MONO)
      .addValidator(SoundEventValidators.ONESHOT)
      .documentation("SoundEvent played at the block after a music item is removed and the track has stopped, after the stop delay.")
      .add()
      .<Float>appendInherited(
         new KeyedCodec<>("StartDelaySeconds", Codec.FLOAT),
         (var0, var1) -> var0.startDelaySeconds = var1,
         var0 -> var0.startDelaySeconds,
         (var0, var1) -> var0.startDelaySeconds = var1.startDelaySeconds
      )
      .addValidator(Validators.min(0.0F))
      .documentation("Seconds between the insert sound and the track starting.")
      .add()
      .<Float>appendInherited(
         new KeyedCodec<>("StopDelaySeconds", Codec.FLOAT),
         (var0, var1) -> var0.stopDelaySeconds = var1,
         var0 -> var0.stopDelaySeconds,
         (var0, var1) -> var0.stopDelaySeconds = var1.stopDelaySeconds
      )
      .addValidator(Validators.min(0.0F))
      .documentation("Seconds between the track stopping on item removal and the remove sound playing.")
      .add()
      .<Float>appendInherited(
         new KeyedCodec<>("ReferenceDistance", Codec.FLOAT),
         (var0, var1) -> var0.referenceDistance = var1,
         var0 -> var0.referenceDistance,
         (var0, var1) -> var0.referenceDistance = var1.referenceDistance
      )
      .addValidator(Validators.min(0.0F))
      .documentation("Distance at which the track plays at full volume.")
      .add()
      .<Float>appendInherited(
         new KeyedCodec<>("MaxDistance", Codec.FLOAT),
         (var0, var1) -> var0.maxDistance = var1,
         var0 -> var0.maxDistance,
         (var0, var1) -> var0.maxDistance = var1.maxDistance
      )
      .addValidator(Validators.min(0.0F))
      .documentation("Distance beyond which the track is inaudible.")
      .add()
      .<Float>appendInherited(
         new KeyedCodec<>("SpatialBlend", Codec.FLOAT),
         (var0, var1) -> var0.spatialBlend = var1,
         var0 -> var0.spatialBlend,
         (var0, var1) -> var0.spatialBlend = var1.spatialBlend
      )
      .addValidator(Validators.range(0.0F, 1.0F))
      .documentation("0 = fully 2D, 1 = fully 3D positioned.")
      .add()
      .<Float>appendInherited(
         new KeyedCodec<>("ReverbSend", Codec.FLOAT),
         (var0, var1) -> var0.reverbSend = var1,
         var0 -> var0.reverbSend,
         (var0, var1) -> var0.reverbSend = var1.reverbSend
      )
      .addValidator(Validators.range(0.0F, 1.0F))
      .documentation("Fraction routed to environment reverb. 0 = dry, 1 = full. Lower keeps sustained music from washing in reverberant spaces.")
      .add()
      .<Float>appendInherited(
         new KeyedCodec<>("Volume", Codec.FLOAT),
         (var0, var1) -> var0.volume = AudioUtil.decibelsToLinearGain(var1),
         var0 -> AudioUtil.linearGainToDecibels(var0.volume),
         (var0, var1) -> var0.volume = var1.volume
      )
      .addValidator(Validators.range(-80.0F, 24.0F))
      .documentation("Volume adjustment in decibels.")
      .add()
      .<Boolean>appendInherited(
         new KeyedCodec<>("Loop", Codec.BOOLEAN), (var0, var1) -> var0.loop = var1, var0 -> var0.loop, (var0, var1) -> var0.loop = var1.loop
      )
      .documentation("Loop the inserted item's container indefinitely, overriding its authored LoopCount.")
      .add()
      .afterDecode(MusicPlayerBlock::resolveIndexes)
      .build();
   @Nullable
   class="kw">protected String insertSoundId;
   @Nullable
   class="kw">protected String removeSoundId;
   class="kw">protected float startDelaySeconds = 2.0F;
   class="kw">protected float stopDelaySeconds = 0.5F;
   class="kw">protected float referenceDistance = 8.0F;
   class="kw">protected float maxDistance = 25.0F;
   class="kw">protected float spatialBlend = 0.6F;
   class="kw">protected float reverbSend = 0.35F;
   class="kw">protected float volume = 1.0F;
   class="kw">protected boolean loop = true;
   class="kw">protected class="kw">transient int insertSoundIndex = 0;
   class="kw">protected class="kw">transient int removeSoundIndex = 0;
   @Nullable
   class="kw">protected class="kw">transient String observedItemId;
   @Nullable
   class="kw">protected class="kw">transient Instant pendingStartDeadline;
   @Nullable
   class="kw">protected class="kw">transient Instant pendingRemoveSoundDeadline;

   class="kw">public class="kw">static ComponentType<ChunkStore, MusicPlayerBlock> getComponentType() {
      class="kw">return AudioPlugin.get().getMusicPlayerBlockComponentType();
   }

   class="kw">private class="kw">static int normalizeIndex(int var0) {
      class="kw">return var0 == Integer.MIN_VALUE ? 0 : var0;
   }

   class="kw">private MusicPlayerBlock() {
   }

   class="kw">public MusicPlayerBlock(@Nonnull MusicPlayerBlock var1) {
      this.insertSoundId = var1.insertSoundId;
      this.removeSoundId = var1.removeSoundId;
      this.startDelaySeconds = var1.startDelaySeconds;
      this.stopDelaySeconds = var1.stopDelaySeconds;
      this.referenceDistance = var1.referenceDistance;
      this.maxDistance = var1.maxDistance;
      this.spatialBlend = var1.spatialBlend;
      this.reverbSend = var1.reverbSend;
      this.volume = var1.volume;
      this.loop = var1.loop;
      this.insertSoundIndex = var1.insertSoundIndex;
      this.removeSoundIndex = var1.removeSoundIndex;
      this.observedItemId = var1.observedItemId;
      this.pendingStartDeadline = var1.pendingStartDeadline;
      this.pendingRemoveSoundDeadline = var1.pendingRemoveSoundDeadline;
   }

   class="kw">private void resolveIndexes() {
      this.insertSoundIndex = this.insertSoundId == null ? 0 : normalizeIndex(SoundEvent.getAssetMap().getIndex(this.insertSoundId));
      this.removeSoundIndex = this.removeSoundId == null ? 0 : normalizeIndex(SoundEvent.getAssetMap().getIndex(this.removeSoundId));
   }

   class="kw">public int getInsertSoundIndex() {
      class="kw">return this.insertSoundIndex;
   }

   class="kw">public int getRemoveSoundIndex() {
      class="kw">return this.removeSoundIndex;
   }

   class="kw">public float getStartDelaySeconds() {
      class="kw">return this.startDelaySeconds;
   }

   class="kw">public float getStopDelaySeconds() {
      class="kw">return this.stopDelaySeconds;
   }

   @Nullable
   class="kw">public String getObservedItemId() {
      class="kw">return this.observedItemId;
   }

   class="kw">public void setObservedItemId(@Nullable String var1) {
      this.observedItemId = var1;
   }

   @Nullable
   class="kw">public Instant getPendingStartDeadline() {
      class="kw">return this.pendingStartDeadline;
   }

   class="kw">public void setPendingStartDeadline(@Nullable Instant var1) {
      this.pendingStartDeadline = var1;
   }

   @Nullable
   class="kw">public Instant getPendingRemoveSoundDeadline() {
      class="kw">return this.pendingRemoveSoundDeadline;
   }

   class="kw">public void setPendingRemoveSoundDeadline(@Nullable Instant var1) {
      this.pendingRemoveSoundDeadline = var1;
   }

   @Nonnull
   class="kw">public MusicEmitterBlock buildEmitter(@Nonnull ItemMusic var1, @Nonnull String var2) {
      class="kw">return MusicEmitterBlock.create(
         var2, var1.getAudioCategoryOverrideId(), this.referenceDistance, this.maxDistance, this.spatialBlend, this.reverbSend, this.volume, this.loop
      );
   }

   @Nonnull
   @Override
   class="kw">public Component<ChunkStore> clone() {
      class="kw">return new MusicPlayerBlock(this);
   }
}