RelativeChunkPosition class

Пакет: com.hypixel.hytale.server.core.command.system.arguments.types

Файл: com/hypixel/hytale/server/core/command/system/arguments/types/RelativeChunkPosition.java

Поля (4)

МодификаторыТипИмя
int var2
Ref var3
int var3
TransformComponent var4

Методы (5)

МодификаторыВозвратСигнатура
abstract throw new GeneralCommandExceptionthrow new GeneralCommandException(MESSAGE_COMMANDS_ERRORS_RELATIVE_POSITION_ARG)
abstract throw new GeneralCommandExceptionthrow new GeneralCommandException(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD)
abstract return new Vector2ireturn new Vector2i(var2, var3)
if if(var3 == null)
public boolean isRelativeboolean isRelative()

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.command.system.arguments.types;

class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.math.util.MathUtil;
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.exceptions.GeneralCommandException;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector2i;
class="kw">import org.joml.Vector3d;

class="kw">public class RelativeChunkPosition {
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD = Message.translation("server.commands.errors.playerNotInWorld");
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_ERRORS_RELATIVE_POSITION_ARG = Message.translation("server.commands.errors.relativePositionArg");
   class="kw">private class="kw">final IntCoord x;
   class="kw">private class="kw">final IntCoord z;

   class="kw">public RelativeChunkPosition(@Nonnull IntCoord var1, @Nonnull IntCoord var2) {
      this.x = var1;
      this.z = var2;
   }

   @Nonnull
   class="kw">public Vector2i getChunkPosition(@Nonnull CommandContext var1, ComponentAccessor<EntityStore> var2) {
      Ref var3 = var1.isPlayer() ? var1.senderAsPlayerRef() : null;
      if (var3 == null) {
         if (this.isRelative()) {
            throw new GeneralCommandException(MESSAGE_COMMANDS_ERRORS_RELATIVE_POSITION_ARG);
         } else {
            class="kw">return this.getChunkPosition(new Vector3d());
         }
      } else {
         if (!var3.isValid()) {
            throw new GeneralCommandException(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD);
         }

         TransformComponent var4 = var2.getComponent(var3, TransformComponent.getComponentType());
         assert var4 != null;
         class="kw">return this.getChunkPosition(var4.getPosition());
      }
   }

   @Nonnull
   class="kw">public Vector2i getChunkPosition(@Nonnull Vector3d var1) {
      int var2 = this.x.isNotBase() ? this.x.getValue() : this.x.resolveXZ(MathUtil.floor(var1.x)) >> 5;
      int var3 = this.z.isNotBase() ? this.z.getValue() : this.z.resolveXZ(MathUtil.floor(var1.z)) >> 5;
      class="kw">return new Vector2i(var2, var3);
   }

   class="kw">public boolean isRelative() {
      class="kw">return this.x.isRelative() || this.z.isRelative();
   }
}