TeleportTopCommand class

Пакет: com.hypixel.hytale.builtin.teleport.commands.teleport

Файл: com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportTopCommand.java

extends: AbstractPlayerCommand

Поля (9)

МодификаторыТипИмя
Ref var10
WorldChunk var11
HeadRotation var12
Rotation3f var13
int var14
TransformComponent var6
Vector3d var7
ChunkStore var8
Store var9

Методы (2)

МодификаторыВозвратСигнатура
if if(var11 == null)
abstract super super("top", "server.commands.top.desc")

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.teleport.components.TeleportHistory;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.math.util.ChunkUtil;
class="kw">import com.hypixel.hytale.math.util.MathUtil;
class="kw">import com.hypixel.hytale.math.vector.Rotation3f;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.command.system.CommandContext;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
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.permissions.HytalePermissions;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
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">public class TeleportTopCommand class="kw">extends AbstractPlayerCommand {
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_TELEPORT_TOP_CHUNK_NOT_LOADED_AT_POS = Message.translation("server.commands.teleport.top.chunkNotLoadedAtPos");
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_TOP = Message.translation("server.commands.teleport.teleportedToTop");
   class="kw">private class="kw">static class="kw">final String TELEPORT_HISTORY_KEY = "Underground";

   class="kw">public TeleportTopCommand() {
      super("top", "server.commands.top.desc");
      this.requirePermission(HytalePermissions.fromCommand("teleport.top"));
   }

   @Override
   class="kw">protected void execute(
      @Nonnull CommandContext var1, @Nonnull Store<EntityStore> var2, @Nonnull Ref<EntityStore> var3, @Nonnull PlayerRef var4, @Nonnull World var5
   ) {
      TransformComponent var6 = var2.getComponent(var3, TransformComponent.getComponentType());
      assert var6 != null;
      Vector3d var7 = var6.getPosition();
      ChunkStore var8 = var5.getChunkStore();
      Store var9 = var8.getStore();
      Ref var10 = var8.getChunkReference(ChunkUtil.indexChunkFromBlock(var7.x(), var7.z()));
      if (var10 != null && var10.isValid()) {
         WorldChunk var11 = var9.getComponent(var10, WorldChunk.getComponentType());
         if (var11 == null) {
            var1.sendMessage(MESSAGE_COMMANDS_TELEPORT_TOP_CHUNK_NOT_LOADED_AT_POS);
         } else {
            HeadRotation var12 = var2.getComponent(var3, HeadRotation.getComponentType());
            assert var12 != null;
            Rotation3f var13 = new Rotation3f(var12.getRotation());
            int var14 = var11.getHeight(MathUtil.floor(var7.x()), MathUtil.floor(var7.z()));
            var2.ensureAndGetComponent(var3, TeleportHistory.getComponentType()).append(var5, new Vector3d(var7), new Rotation3f(var13), "Underground");
            var2.addComponent(var3, Teleport.getComponentType(), Teleport.createForPlayer(new Vector3d(var7.x(), var14 + 2, var7.z()), Rotation3f.NaN));
            var1.sendMessage(MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_TOP);
         }
      } else {
         var1.sendMessage(MESSAGE_COMMANDS_TELEPORT_TOP_CHUNK_NOT_LOADED_AT_POS);
      }
   }
}