DamageEffects class

Пакет: com.hypixel.hytale.server.core.modules.interaction.interaction.config.server.combat

Файл: com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/DamageEffects.java

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

Поля (11)

МодификаторыТипИмя
final BuilderCodec<DamageEffects> CODEC
com.hypixel.hytale.protocol.ModelParticle[] var1
var1
TransformComponent var3
Vector3d var4
com.hypixel.hytale.protocol.WorldParticle[] var4
var4
SpatialResource var5
List var6
PlayerRef var7
boolean var8

Методы (26)

МодификаторыВозвратСигнатура
public void addToDamagevoid addToDamage(@Nonnull Damage var1)
for for(int var2 = 0; var2 < this.modelParticles.length; var2++)
for for(int var3 = 0; var3 < this.worldParticles.length; var3++)
public String getCameraEffectIdString getCameraEffectId()
public Knockback getKnockbackKnockback getKnockback()
public int getLocalSoundEventIndexint getLocalSoundEventIndex()
public ModelParticle[] getModelParticlesModelParticle[] getModelParticles()
public double getViewDistancedouble getViewDistance()
public WorldParticle[] getWorldParticlesWorldParticle[] getWorldParticles()
public int getWorldSoundEventIndexint getWorldSoundEventIndex()
if if(this.localSoundEventId != null)
if if(this.worldSoundEventId != null)
if if(this.playerSoundEventId != null)
if if(this.cameraEffectId != null)
if if(this.worldSoundEventIndex != 0)
if if(this.playerSoundEventIndex != 0)
if if(this.worldParticles != null || this.modelParticles != null)
if if(this.cameraEffectId != null)
if if(this.staminaDrainMultiplier != 1.0F)
if if(var3 != null)
if if(this.worldParticles != null)
if if(this.worldSoundEventIndex != 0)
if if(this.modelParticles != null && this.modelParticles.length > 0)
if if(this.worldParticles != null && this.worldParticles.length > 0)
protected void processConfigvoid processConfig()
public void spawnAtEntityvoid spawnAtEntity(@Nonnull CommandBuffer<EntityStore> var1, @Nonnull Ref<EntityStore> var2)

Исходный код

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

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.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.spatial.SpatialResource;
class="kw">import com.hypixel.hytale.protocol.SoundCategory;
class="kw">import com.hypixel.hytale.server.core.asset.type.camera.CameraEffect;
class="kw">import com.hypixel.hytale.server.core.asset.type.model.config.ModelParticle;
class="kw">import com.hypixel.hytale.server.core.asset.type.particle.config.WorldParticle;
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.EntityModule;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.damage.Damage;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.ParticleUtil;
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 java.util.Arrays;
class="kw">import java.util.List;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;

