PrefabPathUpdateObservationAngleCommand class

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

Файл: com/hypixel/hytale/builtin/path/commands/PrefabPathUpdateObservationAngleCommand.java

extends: AbstractWorldCommand

Поля (7)

МодификаторыТипИмя
Float var4
Ref var5
var5
var5
Ref var6
Ref var7
PatrolPathMarkerEntity var8

Методы (4)

МодификаторыВозвратСигнатура
if if(var6 == null)
if if(var7 == null)
if if(var8 == null)
abstract super super("observationAngle", "server.commands.npcpath.update.observationAngle.desc")

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.path.entities.PatrolPathMarkerEntity;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
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.arguments.system.RequiredArg;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.types.EntityWrappedArg;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
class="kw">import com.hypixel.hytale.server.core.command.system.exceptions.GeneralCommandException;
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 com.hypixel.hytale.server.core.util.TargetUtil;
class="kw">import javax.annotation.Nonnull;

class="kw">public class PrefabPathUpdateObservationAngleCommand class="kw">extends AbstractWorldCommand {
   @Nonnull
   class="kw">private class="kw">final EntityWrappedArg entityIdArg = this.withOptionalArg(
      "entityId", "server.commands.npcpath.update.observationAngle.entityId.desc", ArgTypes.ENTITY_ID
   );
   @Nonnull
   class="kw">private class="kw">final RequiredArg<Float> angleArg = this.withRequiredArg("angle", "server.commands.npcpath.update.observationAngle.angle.desc", ArgTypes.FLOAT);

   class="kw">public PrefabPathUpdateObservationAngleCommand() {
      super("observationAngle", "server.commands.npcpath.update.observationAngle.desc");
   }

   @Override
   class="kw">protected void execute(@Nonnull CommandContext var1, @Nonnull World var2, @Nonnull Store<EntityStore> var3) {
      Float var4 = this.angleArg.get(var1);
      Ref var5;
      if (this.entityIdArg.provided(var1)) {
         var5 = this.entityIdArg.get(var3, var1);
      } else {
         Ref var6 = var1.senderAsPlayerRef();
         if (var6 == null) {
            throw new GeneralCommandException(Message.translation("server.commands.errors.playerOrArg").param("option", "entity"));
         }

         if (!var6.isValid()) {
            throw new GeneralCommandException(Message.translation("server.commands.errors.playerNotInWorld").param("option", "entity"));
         }

         Ref var7 = TargetUtil.getTargetEntity(var6, var3);
         if (var7 == null) {
            throw new GeneralCommandException(Message.translation("server.commands.errors.no_entity_in_view").param("option", "entity"));
         }

         var5 = var7;
      }

      PatrolPathMarkerEntity var8 = var3.getComponent(var5, PatrolPathMarkerEntity.getComponentType());
      if (var8 == null) {
         var1.sendMessage(Message.translation("server.general.entityNotFound").param("id", var5.getIndex()));
      } else {
         var8.setObservationAngle(var4 * (float) (Math.PI / 180.0));
         var8.markNeedsSave();
      }
   }
}