ParticleAttractor class

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

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

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

Поля (2)

МодификаторыТипИмя
final BuilderCodec<ParticleAttractor> CODEC
com.hypixel.hytale.protocol.ParticleAttractor var1

Методы (16)

МодификаторыВозвратСигнатура
public Vector3f getDampingMultiplierVector3f getDampingMultiplier()
public Vector3f getLinearAccelerationVector3f getLinearAcceleration()
public Vector3f getLinearImpulseVector3f getLinearImpulse()
public Vector3f getPositionVector3f getPosition()
public float getRadialAccelerationfloat getRadialAcceleration()
public Vector3f getRadialAxisVector3f getRadialAxis()
public float getRadialImpulsefloat getRadialImpulse()
public float getRadialTangentAccelerationfloat getRadialTangentAcceleration()
public float getRadialTangentImpulsefloat getRadialTangentImpulse()
public float getRadiusfloat getRadius()
public float getTrailPositionMultiplierfloat getTrailPositionMultiplier()
if if(this.position != null)
if if(this.radialAxis != null)
if if(this.linearAcceleration != null)
if if(this.linearImpulse != null)
if if(this.dampingMultiplier != null)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.asset.type.particle.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.UIPropertyTitle;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.math.vector.Vector3fUtil;
class="kw">import com.hypixel.hytale.server.core.io.NetworkSerializable;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3f;

