TeleportEffect class

Пакет: com.hypixel.hytale.builtin.triggervolumes.effect.builtin

Файл: com/hypixel/hytale/builtin/triggervolumes/effect/builtin/TeleportEffect.java

extends: TriggerEffect

Поля (12)

МодификаторыТипИмя
Ref var2
Store var3
TransformComponent var4
Vector3d var5
Rotation3f var6
var6
var6
HeadRotation var7
Teleport var8
var8
World var9
var9

Методы (11)

МодификаторыВозвратСигнатура
if if(this.position != null)
if if(var4 != null)
if if(this.relativeToEntity)
if if(this.relativeToVolume)
if if(this.useRotation)
if if(this.world != null)
if if(var9 == null)
if if(!this.resetVelocity)
if if(this.relativeToVolume && !this.relativeToEntity)
if if(this.position != null)
if if(this.useRotation)

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.triggervolumes.YawRotation;
class="kw">import com.hypixel.hytale.builtin.triggervolumes.effect.TriggerContext;
class="kw">import com.hypixel.hytale.builtin.triggervolumes.effect.TriggerEffect;
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.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.math.vector.Rotation3f;
class="kw">import com.hypixel.hytale.math.vector.Vector3dUtil;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.teleport.Teleport;
class="kw">import com.hypixel.hytale.server.core.universe.Universe;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;

class="kw">public class TeleportEffect class="kw">extends TriggerEffect {
   @Nonnull
   class="kw">private class="kw">static class="kw">final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<TeleportEffect> CODEC = BuilderCodec.builder(TeleportEffect.class, TeleportEffect::new, BASE_CODEC)
      .append(new KeyedCodec<>("Position", Vector3dUtil.CODEC), (var0, var1) -> var0.position = var1, var0 -> var0.position)
      .add()
      .append(new KeyedCodec<>("World", Codec.STRING, false), (var0, var1) -> var0.world = var1, var0 -> var0.world)
      .add()
      .append(new KeyedCodec<>("ResetVelocity", Codec.BOOLEAN, false), (var0, var1) -> var0.resetVelocity = var1, var0 -> var0.resetVelocity)
      .add()
      .append(new KeyedCodec<>("RelativeToEntity", Codec.BOOLEAN, false), (var0, var1) -> var0.relativeToEntity = var1, var0 -> var0.relativeToEntity)
      .add()
      .append(new KeyedCodec<>("RelativeToVolume", Codec.BOOLEAN, false), (var0, var1) -> var0.relativeToVolume = var1, var0 -> var0.relativeToVolume)
      .add()
      .append(new KeyedCodec<>("UseRotation", Codec.BOOLEAN, false), (var0, var1) -> var0.useRotation = var1, var0 -> var0.useRotation)
      .add()
      .append(new KeyedCodec<>("Rotation", Vector3dUtil.CODEC, false), (var0, var1) -> var0.rotation = var1, var0 -> var0.rotation)
      .add()
      .build();
   class="kw">private Vector3d position;
   @Nullable
   class="kw">private String world;
   class="kw">private boolean resetVelocity = true;
   class="kw">private boolean relativeToEntity;
   class="kw">private boolean relativeToVolume;
   class="kw">private boolean useRotation;
   @Nonnull
   class="kw">private Vector3d rotation = new Vector3d();

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

   @Override
   class="kw">public void execute(@Nonnull TriggerContext var1) {
      if (this.position != null) {
         Ref var2 = var1.getEntityRef();
         Store var3 = var1.getStore();
         TransformComponent var4 = var3.getComponent(var2, TransformComponent.getComponentType());
         if (var4 != null) {
            Vector3d var5 = new Vector3d(this.position);
            if (this.relativeToEntity) {
               if (this.relativeToVolume) {
                  ((HytaleLogger.Api)LOGGER.atWarning()).log("TeleportEffect has both RelativeToEntity and RelativeToVolume set; using RelativeToEntity");
               }

               var5.add(var4.getPosition());
            } else if (this.relativeToVolume) {
               var5.add(var1.getVolume().getPosition());
            }

            Rotation3f var6;
            if (this.useRotation) {
               var6 = toRotation(this.rotation);
            } else {
               HeadRotation var7 = var3.getComponent(var2, HeadRotation.getComponentType());
               var6 = var7 != null ? var7.getRotation() : var4.getRotation();
            }

            World var9 = null;
            if (this.world != null) {
               var9 = Universe.get().getWorld(this.world);
               if (var9 == null) {
                  ((HytaleLogger.Api)LOGGER.atWarning())
                     .log("TeleportEffect references world '%s' which is not loaded; teleporting within current world", this.world);
               }
            }

            Teleport var8 = var9 != null ? Teleport.createForPlayer(var9, var5, var6) : Teleport.createForPlayer(var5, var6);
            if (!this.resetVelocity) {
               var8 = var8.withoutVelocityReset();
            }

            var3.addComponent(var2, Teleport.getComponentType(), var8);
         }
      }
   }

   @Override
   class="kw">public void rotateInPlace(float var1, @Nonnull Vector3d var2) {
      if (this.relativeToVolume && !this.relativeToEntity) {
         if (this.position != null) {
            YawRotation.rotate(this.position, var1);
         }

         if (this.useRotation) {
            this.rotation.y = YawRotation.addDegrees((float)this.rotation.y, var1);
         }
      }
   }

   @Nonnull
   class="kw">private class="kw">static Rotation3f toRotation(@Nonnull Vector3d var0) {
      class="kw">return new Rotation3f((float)Math.toRadians(var0.y), (float)Math.toRadians(var0.x), (float)Math.toRadians(var0.z));
   }
}