DeployableConfig class

Пакет: com.hypixel.hytale.builtin.deployables.config

Файл: com/hypixel/hytale/builtin/deployables/config/DeployableConfig.java

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

Поля (7)

МодификаторыТипИмя
private static final BuilderCodec<DeployableConfig.StatConfig> CODEC
private float initial
private float max
com.hypixel.hytale.protocol.DeployableConfig var1
Ref var3
NetworkId var4
NetworkId var4

Методы (40)

МодификаторыВозвратСигнатура
private StatConfigprivate StatConfig()
public void firstTickvoid firstTick(@Nonnull DeployableComponent var1, float var2, int var3, @Nonnull ArchetypeChunk<EntityStore> var4, @Nonnull Store<EntityStore> var5, @Nonnull CommandBuffer<EntityStore> var6)
public boolean getAllowPlaceOnWallsboolean getAllowPlaceOnWalls()
public int getAmbientSoundEventIndexint getAmbientSoundEventIndex()
public boolean getCountTowardsGlobalLimitboolean getCountTowardsGlobalLimit()
public boolean getDebugVisualsboolean getDebugVisuals()
public int getDeploySoundEventIndexint getDeploySoundEventIndex()
public ModelParticle[] getDespawnParticlesModelParticle[] getDespawnParticles()
public int getDespawnSoundEventIndexint getDespawnSoundEventIndex()
public int getDieSoundEventIndexint getDieSoundEventIndex()
public int getHitboxCollisionConfigIndexint getHitboxCollisionConfigIndex()
public String getIdString getId()
public float getInitialpublic float getInitial()
public boolean getInvulnerableboolean getInvulnerable()
public float getLiveDurationfloat getLiveDuration()
public long getLiveDurationInMillislong getLiveDurationInMillis()
public float getMaxpublic float getMax()
public int getMaxLiveCountint getMaxLiveCount()
public Model getModelModel getModel()
public Model getModelPreviewModel getModelPreview()
public ModelParticle[] getSpawnParticlesModelParticle[] getSpawnParticles()
public Map<String, DeployableConfig.StatConfig> getStatValuesMap<String, DeployableConfig.StatConfig> getStatValues()
public boolean getWireframeDebugVisualsboolean getWireframeDebugVisuals()
if if(var0.deploySoundEventId != null)
if if(var0.despawnSoundEventId != null)
if if(var0.dieSoundEventId != null)
if if(var0.ambientSoundEventId != null)
if if(var0.generatedModel != null)
if if(var0.generatedModelPreview != null)
if if(var0.hitboxCollisionConfigId != null)
if if(var4 != null)
if if(var4 != null)
if if(this.generatedModel != null)
if if(this.modelPreview == null)
if if(this.generatedModelPreview != null)
if if(this.modelPreview != null)
static void playAnimationvoid playAnimation(@Nonnull Store<EntityStore> var0, @Nonnull Ref<EntityStore> var1, @Nonnull DeployableConfig var2, @Nonnull String var3)
static void processConfigvoid processConfig(@Nonnull DeployableConfig var0)
static void stopAnimationvoid stopAnimation(@Nonnull Store<EntityStore> var0, @Nonnull ArchetypeChunk<EntityStore> var1, int var2)
public void tickvoid tick(@Nonnull DeployableComponent var1, float var2, int var3, @Nonnull ArchetypeChunk<EntityStore> var4, @Nonnull Store<EntityStore> var5, @Nonnull CommandBuffer<EntityStore> var6)

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.deployables.DeployablesUtils;
class="kw">import com.hypixel.hytale.builtin.deployables.component.DeployableComponent;
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.map.MapCodec;
class="kw">import com.hypixel.hytale.codec.lookup.CodecMapCodec;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.component.ArchetypeChunk;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.protocol.AnimationSlot;
class="kw">import com.hypixel.hytale.server.core.asset.type.model.config.Model;
class="kw">import com.hypixel.hytale.server.core.asset.type.model.config.ModelAsset;
class="kw">import com.hypixel.hytale.server.core.asset.type.model.config.ModelParticle;
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.io.NetworkSerializable;
class="kw">import com.hypixel.hytale.server.core.modules.entity.hitboxcollision.HitboxCollisionConfig;
class="kw">import com.hypixel.hytale.server.core.modules.entity.tracker.NetworkId;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
class="kw">import java.util.Map;
class="kw">import javax.annotation.Nonnull;

