HeadRotation class

Пакет: com.hypixel.hytale.server.core.modules.entity.component

Файл: com/hypixel/hytale/server/core/modules/entity/component/HeadRotation.java

implements: Component<EntityStore>

Поля (9)

МодификаторыТипИмя
final BuilderCodec<HeadRotation> CODEC
Vector3i var1
float var2
double var3
float var3
float var4
double var5
double var7
double var9

Методы (6)

МодификаторыВозвратСигнатура
abstract throw new IllegalStateExceptionthrow new IllegalStateException("Pitch can't be NaN")
abstract throw new IllegalStateExceptionthrow new IllegalStateException("Yaw can't be NaN")
static ComponentType<EntityStore, HeadRotation> getComponentTypeComponentType<EntityStore, HeadRotation> getComponentType()
public Vector3d getDirectionVector3d getDirection()
public void setRotationvoid setRotation(@Nonnull Rotation3fc var1)
public void teleportRotationvoid teleportRotation(@Nonnull Rotation3f var1)

Исходный код

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

class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.component.Component;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.math.Axis;
class="kw">import com.hypixel.hytale.math.util.TrigMathUtil;
class="kw">import com.hypixel.hytale.math.vector.Rotation3f;
class="kw">import com.hypixel.hytale.math.vector.Rotation3fc;
class="kw">import com.hypixel.hytale.math.vector.Vector3dUtil;
class="kw">import com.hypixel.hytale.server.core.modules.entity.EntityModule;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3d;
class="kw">import org.joml.Vector3i;

class="kw">public class HeadRotation class="kw">implements Component<EntityStore> {
   class="kw">public class="kw">static class="kw">final BuilderCodec<HeadRotation> CODEC = BuilderCodec.builder(HeadRotation.class, HeadRotation::new)
      .append(new KeyedCodec<>("Rotation", Rotation3f.CODEC), (var0, var1) -> var0.rotation.set(var1), var0 -> var0.rotation)
      .add()
      .build();
   class="kw">private class="kw">final Rotation3f rotation = new Rotation3f();

   class="kw">public class="kw">static ComponentType<EntityStore, HeadRotation> getComponentType() {
      class="kw">return EntityModule.get().getHeadRotationComponentType();
   }

   class="kw">public HeadRotation() {
   }

   class="kw">public HeadRotation(@Nonnull Rotation3fc var1) {
      this.rotation.set(var1);
   }

   @Nonnull
   class="kw">public Rotation3f getRotation() {
      class="kw">return this.rotation;
   }

   class="kw">public void setRotation(@Nonnull Rotation3fc var1) {
      this.rotation.set(var1);
   }

   class="kw">public Vector3d getDirection() {
      class="kw">return getDirection(this.rotation.pitch(), this.rotation.yaw(), new Vector3d());
   }

   @Nonnull
   class="kw">public Vector3i getAxisDirection() {
      class="kw">return getAxisDirection(this.rotation.pitch(), this.rotation.yaw(), new Vector3i());
   }

   @Nonnull
   class="kw">public Vector3i getAxisDirection(@Nonnull Vector3i var1) {
      class="kw">return getAxisDirection(this.rotation.pitch(), this.rotation.yaw(), var1);
   }

   @Nonnull
   class="kw">public Vector3i getHorizontalAxisDirection() {
      class="kw">return getAxisDirection(0.0F, this.rotation.yaw(), new Vector3i());
   }

   @Nonnull
   class="kw">public Axis getAxis() {
      Vector3i var1 = this.getAxisDirection();
      if (var1.x() != 0) {
         class="kw">return Axis.X;
      } else {
         class="kw">return var1.y() != 0 ? Axis.Y : Axis.Z;
      }
   }

   @Nonnull
   class="kw">public class="kw">static Vector3i getAxisDirection(float var0, float var1, @Nonnull Vector3i var2) {
      if (Float.isNaN(var0)) {
         throw new IllegalStateException("Pitch can't be NaN");
      }

      if (Float.isNaN(var1)) {
         throw new IllegalStateException("Yaw can't be NaN");
      }

      double var3 = TrigMathUtil.cos(var0);
      double var5 = var3 * -TrigMathUtil.sin(var1);
      double var7 = TrigMathUtil.sin(var0);
      double var9 = var3 * -TrigMathUtil.cos(var1);
      class="kw">return var2.set((int)Math.round(var5), (int)Math.round(var7), (int)Math.round(var9));
   }

   @Nonnull
   class="kw">private class="kw">static Vector3d getDirection(float var0, float var1, @Nonnull Vector3d var2) {
      if (Float.isNaN(var0)) {
         throw new IllegalStateException("Pitch can't be NaN");
      } else if (Float.isNaN(var1)) {
         throw new IllegalStateException("Yaw can't be NaN");
      } else {
         class="kw">return Vector3dUtil.setYawPitch(var1, var0, var2);
      }
   }

   class="kw">public void teleportRotation(@Nonnull Rotation3f var1) {
      float var2 = var1.yaw();
      if (Float.isFinite(var2)) {
         this.rotation.setYaw(var2);
      }

      float var3 = var1.pitch();
      if (Float.isFinite(var3)) {
         this.rotation.setPitch(var3);
      }

      float var4 = var1.roll();
      if (Float.isFinite(var4)) {
         this.rotation.setRoll(var4);
      }
   }

   @Nonnull
   class="kw">public HeadRotation clone() {
      class="kw">return new HeadRotation(this.rotation);
   }
}