class="kw">public class DamageEffects class="kw">implements NetworkSerializable<com.hypixel.hytale.protocol.DamageEffects> {
   class="kw">public class="kw">static class="kw">final BuilderCodec<DamageEffects> CODEC = BuilderCodec.builder(DamageEffects.class, DamageEffects::new)
      .appendInherited(
         new KeyedCodec<>("ModelParticles", ModelParticle.ARRAY_CODEC),
         (var0, var1) -> var0.modelParticles = var1,
         var0 -> var0.modelParticles,
         (var0, var1) -> var0.modelParticles = var1.modelParticles
      )
      .add()
      .appendInherited(
         new KeyedCodec<>("WorldParticles", WorldParticle.ARRAY_CODEC),
         (var0, var1) -> var0.worldParticles = var1,
         var0 -> var0.worldParticles,
         (var0, var1) -> var0.worldParticles = var1.worldParticles
      )
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("LocalSoundEventId", Codec.STRING),
         (var0, var1) -> var0.localSoundEventId = var1,
         var0 -> var0.localSoundEventId,
         (var0, var1) -> var0.localSoundEventId = var1.localSoundEventId
      )
      .addValidator(SoundEvent.VALIDATOR_CACHE.getValidator())
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("WorldSoundEventId", Codec.STRING),
         (var0, var1) -> var0.worldSoundEventId = var1,
         var0 -> var0.worldSoundEventId,
         (var0, var1) -> var0.worldSoundEventId = var1.worldSoundEventId
      )
      .addValidator(SoundEvent.VALIDATOR_CACHE.getValidator())
      .addValidator(SoundEventValidators.MONO)
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("PlayerSoundEventId", Codec.STRING),
         (var0, var1) -> var0.playerSoundEventId = var1,
         var0 -> var0.playerSoundEventId,
         (var0, var1) -> var0.playerSoundEventId = var1.playerSoundEventId
      )
      .addValidator(SoundEvent.VALIDATOR_CACHE.getValidator())
      .documentation("The sound to play to a player receiving the damage.")
      .add()
      .appendInherited(
         new KeyedCodec<>("ViewDistance", Codec.DOUBLE),
         (var0, var1) -> var0.viewDistance = var1,
         var0 -> var0.viewDistance,
         (var0, var1) -> var0.viewDistance = var1.viewDistance
      )
      .add()
      .appendInherited(
         new KeyedCodec<>("Knockback", Knockback.CODEC),
         (var0, var1) -> var0.knockback = var1,
         var0 -> var0.knockback,
         (var0, var1) -> var0.knockback = var1.knockback
      )
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("CameraEffect", CameraEffect.CHILD_ASSET_CODEC),
         (var0, var1) -> var0.cameraEffectId = var1,
         var0 -> var0.cameraEffectId,
         (var0, var1) -> var0.cameraEffectId = var1.cameraEffectId
      )
      .addValidator(CameraEffect.VALIDATOR_CACHE.getValidator())
      .add()
      .<Float>appendInherited(
         new KeyedCodec<>("StaminaDrainMultiplier", Codec.FLOAT),
         (var0, var1) -> var0.staminaDrainMultiplier = var1,
         var0 -> var0.staminaDrainMultiplier,
         (var0, var1) -> var0.staminaDrainMultiplier = var1.staminaDrainMultiplier
      )
      .documentation("A multiplier to apply to any stamina drain caused by this damage.")
      .add()
      .afterDecode(DamageEffects::processConfig)
      .build();
   class="kw">protected ModelParticle[] modelParticles;
   class="kw">protected WorldParticle[] worldParticles;
   @Nullable
   class="kw">protected String localSoundEventId = null;
   class="kw">protected class="kw">transient int localSoundEventIndex;
   @Nullable
   class="kw">protected String worldSoundEventId = null;
   class="kw">protected class="kw">transient int worldSoundEventIndex;
   @Nullable
   class="kw">protected String playerSoundEventId = null;
   class="kw">protected class="kw">transient int playerSoundEventIndex;
   class="kw">protected double viewDistance = 75.0;
   class="kw">protected Knockback knockback;
   class="kw">protected String cameraEffectId;
   class="kw">protected int cameraEffectIndex = Integer.MIN_VALUE;
   class="kw">protected float staminaDrainMultiplier = 1.0F;

   class="kw">public DamageEffects(ModelParticle[] var1, WorldParticle[] var2, String var3, String var4, double var5, Knockback var7) {
      this.modelParticles = var1;
      this.worldParticles = var2;
      this.localSoundEventId = var3;
      this.worldSoundEventId = var4;
      this.viewDistance = var5;
      this.knockback = var7;
      this.processConfig();
   }

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

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

   class="kw">public WorldParticle[] getWorldParticles() {
      class="kw">return this.worldParticles;
   }

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

   class="kw">public int getWorldSoundEventIndex() {
      class="kw">return this.worldSoundEventIndex;
   }

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

   class="kw">public int getLocalSoundEventIndex() {
      class="kw">return this.localSoundEventIndex;
   }

   class="kw">public double getViewDistance() {
      class="kw">return this.viewDistance;
   }

   class="kw">public Knockback getKnockback() {
      class="kw">return this.knockback;
   }

   class="kw">public String getCameraEffectId() {
      class="kw">return this.cameraEffectId;
   }

   class="kw">protected void processConfig() {
      if (this.localSoundEventId != null) {
         this.localSoundEventIndex = SoundEvent.getAssetMap().getIndex(this.localSoundEventId);
      }

      if (this.worldSoundEventId != null) {
         this.worldSoundEventIndex = SoundEvent.getAssetMap().getIndex(this.worldSoundEventId);
      }

      if (this.playerSoundEventId != null) {
         this.playerSoundEventIndex = SoundEvent.getAssetMap().getIndex(this.playerSoundEventId);
      }

      if (this.cameraEffectId != null) {
         this.cameraEffectIndex = CameraEffect.getAssetMap().getIndex(this.cameraEffectId);
      }
   }

   class="kw">public void addToDamage(@Nonnull Damage var1) {
      if (this.worldSoundEventIndex != 0) {
         var1.putMetaObject(Damage.IMPACT_SOUND_EFFECT, new Damage.SoundEffect(this.worldSoundEventIndex));
      }

      if (this.playerSoundEventIndex != 0) {
         var1.putMetaObject(Damage.PLAYER_IMPACT_SOUND_EFFECT, new Damage.SoundEffect(this.playerSoundEventIndex));
      }

      if (this.worldParticles != null || this.modelParticles != null) {
         var1.putMetaObject(Damage.IMPACT_PARTICLES, new Damage.Particles(this.modelParticles, this.worldParticles, this.viewDistance));
      }

      if (this.cameraEffectId != null) {
         var1.putMetaObject(Damage.CAMERA_EFFECT, new Damage.CameraEffect(this.cameraEffectIndex));
      }

      if (this.staminaDrainMultiplier != 1.0F) {
         var1.putMetaObject(Damage.STAMINA_DRAIN_MULTIPLIER, this.staminaDrainMultiplier);
      }
   }

   class="kw">public void spawnAtEntity(@Nonnull CommandBuffer<EntityStore> var1, @Nonnull Ref<EntityStore> var2) {
      TransformComponent var3 = var1.getComponent(var2, TransformComponent.getComponentType());
      if (var3 != null) {
         Vector3d var4 = var3.getPosition();
         if (this.worldParticles != null) {
            SpatialResource var5 = var1.getResource(EntityModule.get().getPlayerSpatialResourceType());
            List var6 = SpatialResource.getThreadLocalReferenceList();
            var5.getSpatialStructure().collect(var4, this.viewDistance, var6);
            ParticleUtil.spawnParticleEffects(this.worldParticles, var4, null, var6, var1);
         }

         PlayerRef var7 = var1.getComponent(var2, PlayerRef.getComponentType());
         if (this.worldSoundEventIndex != 0) {
            boolean var8 = var7 != null;
            SoundUtil.playSoundEvent3d(var2, this.worldSoundEventIndex, var4, var8, var1);
         }

         if (var7 != null && (this.playerSoundEventIndex != 0 || this.worldSoundEventIndex != 0)) {
            SoundUtil.playLocalPlayerSoundEvent(var7, this.playerSoundEventIndex, this.worldSoundEventIndex, SoundCategory.SFX);
         }
      }
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "DamageEffects{modelParticles="
         + Arrays.toString(this.modelParticles)
         + ", worldParticles="
         + Arrays.toString(this.worldParticles)
         + ", localSoundEventId='"
         + this.localSoundEventId
         + "', localSoundEventIndex="
         + this.localSoundEventIndex
         + ", worldSoundEventId='"
         + this.worldSoundEventId
         + "', worldSoundEventIndex="
         + this.worldSoundEventIndex
         + ", viewDistance="
         + this.viewDistance
         + ", knockback="
         + this.knockback
         + ", cameraEffectId='"
         + this.cameraEffectId
         + "'}";
   }

   @Nonnull
   class="kw">public com.hypixel.hytale.protocol.DamageEffects toPacket() {
      com.hypixel.hytale.protocol.ModelParticle[] var1 = null;
      if (this.modelParticles != null && this.modelParticles.length > 0) {
         var1 = new com.hypixel.hytale.protocol.ModelParticle[this.modelParticles.length];

         for (int var2 = 0; var2 < this.modelParticles.length; var2++) {
            var1[var2] = this.modelParticles[var2].toPacket();
         }
      }

      com.hypixel.hytale.protocol.WorldParticle[] var4 = null;
      if (this.worldParticles != null && this.worldParticles.length > 0) {
         var4 = new com.hypixel.hytale.protocol.WorldParticle[this.worldParticles.length];

         for (int var3 = 0; var3 < this.worldParticles.length; var3++) {
            var4[var3] = this.worldParticles[var3].toPacket();
         }
      }

      class="kw">return new com.hypixel.hytale.protocol.DamageEffects(var1, var4, this.localSoundEventIndex != 0 ? this.localSoundEventIndex : this.worldSoundEventIndex);
   }
}