BuilderBodyMotionTeleport class

Пакет: com.hypixel.hytale.server.npc.corecomponents.movement.builders

Файл: com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionTeleport.java

extends: BuilderBodyMotionBase

Поля (1)

МодификаторыТипИмя
final double[] DEFAULT_OFFSET_RADIUS

Методы (5)

МодификаторыВозвратСигнатура
abstract return new BodyMotionTeleportreturn new BodyMotionTeleport(this)
public double getMaxYOffsetdouble getMaxYOffset()
public double[] getOffsetRadiusdouble[] getOffsetRadius()
public BodyMotionTeleport.Orientation getOrientationBodyMotionTeleport.Orientation getOrientation()
public float getSectorRadiansfloat getSectorRadians()

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.corecomponents.movement.builders;

class="kw">import com.google.gson.JsonElement;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.BuilderDescriptorState;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.Feature;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleRangeValidator;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleSequenceValidator;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleSingleValidator;
class="kw">import com.hypixel.hytale.server.npc.corecomponents.builders.BuilderBodyMotionBase;
class="kw">import com.hypixel.hytale.server.npc.corecomponents.movement.BodyMotionTeleport;
class="kw">import com.hypixel.hytale.server.npc.instructions.BodyMotion;
class="kw">import javax.annotation.Nonnull;

class="kw">public class BuilderBodyMotionTeleport class="kw">extends BuilderBodyMotionBase {
   class="kw">public class="kw">static class="kw">final double[] DEFAULT_OFFSET_RADIUS = new double[]{0.0, 0.0};
   class="kw">protected double[] offsetRadius;
   class="kw">protected double maxYOffset;
   class="kw">protected float sector;
   class="kw">protected BodyMotionTeleport.Orientation orientation;

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

   @Nonnull
   @Override
   class="kw">public String getShortDescription() {
      class="kw">return "Teleport NPC to a position given by a sensor";
   }

   @Nonnull
   @Override
   class="kw">public String getLongDescription() {
      class="kw">return "Teleport NPC to a position given by a sensor or to a random position nearby with an optional minimum offset up to a maximum offset";
   }

   @Nonnull
   class="kw">public BodyMotion build(BuilderSupport var1) {
      class="kw">return new BodyMotionTeleport(this);
   }

   @Nonnull
   @Override
   class="kw">public BuilderDescriptorState getBuilderDescriptorState() {
      class="kw">return BuilderDescriptorState.Experimental;
   }

   @Nonnull
   class="kw">public BuilderBodyMotionTeleport readConfig(@Nonnull JsonElement var1) {
      this.getDoubleRange(
         var1,
         "OffsetRange",
         var1x -> this.offsetRadius = var1x,
         DEFAULT_OFFSET_RADIUS,
         DoubleSequenceValidator.betweenWeaklyMonotonic(0.0, Double.MAX_VALUE),
         BuilderDescriptorState.Experimental,
         "The minimum and maximum offset the NPC can be spawned from the target position",
         null
      );
      this.getDouble(
         var1,
         "MaxYOffset",
         var1x -> this.maxYOffset = var1x,
         5.0,
         DoubleSingleValidator.greater0(),
         BuilderDescriptorState.Experimental,
         "Maximum vertical offset from the target position in case of terrain obstacles",
         null
      );
      this.getFloat(
         var1,
         "OffsetSector",
         var1x -> this.sector = var1x,
         0.0F,
         DoubleRangeValidator.between(0.0, 360.0),
         BuilderDescriptorState.Experimental,
         "The sector around the target in which to teleport to",
         "The sector around the target in which to teleport to. The origin point is directly between the target and the NPC teleporting"
      );
      this.getEnum(
         var1,
         "Orientation",
         var1x -> this.orientation = var1x,
         BodyMotionTeleport.Orientation.class,
         BodyMotionTeleport.Orientation.Unchanged,
         BuilderDescriptorState.Experimental,
         "The direction to face after teleporting",
         null
      );
      this.requireFeature(Feature.AnyPosition);
      this.requireFeatureIf("Orientation", BodyMotionTeleport.Orientation.UseTarget, this.orientation, Feature.AnyEntity);
      class="kw">return this;
   }

   class="kw">public double[] getOffsetRadius() {
      class="kw">return this.offsetRadius;
   }

   class="kw">public double getMaxYOffset() {
      class="kw">return this.maxYOffset;
   }

   class="kw">public float getSectorRadians() {
      class="kw">return (float) (Math.PI / 180.0) * this.sector;
   }

   class="kw">public BodyMotionTeleport.Orientation getOrientation() {
      class="kw">return this.orientation;
   }
}