class="kw">public class ParticleAttractor class="kw">implements NetworkSerializable<com.hypixel.hytale.protocol.ParticleAttractor> {
   class="kw">public class="kw">static class="kw">final BuilderCodec<ParticleAttractor> CODEC = BuilderCodec.builder(ParticleAttractor.class, ParticleAttractor::new)
      .append(new KeyedCodec<>("Position", Vector3fUtil.CODEC), (var0, var1) -> var0.position = var1, var0 -> var0.position)
      .metadata(new UIPropertyTitle("Position Offset"))
      .documentation(
         "Attractors are used both in `ParticleSpawner` and `ParticleSystem` so depending where they are used they may have a different explanation:\n\nSpawner:\n    Offsets the centre of the `Attractor` from the centre of the `ParticleSpawner`.\n\nSystem:\n    Offsets the centre of the `Attractor` from the centre of the `ParticleSpawnerGroup`."
      )
      .add()
      .<Vector3f>append(new KeyedCodec<>("RadialAxis", Vector3fUtil.CODEC), (var0, var1) -> var0.radialAxis = var1, var0 -> var0.radialAxis)
      .documentation(
         "Sets an axis for the radial motion. Values can be mixed to change the direction of the axis. You can think of it as defining another position in a coordinate system originating from the centre of the attractor and then drawing a line through this origin and the newly defined point.\n\nE.g.: If the x and y value is 1 it is exactly between the class="kw">default x and y axis. If x = 2 and y = 1 the axis is 1/3 towards the y and 2/3 towards the x axis.\n\n`RadialImpulse` can work without axis perfectly fine, while `RadialTangentAcceleration` and `RadialTangentImpulse` can cause some interesting effects."
      )
      .add()
      .<Float>append(
         new KeyedCodec<>("TrailPositionMultiplier", Codec.FLOAT), (var0, var1) -> var0.trailPositionMultiplier = var1, var0 -> var0.trailPositionMultiplier
      )
      .addValidator(Validators.range(0.0F, 1.0F))
      .documentation(
         "Attractors are used both in `ParticleSpawner` and `ParticleSystem` so depending where they are used they may have a different explanation:\n\nSpawner (Advanced, rarely used):\n    Defines how strong the attractor keeps its position, while the spawner gets moved. This movement for the attractor is individual for each particle,    so the movement of the attractor is only stopped, when the particle gets spawned.\n\n    E.g.: The spawner moves with speed 1 towards +x and every 0.5 seconds a field of particles (1 x and 1 z max spawn offset) get spawned.    The attractor has a `TrailPositionMultiplier` of 1 (no movement) and a `RadialImpulse` of -1 (movement towards the axis) and a `RadialAxis` y of 1.    The first wave spawns at the starting position of the spawner and all the particles move towards the centre, while not following the motion of the spawner.\n    The particles for the second wave would spawn with 0.5 +x offset from the prior wave, since the spawner moved, but the particles don't move now to the same place the first wave moved.     They now move like the first wave to the centre of their own position, but yet again, don't get dragged with the continued motion of the spawner.\n    The third wave now has 1 +x offset and acts like the second wave.\n    If the `TrailPositionMultiplier` were 0.5, the particles would move half the speed with the spawner, since the attractor would move half the distance with the spawner     and thus the centre the particles move towards gets moved with it.\n\nBoth:\n    0.0: Moves fully with its anchor.\n    0.5: Moves half the distance with its anchor.\n    1.0: Does not move with its anchor."
      )
      .add()
      .<Float>append(new KeyedCodec<>("Radius", Codec.FLOAT), (var0, var1) -> var0.radius = var1, var0 -> var0.radius)
      .metadata(new UIPropertyTitle("Effective Radius"))
      .documentation("Defines how far the attractor takes effect. Leave empty for infinite range.")
      .add()
      .<Float>append(new KeyedCodec<>("RadialAcceleration", Codec.FLOAT), (var0, var1) -> var0.radialAcceleration = var1, var0 -> var0.radialAcceleration)
      .documentation("Defines the acceleration away from (positive) or towards (negative) the `RadialAxis` (if no axis: the attractor centre).")
      .add()
      .<Float>append(
         new KeyedCodec<>("RadialTangentAcceleration", Codec.FLOAT),
         (var0, var1) -> var0.radialTangentAcceleration = var1,
         var0 -> var0.radialTangentAcceleration
      )
      .documentation(
         "Defines the acceleration of rotation around the `RadialAxis`. High speed values will cause it to expand.\n\nPositive: clockwise\nNegative: anti-clockwise"
      )
      .add()
      .<Vector3f>append(
         new KeyedCodec<>("LinearAcceleration", Vector3fUtil.CODEC), (var0, var1) -> var0.linearAcceleration = var1, var0 -> var0.linearAcceleration
      )
      .documentation("Lets you define the acceleration along the x,y and z-Axis.\n\n+x: East\n-x: West\n\n+y: Up\n-y: Down\n\n+z: South\n-z: North")
      .add()
      .<Float>append(new KeyedCodec<>("RadialImpulse", Codec.FLOAT), (var0, var1) -> var0.radialImpulse = var1, var0 -> var0.radialImpulse)
      .documentation(
         "Defines a constant speed away from (positive) or towards (negative) the `RadialAxis` (if no axis: the attractor centre). Applied while the particle is inside the effective radius."
      )
      .add()
      .<Float>append(new KeyedCodec<>("RadialTangentImpulse", Codec.FLOAT), (var0, var1) -> var0.radialTangentImpulse = var1, var0 -> var0.radialTangentImpulse)
      .documentation(
         "Defines a constant rotation speed around the `RadialAxis`, applied while the particle is inside the effective radius. High speed values will cause it to expand.\n\nPositive: clockwise\nNegative: anti-clockwise"
      )
      .add()
      .<Vector3f>append(new KeyedCodec<>("LinearImpulse", Vector3fUtil.CODEC), (var0, var1) -> var0.linearImpulse = var1, var0 -> var0.linearImpulse)
      .documentation(
         "Lets you define a constant speed along the x,y and z-Axis, applied while the particle is inside the effective radius.\n\n+x: East\n-x: West\n\n+y: Up\n-y: Down\n\n+z: South\n-z: North"
      )
      .add()
      .<Vector3f>append(
         new KeyedCodec<>("DampingMultiplier", Vector3fUtil.CODEC), (var0, var1) -> var0.dampingMultiplier = var1, var0 -> var0.dampingMultiplier
      )
      .documentation(
         "Attractors are used both in `ParticleSpawner` and `ParticleSystem` so depending where they are used they may have a different explanation:\n\nSpawner:\n    Defines the slowdown of the `Particles`. Used for air resistance. A value of 1 applies no damping,     while values above 1 speed the particles up. If at least one value is defined, you should set the others too,     since they will be treated as 0, if left undefined. Impulses from attractors are not affected, while `InitialVelocity` is affected.\n\nSystem:\n    Defines the slowdown of the `ParticleSpawner`."
      )
      .add()
      .build();
   class="kw">protected Vector3f position;
   class="kw">protected Vector3f radialAxis;
   class="kw">protected float trailPositionMultiplier;
   class="kw">protected float radius;
   class="kw">protected float radialAcceleration;
   class="kw">protected float radialTangentAcceleration;
   class="kw">protected Vector3f linearAcceleration;
   class="kw">protected float radialImpulse;
   class="kw">protected float radialTangentImpulse;
   class="kw">protected Vector3f linearImpulse;
   class="kw">protected Vector3f dampingMultiplier;