class="kw">public class="kw">abstract class DeployableConfig class="kw">implements NetworkSerializable<com.hypixel.hytale.protocol.DeployableConfig> {
   @Nonnull
   class="kw">public class="kw">static class="kw">final CodecMapCodec<DeployableConfig> CODEC = new CodecMapCodec<>("Type");
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<DeployableConfig> BASE_CODEC = BuilderCodec.abstractBuilder(DeployableConfig.class)
      .appendInherited(new KeyedCodec<>("Id", Codec.STRING), (var0, var1) -> var0.id = var1, var0 -> var0.id, (var0, var1) -> var0.id = var1.id)
      .documentation("Used to identify this deployable for uses such as MaxLiveCount")
      .add()
      .<Integer>appendInherited(
         new KeyedCodec<>("MaxLiveCount", Codec.INTEGER),
         (var0, var1) -> var0.maxLiveCount = var1,
         var0 -> var0.maxLiveCount,
         (var0, var1) -> var0.maxLiveCount = var1.maxLiveCount
      )
      .documentation("The maximum amount of this deployable that can be live at once")
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("Model", Codec.STRING), (var0, var1) -> var0.model = var1, var0 -> var0.model, (var0, var1) -> var0.model = var1.model
      )
      .addValidator(Validators.nonNull())
      .addValidator(ModelAsset.VALIDATOR_CACHE.getValidator())
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("ModelPreview", Codec.STRING),
         (var0, var1) -> var0.modelPreview = var1,
         var0 -> var0.modelPreview,
         (var0, var1) -> var0.modelPreview = var1.modelPreview
      )
      .addValidator(ModelAsset.VALIDATOR_CACHE.getValidator())
      .add()
      .appendInherited(
         new KeyedCodec<>("ModelScale", Codec.FLOAT),
         (var0, var1) -> var0.modelScale = var1,
         var0 -> var0.modelScale,
         (var0, var1) -> var0.modelScale = var1.modelScale
      )
      .add()
      .<Float>appendInherited(
         new KeyedCodec<>("LiveDuration", Codec.FLOAT),
         (var0, var1) -> var0.liveDuration = var1,
         var0 -> var0.liveDuration,
         (var0, var1) -> var0.liveDuration = var1.liveDuration
      )
      .documentation("The duration of the lifetime of the deployable in seconds")
      .add()
      .<Boolean>appendInherited(
         new KeyedCodec<>("Invulnerable", Codec.BOOLEAN),
         (var0, var1) -> var0.invulnerable = var1,
         var0 -> var0.invulnerable,
         (var0, var1) -> var0.invulnerable = var1.invulnerable
      )
      .documentation("Whether this deployable is invulnerable to damage or not")
      .add()
      .<Map>appendInherited(
         new KeyedCodec<>("Stats", new MapCodec<>(DeployableConfig.StatConfig.CODEC, Object2ObjectOpenHashMap::new)),
         (var0, var1) -> var0.statValues = var1,
         var0 -> var0.statValues,
         (var0, var1) -> var0.statValues = var1.statValues
      )
      .documentation("The class="kw">default stat configuration for the deployable")
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("DeploySoundEventId", Codec.STRING),
         (var0, var1) -> var0.deploySoundEventId = var1,
         var0 -> var0.deploySoundEventId,
         (var0, var1) -> var0.deploySoundEventId = var1.deploySoundEventId
      )
      .documentation("The ID of the sound to play upon deployment (at deployment location)")
      .addValidator(SoundEventValidators.ONESHOT)
      .addValidator(SoundEventValidators.MONO)
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("DespawnSoundEventId", Codec.STRING),
         (var0, var1) -> var0.despawnSoundEventId = var1,
         var0 -> var0.despawnSoundEventId,
         (var0, var1) -> var0.despawnSoundEventId = var1.despawnSoundEventId
      )
      .documentation("The ID of the sound to play when despawning")
      .addValidator(SoundEventValidators.ONESHOT)
      .addValidator(SoundEventValidators.MONO)
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("DieSoundEventId", Codec.STRING),
         (var0, var1) -> var0.dieSoundEventId = var1,
         var0 -> var0.dieSoundEventId,
         (var0, var1) -> var0.dieSoundEventId = var1.dieSoundEventId
      )
      .documentation("The ID of the sound to play when despawning due to death")
      .addValidator(SoundEventValidators.ONESHOT)
      .addValidator(SoundEventValidators.MONO)
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("AmbientSoundEventId", Codec.STRING),
         (var0, var1) -> var0.ambientSoundEventId = var1,
         var0 -> var0.ambientSoundEventId,
         (var0, var1) -> var0.ambientSoundEventId = var1.ambientSoundEventId
      )
      .documentation("The ID of the sound to play ambiently from the deployable while it's in the world")
      .addValidator(SoundEventValidators.LOOPING)
      .addValidator(SoundEventValidators.MONO)
      .add()
      .<ModelParticle[]>appendInherited(
         new KeyedCodec<>("SpawnParticles", ModelParticle.ARRAY_CODEC),
         (var0, var1) -> var0.spawnParticles = var1,
         var0 -> var0.spawnParticles,
         (var0, var1) -> var0.spawnParticles = var1.spawnParticles
      )
      .documentation("A collection of model particles to play when this deployable is spawned.")
      .add()
      .<ModelParticle[]>appendInherited(
         new KeyedCodec<>("DespawnParticles", ModelParticle.ARRAY_CODEC),
         (var0, var1) -> var0.despawnParticles = var1,
         var0 -> var0.despawnParticles,
         (var0, var1) -> var0.despawnParticles = var1.despawnParticles
      )
      .documentation("A collection of model particles to play when this deployable is despawned.")
      .add()
      .<Boolean>appendInherited(
         new KeyedCodec<>("DebugVisuals", Codec.BOOLEAN),
         (var0, var1) -> var0.debugVisuals = var1,
         var0 -> var0.debugVisuals,
         (var0, var1) -> var0.debugVisuals = var1.debugVisuals
      )
      .documentation("Whether or not to display debug visuals.")
      .add()
      .<Boolean>appendInherited(
         new KeyedCodec<>("AllowPlaceOnWalls", Codec.BOOLEAN),
         (var0, var1) -> var0.allowPlaceOnWalls = var1,
         var0 -> var0.allowPlaceOnWalls,
         (var0, var1) -> var0.allowPlaceOnWalls = var1.allowPlaceOnWalls
      )
      .documentation("Whether or not this deployable can be placed on walls.")
      .add()
      .<Boolean>appendInherited(
         new KeyedCodec<>("WireframeDebugVisuals", Codec.BOOLEAN),
         (var0, var1) -> var0.wireframeDebugVisuals = var1,
         var0 -> var0.wireframeDebugVisuals,
         (var0, var1) -> var0.wireframeDebugVisuals = var1.wireframeDebugVisuals
      )
      .documentation("Whether debug visuals will be wireframe or have color.")
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("HitboxCollisionConfig", Codec.STRING),
         (var0, var1) -> var0.hitboxCollisionConfigId = var1,
         var0 -> var0.hitboxCollisionConfigId,
         (var0, var1) -> var0.hitboxCollisionConfigId = var1.hitboxCollisionConfigId
      )
      .documentation("The HitboxCollision config to apply to the deployable.")
      .addValidator(HitboxCollisionConfig.VALIDATOR_CACHE.getValidator())
      .add()
      .<Boolean>appendInherited(
         new KeyedCodec<>("CountTowardsGlobalLimit", Codec.BOOLEAN),
         (var0, var1) -> var0.countTowardsGlobalLimit = var1,
         var0 -> var0.countTowardsGlobalLimit,
         (var0, var1) -> var0.countTowardsGlobalLimit = var1.countTowardsGlobalLimit
      )
      .documentation("Whether or not this deployable counts towards global deployable limit")
      .add()
      .afterDecode(DeployableConfig::processConfig)
      .build();
   class="kw">protected Map<String, DeployableConfig.StatConfig> statValues;
   class="kw">protected String deploySoundEventId;
   class="kw">protected String despawnSoundEventId;
   class="kw">protected String dieSoundEventId;
   class="kw">protected String ambientSoundEventId;
   class="kw">protected ModelParticle[] spawnParticles;
   class="kw">protected ModelParticle[] despawnParticles;
   class="kw">protected class="kw">transient int deploySoundEventIndex = 0;
   class="kw">protected class="kw">transient int despawnSoundEventIndex = 0;
   class="kw">protected class="kw">transient int dieSoundEventIndex = 0;
   class="kw">protected class="kw">transient int ambientSoundEventIndex = 0;
   class="kw">protected Model generatedModel;
   class="kw">protected Model generatedModelPreview;
   class="kw">protected String hitboxCollisionConfigId;
   class="kw">protected int hitboxCollisionConfigIndex = -1;
   class="kw">private String id;
   class="kw">private int maxLiveCount = Integer.MAX_VALUE;
   class="kw">private String model;
   class="kw">private String modelPreview;
   class="kw">private float modelScale = 1.0F;
   class="kw">private float liveDuration = 1.0F;
   class="kw">private boolean invulnerable;
   class="kw">private boolean debugVisuals;
   class="kw">private boolean allowPlaceOnWalls;
   class="kw">private boolean wireframeDebugVisuals;
   class="kw">private boolean countTowardsGlobalLimit = true;

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

   class="kw">private class="kw">static void processConfig(@Nonnull DeployableConfig var0) {
      if (var0.deploySoundEventId != null) {
         var0.deploySoundEventIndex = SoundEvent.getAssetMap().getIndex(var0.deploySoundEventId);
      }

      if (var0.despawnSoundEventId != null) {
         var0.despawnSoundEventIndex = SoundEvent.getAssetMap().getIndex(var0.despawnSoundEventId);
      }

      if (var0.dieSoundEventId != null) {
         var0.dieSoundEventIndex = SoundEvent.getAssetMap().getIndex(var0.dieSoundEventId);
      }

      if (var0.ambientSoundEventId != null) {
         var0.ambientSoundEventIndex = SoundEvent.getAssetMap().getIndex(var0.ambientSoundEventId);
      }

      if (var0.generatedModel != null) {
         var0.generatedModel = Model.createScaledModel(ModelAsset.getAssetMap().getAsset(var0.model), var0.modelScale);
      }

      if (var0.generatedModelPreview != null) {
         var0.generatedModelPreview = Model.createScaledModel(ModelAsset.getAssetMap().getAsset(var0.modelPreview), var0.modelScale);
      }

      if (var0.hitboxCollisionConfigId != null) {
         var0.hitboxCollisionConfigIndex = HitboxCollisionConfig.getAssetMap().getIndexOrDefault(var0.hitboxCollisionConfigId, -1);
      }
   }

   class="kw">protected class="kw">static void playAnimation(@Nonnull Store<EntityStore> var0, @Nonnull Ref<EntityStore> var1, @Nonnull DeployableConfig var2, @Nonnull String var3) {
      NetworkId var4 = var0.getComponent(var1, NetworkId.getComponentType());
      if (var4 != null) {
         DeployablesUtils.playAnimation(var0, var4.getId(), var1, var2, AnimationSlot.Action, null, var3);
      }
   }

   class="kw">protected class="kw">static void stopAnimation(@Nonnull Store<EntityStore> var0, @Nonnull ArchetypeChunk<EntityStore> var1, int var2) {
      Ref var3 = var1.getReferenceTo(var2);
      if (var3.isValid()) {
         NetworkId var4 = var1.getComponent(var2, NetworkId.getComponentType());
         if (var4 != null) {
            DeployablesUtils.stopAnimation(var0, var4.getId(), var3, AnimationSlot.Action);
         }
      }
   }

   class="kw">public Model getModel() {
      if (this.generatedModel != null) {
         class="kw">return this.generatedModel;
      }

      this.generatedModel = Model.createScaledModel(ModelAsset.getAssetMap().getAsset(this.model), this.modelScale);
      class="kw">return this.generatedModel;
   }

   class="kw">public Model getModelPreview() {
      if (this.modelPreview == null) {
         class="kw">return null;
      }

      if (this.generatedModelPreview != null) {
         class="kw">return this.generatedModelPreview;
      }

      this.generatedModelPreview = Model.createScaledModel(ModelAsset.getAssetMap().getAsset(this.modelPreview), this.modelScale);
      class="kw">return this.generatedModelPreview;
   }

   class="kw">public int getHitboxCollisionConfigIndex() {
      class="kw">return this.hitboxCollisionConfigIndex;
   }

   class="kw">public long getLiveDurationInMillis() {
      class="kw">return (long)(this.liveDuration * 1000.0F);
   }

   class="kw">public float getLiveDuration() {
      class="kw">return this.liveDuration;
   }

   class="kw">public String getId() {
      class="kw">return this.id;
   }

   class="kw">public int getMaxLiveCount() {
      class="kw">return this.maxLiveCount;
   }

   class="kw">public boolean getInvulnerable() {
      class="kw">return this.invulnerable;
   }

   class="kw">public Map<String, DeployableConfig.StatConfig> getStatValues() {
      class="kw">return this.statValues;
   }

   class="kw">public int getDespawnSoundEventIndex() {
      class="kw">return this.despawnSoundEventIndex;
   }

   class="kw">public int getDeploySoundEventIndex() {
      class="kw">return this.deploySoundEventIndex;
   }

   class="kw">public int getDieSoundEventIndex() {
      class="kw">return this.dieSoundEventIndex;
   }

   class="kw">public int getAmbientSoundEventIndex() {
      class="kw">return this.ambientSoundEventIndex;
   }

   class="kw">public ModelParticle[] getSpawnParticles() {
      class="kw">return this.spawnParticles;
   }

   class="kw">public ModelParticle[] getDespawnParticles() {
      class="kw">return this.despawnParticles;
   }

   class="kw">public boolean getDebugVisuals() {
      class="kw">return this.debugVisuals;
   }

   class="kw">public boolean getAllowPlaceOnWalls() {
      class="kw">return this.allowPlaceOnWalls;
   }

   class="kw">public boolean getWireframeDebugVisuals() {
      class="kw">return this.wireframeDebugVisuals;
   }

   class="kw">public boolean getCountTowardsGlobalLimit() {
      class="kw">return this.countTowardsGlobalLimit;
   }

   class="kw">public void tick(
      @Nonnull DeployableComponent var1,
      float var2,
      int var3,
      @Nonnull ArchetypeChunk<EntityStore> var4,
      @Nonnull Store<EntityStore> var5,
      @Nonnull CommandBuffer<EntityStore> var6
   ) {
   }

   class="kw">public void firstTick(
      @Nonnull DeployableComponent var1,
      float var2,
      int var3,
      @Nonnull ArchetypeChunk<EntityStore> var4,
      @Nonnull Store<EntityStore> var5,
      @Nonnull CommandBuffer<EntityStore> var6
   ) {
   }

   @Nonnull
   class="kw">public com.hypixel.hytale.protocol.DeployableConfig toPacket() {
      com.hypixel.hytale.protocol.DeployableConfig var1 = new com.hypixel.hytale.protocol.DeployableConfig();
      var1.model = this.getModel().toPacket();
      if (this.modelPreview != null) {
         var1.modelPreview = this.getModelPreview().toPacket();
      }

      var1.allowPlaceOnWalls = this.allowPlaceOnWalls;
      class="kw">return var1;
   }

   @Override
   class="kw">public String toString() {
      class="kw">return "DeployableConfig{}";
   }

   class="kw">public class="kw">static class StatConfig {
      @Nonnull
      class="kw">private class="kw">static class="kw">final BuilderCodec<DeployableConfig.StatConfig> CODEC = BuilderCodec.builder(
            DeployableConfig.StatConfig.class, DeployableConfig.StatConfig::new
         )
         .documentation("Initial and maximum values for a stat.")
         .<Float>append(new KeyedCodec<>("Max", Codec.FLOAT), (var0, var1) -> var0.max = var1, var0 -> var0.max)
         .addValidator(Validators.nonNull())
         .addValidator(Validators.greaterThan(0.0F))
         .documentation("The maximum value for the stat.")
         .add()
         .<Float>append(new KeyedCodec<>("Initial", Codec.FLOAT), (var0, var1) -> var0.initial = var1, var0 -> var0.initial)
         .documentation("The initial value for the stat. If omitted, will be set to max.")
         .add()
         .build();
      class="kw">private float max;
      class="kw">private float initial = Float.MAX_VALUE;

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

      class="kw">public float getMax() {
         class="kw">return this.max;
      }

      class="kw">public float getInitial() {
         class="kw">return this.initial;
      }
   }
}