SoundEvent class
Пакет: com.hypixel.hytale.server.core.asset.type.soundevent.config
Файл: com/hypixel/hytale/server/core/asset/type/soundevent/config/SoundEvent.java
implements: JsonAssetWithMap<String, IndexedLookupTableAssetMap<String, SoundEvent>>,
NetworkSerializable<com.hypixel.hytale.protocol.SoundEvent>
Поля (4)
| Модификаторы | Тип | Имя |
|---|---|---|
|
|
ASSET_STORE |
final |
int |
EMPTY_ID |
|
com.hypixel.hytale.protocol.SoundEvent |
var1 |
|
com.hypixel.hytale.protocol.SoundEvent |
var2 |
Методы (23)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
for for(SoundEventLayer var4 : this.layers) |
|
|
for for(int var3 = 0; var3 < this.layers.length; var3++) |
static |
IndexedLookupTableAssetMap<String, SoundEvent> |
getAssetMapIndexedLookupTableAssetMap<String, SoundEvent> getAssetMap() |
static |
AssetStore<String, SoundEvent, IndexedLookupTableAssetMap<String, SoundEvent>> |
getAssetStoreAssetStore<String, SoundEvent, IndexedLookupTableAssetMap<String, SoundEvent>> getAssetStore() |
public |
int |
getAudioCategoryIndexint getAudioCategoryIndex() |
public |
int |
getHighestNumberOfChannelsint getHighestNumberOfChannels() |
public |
String |
getIdString getId() |
public |
SoundEventLayer[] |
getLayersSoundEventLayer[] getLayers() |
public |
float |
getMaxDistancefloat getMaxDistance() |
public |
int |
getMaxInstanceint getMaxInstance() |
public |
float |
getPitchfloat getPitch() |
public |
boolean |
getPreventSoundInterruptionboolean getPreventSoundInterruption() |
public |
float |
getSpatialBlendfloat getSpatialBlend() |
public |
float |
getStartAttenuationDistancefloat getStartAttenuationDistance() |
public |
float |
getVolumefloat getVolume() |
|
|
if if(ASSET_STORE == null) |
|
|
if if(this.audioCategoryId != null) |
|
|
if if(this.layers != null) |
|
|
if if(var4.highestNumberOfChannels > this.highestNumberOfChannels) |
|
|
if if(var1 != null) |
|
|
if if(this.layers != null && this.layers.length > 0) |
public |
void |
invalidatePacketCachevoid invalidatePacketCache() |
protected |
void |
processConfigvoid processConfig() |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.asset.type.soundevent.config;
class="kw">import com.hypixel.hytale.assetstore.AssetExtraInfo;
class="kw">import com.hypixel.hytale.assetstore.AssetKeyValidator;
class="kw">import com.hypixel.hytale.assetstore.AssetRegistry;
class="kw">import com.hypixel.hytale.assetstore.AssetStore;
class="kw">import com.hypixel.hytale.assetstore.codec.AssetBuilderCodec;
class="kw">import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
class="kw">import com.hypixel.hytale.assetstore.map.JsonAssetWithMap;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
class="kw">import com.hypixel.hytale.codec.schema.metadata.ui.UIEditor;
class="kw">import com.hypixel.hytale.codec.validation.ValidatorCache;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.common.util.AudioUtil;
class="kw">import com.hypixel.hytale.server.core.asset.type.audiocategory.config.AudioCategory;
class="kw">import com.hypixel.hytale.server.core.asset.type.audiocategory.config.AudioCategoryDuckingRuleConfig;
class="kw">import com.hypixel.hytale.server.core.asset.type.audiostate.config.AudioStateResolver;
class="kw">import com.hypixel.hytale.server.core.asset.type.audiostate.config.StateBindingConfig;
class="kw">import com.hypixel.hytale.server.core.io.NetworkSerializable;
class="kw">import java.lang.ref.SoftReference;
class="kw">import java.util.Arrays;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class SoundEvent
class="kw">implements JsonAssetWithMap<String, IndexedLookupTableAssetMap<String, SoundEvent>>,
NetworkSerializable<com.hypixel.hytale.protocol.SoundEvent> {
class="kw">public class="kw">static class="kw">final int EMPTY_ID = 0;
class="kw">public class="kw">static class="kw">final String EMPTY = "EMPTY";
class="kw">public class="kw">static class="kw">final SoundEvent EMPTY_SOUND_EVENT = new SoundEvent("EMPTY");
class="kw">private class="kw">static class="kw">final int MAX_SOUND_EVENT_LAYERS = 8;
class="kw">public class="kw">static class="kw">final AssetBuilderCodec<String, SoundEvent> CODEC = AssetBuilderCodec.builder(
SoundEvent.class, SoundEvent::new, Codec.STRING, (var0, var1) -> var0.id = var1, var0 -> var0.id, (var0, var1) -> var0.data = var1, var0 -> var0.data
)
.appendInherited(
new KeyedCodec<>("Volume", Codec.FLOAT),
(var0, var1) -> var0.volume = AudioUtil.decibelsToLinearGain(var1),
var0 -> AudioUtil.linearGainToDecibels(var0.volume),
(var0, var1) -> var0.volume = var1.volume
)
.metadata(new UIEditor(new UIEditor.FormattedNumber(null, " dB", null)))
.addValidator(Validators.range(-100.0F, 10.0F))
.documentation("Volume adjustment of the sound event in decibels.")
.add()
.<Float>appendInherited(
new KeyedCodec<>("Pitch", Codec.FLOAT),
(var0, var1) -> var0.pitch = AudioUtil.semitonesToLinearPitch(var1),
var0 -> AudioUtil.linearPitchToSemitones(var0.pitch),
(var0, var1) -> var0.pitch = var1.pitch
)
.addValidator(Validators.range(-12.0F, 12.0F))
.documentation("Pitch adjustment of the sound event in semitones.")
.add()
.<Float>appendInherited(
new KeyedCodec<>("StartAttenuationDistance", Codec.FLOAT),
(var0, var1) -> var0.startAttenuationDistance = var1,
var0 -> var0.startAttenuationDistance,
(var0, var1) -> var0.startAttenuationDistance = var1.startAttenuationDistance
)
.documentation("Distance at which to begin attenuation in blocks.")
.add()
.<Float>appendInherited(
new KeyedCodec<>("MaxDistance", Codec.FLOAT),
(var0, var1) -> var0.maxDistance = var1,
var0 -> var0.maxDistance,
(var0, var1) -> var0.maxDistance = var1.maxDistance
)
.documentation("Maximum distance at which this sound event can be heard in blocks (i.e. the distance at which it's attenuated to zero).")
.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(
"Controls spatial blending. At 1.0 the source is fully 3D (i.e. a point source). At 0.0 the source is fully diffuse (i.e. centered on the player). Only applies to Stereo Headphone mode."
)
.add()
.<Integer>appendInherited(
new KeyedCodec<>("MaxInstance", Codec.INTEGER),
(var0, var1) -> var0.maxInstance = var1,
var0 -> var0.maxInstance,
(var0, var1) -> var0.maxInstance = var1.maxInstance
)
.addValidator(Validators.range(1, 100))
.documentation("Max concurrent number of instances of this sound event.")
.add()
.<Boolean>appendInherited(
new KeyedCodec<>("PreventSoundInterruption", Codec.BOOLEAN),
(var0, var1) -> var0.preventSoundInterruption = var1,
var0 -> var0.preventSoundInterruption,
(var0, var1) -> var0.preventSoundInterruption = var1.preventSoundInterruption
)
.documentation("Whether to prevent interruption of this sound event.")
.add()
.<SoundEventLayer[]>appendInherited(
new KeyedCodec<>("Layers", new ArrayCodec<>(SoundEventLayer.CODEC, SoundEventLayer[]::new)),
(var0, var1) -> var0.layers = var1,
var0 -> var0.layers,
(var0, var1) -> var0.layers = var1.layers
)
.addValidator(Validators.nonNull())
.addValidator(Validators.arraySizeRange(1, 8))
.documentation("The layered sounds that make up this sound event.")
.add()
.<String>appendInherited(
new KeyedCodec<>("AudioCategory", Codec.STRING),
(var0, var1) -> var0.audioCategoryId = var1,
var0 -> var0.audioCategoryId,
(var0, var1) -> var0.audioCategoryId = var1.audioCategoryId
)
.addValidator(AudioCategory.VALIDATOR_CACHE.getValidator())
.documentation("Audio category to assign this sound event to for additional property routing.")
.add()
.<StateBindingConfig[]>append(
new KeyedCodec<>("StateBindings", StateBindingConfig.CODEC_ARRAY), (var0, var1) -> var0.stateBindings = var1, var0 -> var0.stateBindings
)
.documentation("Subscribe this sound event to AudioState axes. Per-state volume deltas will be applied to all layers.")
.add()
.<AudioCategoryDuckingRuleConfig[]>append(
new KeyedCodec<>("DuckingRules", AudioCategoryDuckingRuleConfig.CODEC_ARRAY), (var0, var1) -> var0.duckingRules = var1, var0 -> var0.duckingRules
)
.documentation("While any layer of this SoundEvent is playing, each rule attenuates its TargetCategory.")
.add()
.<Boolean>append(new KeyedCodec<>("BypassDucking", Codec.BOOLEAN), (var0, var1) -> var0.bypassDucking = var1, var0 -> var0.bypassDucking)
.documentation("When true, this SoundEvent's voices ignore the ducking contribution of their routing category.")
.add()
.afterDecode(SoundEvent::processConfig)
.validator((var0, var1) -> {
AudioStateResolver.validateBindings(var0.stateBindings, "SoundEvent '" + var0.id + "'", var1);
AudioCategoryDuckingRuleConfig.validateUniqueTargets(var0.duckingRules, "SoundEvent '" + var0.id + "'", var1);
})
.build();
class="kw">public class="kw">static class="kw">final ValidatorCache<String> VALIDATOR_CACHE = new ValidatorCache<>(new AssetKeyValidator<>(SoundEvent::getAssetStore));
class="kw">private class="kw">static AssetStore<String, SoundEvent, IndexedLookupTableAssetMap<String, SoundEvent>> ASSET_STORE;
class="kw">protected AssetExtraInfo.Data data;
class="kw">protected String id;
class="kw">protected class="kw">transient float volume = 1.0F;
class="kw">protected class="kw">transient float pitch = 1.0F;
class="kw">protected float startAttenuationDistance = 2.0F;
class="kw">protected float maxDistance = 16.0F;
class="kw">protected float spatialBlend = 0.6F;
class="kw">protected int maxInstance = 50;
class="kw">protected boolean preventSoundInterruption = false;
class="kw">protected SoundEventLayer[] layers;
@Nullable
class="kw">protected String audioCategoryId = null;
class="kw">protected class="kw">transient int audioCategoryIndex = 0;
@Nullable
class="kw">protected StateBindingConfig[] stateBindings;
@Nullable
class="kw">protected AudioCategoryDuckingRuleConfig[] duckingRules;
class="kw">protected boolean bypassDucking;
class="kw">protected class="kw">transient int highestNumberOfChannels = 0;
class="kw">private SoftReference<com.hypixel.hytale.protocol.SoundEvent> cachedPacket;
class="kw">public class="kw">static AssetStore<String, SoundEvent, IndexedLookupTableAssetMap<String, SoundEvent>> getAssetStore() {
if (ASSET_STORE == null) {
ASSET_STORE = AssetRegistry.getAssetStore(SoundEvent.class);
}
class="kw">return ASSET_STORE;
}
class="kw">public class="kw">static IndexedLookupTableAssetMap<String, SoundEvent> getAssetMap() {
class="kw">return (IndexedLookupTableAssetMap<String, SoundEvent>)getAssetStore().getAssetMap();
}
class="kw">protected void processConfig() {
if (this.audioCategoryId != null) {
this.audioCategoryIndex = AudioCategory.getAssetMap().getIndex(this.audioCategoryId);
}
if (this.layers != null) {
for (SoundEventLayer var4 : this.layers) {
if (var4.highestNumberOfChannels > this.highestNumberOfChannels) {
this.highestNumberOfChannels = var4.highestNumberOfChannels;
}
}
}
AudioStateResolver.resolveBindings(this.stateBindings);
}
@Nullable
class="kw">public AudioCategoryDuckingRuleConfig[] getDuckingRules() {
class="kw">return this.duckingRules;
}
class="kw">public void invalidatePacketCache() {
this.cachedPacket = null;
}
class="kw">public SoundEvent(String var1, float var2, float var3, float var4, float var5, int var6, boolean var7, SoundEventLayer[] var8) {
this.id = var1;
this.volume = var2;
this.pitch = var3;
this.startAttenuationDistance = var4;
this.maxDistance = var5;
this.maxInstance = var6;
this.preventSoundInterruption = var7;
this.layers = var8;
}
class="kw">public SoundEvent(String var1) {
this.id = var1;
}
class="kw">protected SoundEvent() {
}
class="kw">public String getId() {
class="kw">return this.id;
}
class="kw">public float getVolume() {
class="kw">return this.volume;
}
class="kw">public float getPitch() {
class="kw">return this.pitch;
}
class="kw">public float getStartAttenuationDistance() {
class="kw">return this.startAttenuationDistance;
}
class="kw">public float getMaxDistance() {
class="kw">return this.maxDistance;
}
class="kw">public float getSpatialBlend() {
class="kw">return this.spatialBlend;
}
class="kw">public int getMaxInstance() {
class="kw">return this.maxInstance;
}
class="kw">public boolean getPreventSoundInterruption() {
class="kw">return this.preventSoundInterruption;
}
class="kw">public SoundEventLayer[] getLayers() {
class="kw">return this.layers;
}
@Nullable
class="kw">public String getAudioCategoryId() {
class="kw">return this.audioCategoryId;
}
class="kw">public int getAudioCategoryIndex() {
class="kw">return this.audioCategoryIndex;
}
class="kw">public int getHighestNumberOfChannels() {
class="kw">return this.highestNumberOfChannels;
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "SoundEvent{id='"
+ this.id
+ "', volume="
+ this.volume
+ ", pitch="
+ this.pitch
+ ", startAttenuationDistance="
+ this.startAttenuationDistance
+ ", maxDistance="
+ this.maxDistance
+ ", spatialBlend="
+ this.spatialBlend
+ ", maxInstance="
+ this.maxInstance
+ ", preventSoundInterruption="
+ this.preventSoundInterruption
+ ", layers="
+ Arrays.toString(this.layers)
+ ", audioCategoryId='"
+ this.audioCategoryId
+ "', audioCategoryIndex="
+ this.audioCategoryIndex
+ ", highestNumberOfChannels="
+ this.highestNumberOfChannels
+ "}";
}
@Nonnull
class="kw">public com.hypixel.hytale.protocol.SoundEvent toPacket() {
com.hypixel.hytale.protocol.SoundEvent var1 = this.cachedPacket == null ? null : this.cachedPacket.get();
if (var1 != null) {
class="kw">return var1;
}
com.hypixel.hytale.protocol.SoundEvent var2 = new com.hypixel.hytale.protocol.SoundEvent();
var2.id = this.id;
var2.volume = this.volume;
var2.pitch = this.pitch;
var2.startAttenuationDistance = this.startAttenuationDistance;
var2.maxDistance = this.maxDistance;
var2.spatialBlend = this.spatialBlend;
var2.maxInstance = this.maxInstance;
var2.preventSoundInterruption = this.preventSoundInterruption;
var2.audioCategory = this.audioCategoryIndex;
if (this.layers != null && this.layers.length > 0) {
var2.layers = new com.hypixel.hytale.protocol.SoundEventLayer[this.layers.length];
for (int var3 = 0; var3 < this.layers.length; var3++) {
var2.layers[var3] = this.layers[var3].toPacket();
}
}
var2.stateBindings = AudioStateResolver.toPacketArray(this.stateBindings);
var2.duckingRules = AudioCategoryDuckingRuleConfig.toPacketArray(this.duckingRules);
var2.bypassDucking = this.bypassDucking;
this.cachedPacket = new SoftReference<>(var2);
class="kw">return var2;
}
}