   class="kw">public ParticleAttractor(
      Vector3f var1, Vector3f var2, float var3, float var4, float var5, float var6, Vector3f var7, float var8, float var9, Vector3f var10, Vector3f var11
   ) {
      this.position = var1;
      this.radialAxis = var2;
      this.trailPositionMultiplier = var3;
      this.radius = var4;
      this.radialAcceleration = var5;
      this.radialTangentAcceleration = var6;
      this.linearAcceleration = var7;
      this.radialImpulse = var8;
      this.radialTangentImpulse = var9;
      this.linearImpulse = var10;
      this.dampingMultiplier = var11;
   }

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

   class="kw">public Vector3f getPosition() {
      class="kw">return this.position;
   }

   class="kw">public Vector3f getRadialAxis() {
      class="kw">return this.radialAxis;
   }

   class="kw">public float getTrailPositionMultiplier() {
      class="kw">return this.trailPositionMultiplier;
   }

   class="kw">public float getRadius() {
      class="kw">return this.radius;
   }

   class="kw">public float getRadialAcceleration() {
      class="kw">return this.radialAcceleration;
   }

   class="kw">public float getRadialTangentAcceleration() {
      class="kw">return this.radialTangentAcceleration;
   }

   class="kw">public Vector3f getLinearAcceleration() {
      class="kw">return this.linearAcceleration;
   }

   class="kw">public float getRadialImpulse() {
      class="kw">return this.radialImpulse;
   }

   class="kw">public float getRadialTangentImpulse() {
      class="kw">return this.radialTangentImpulse;
   }

   class="kw">public Vector3f getLinearImpulse() {
      class="kw">return this.linearImpulse;
   }

   class="kw">public Vector3f getDampingMultiplier() {
      class="kw">return this.dampingMultiplier;
   }

   @Nonnull
   class="kw">public com.hypixel.hytale.protocol.ParticleAttractor toPacket() {
      com.hypixel.hytale.protocol.ParticleAttractor var1 = new com.hypixel.hytale.protocol.ParticleAttractor();
      if (this.position != null) {
         var1.position = this.position;
      }

      if (this.radialAxis != null) {
         var1.radialAxis = this.radialAxis;
      }

      var1.trailPositionMultiplier = this.trailPositionMultiplier;
      var1.radius = this.radius;
      var1.radialAcceleration = this.radialAcceleration;
      var1.radialTangentAcceleration = this.radialTangentAcceleration;
      if (this.linearAcceleration != null) {
         var1.linearAcceleration = this.linearAcceleration;
      }

      var1.radialImpulse = this.radialImpulse;
      var1.radialTangentImpulse = this.radialTangentImpulse;
      if (this.linearImpulse != null) {
         var1.linearImpulse = this.linearImpulse;
      }

      if (this.dampingMultiplier != null) {
         var1.dampingMultiplier = this.dampingMultiplier;
      }

      class="kw">return var1;
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "ParticleAttractor{position="
         + this.position
         + ", radialAxis="
         + this.radialAxis
         + ", trailPositionMultiplier="
         + this.trailPositionMultiplier
         + ", radius="
         + this.radius
         + ", radialAcceleration="
         + this.radialAcceleration
         + ", radialTangentAcceleration="
         + this.radialTangentAcceleration
         + ", linearAcceleration="
         + this.linearAcceleration
         + ", radialImpulse="
         + this.radialImpulse
         + ", radialTangentImpulse="
         + this.radialTangentImpulse
         + ", linearImpulse="
         + this.linearImpulse
         + ", dampingMultiplier="
         + this.dampingMultiplier
         + "}";
   }
}