TeleportToCoordinatesCommand class
Пакет: com.hypixel.hytale.builtin.teleport.commands.teleport.variant
Файл: com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportToCoordinatesCommand.java
extends: AbstractPlayerCommand
Поля (19)
| Модификаторы | Тип | Имя |
|---|---|---|
|
Rotation3f |
var10 |
|
Coord |
var11 |
|
Coord |
var12 |
|
Coord |
var13 |
|
double |
var14 |
|
double |
var16 |
|
double |
var18 |
|
float |
var20 |
|
float |
var21 |
|
float |
var22 |
|
Teleport |
var23 |
|
boolean |
var24 |
|
float |
var25 |
|
float |
var26 |
|
float |
var27 |
|
TransformComponent |
var6 |
|
HeadRotation |
var7 |
|
Vector3d |
var8 |
|
Rotation3f |
var9 |
Методы (2)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
if if(var24) |
abstract |
|
super super("server.commands.teleport.toCoordinates.desc") |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.teleport.commands.teleport.variant;
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.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.arguments.system.OptionalArg;
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.Coord;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.types.RelativeFloat;
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.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3d;
class="kw">public class TeleportToCoordinatesCommand class="kw">extends AbstractPlayerCommand {
@Nonnull
class="kw">private class="kw">final RequiredArg<Coord> xArg = this.withRequiredArg("x", "server.commands.teleport.x.desc", ArgTypes.RELATIVE_DOUBLE_COORD)
.withSuggestionOverride(ArgTypes.RELATIVE_POSITION);
@Nonnull
class="kw">private class="kw">final RequiredArg<Coord> yArg = this.withRequiredArg("y", "server.commands.teleport.y.desc", ArgTypes.RELATIVE_DOUBLE_COORD);
@Nonnull
class="kw">private class="kw">final RequiredArg<Coord> zArg = this.withRequiredArg("z", "server.commands.teleport.z.desc", ArgTypes.RELATIVE_DOUBLE_COORD);
@Nonnull
class="kw">private class="kw">final OptionalArg<RelativeFloat> yawArg = this.withOptionalArg("yaw", "server.commands.teleport.yaw.desc", ArgTypes.RELATIVE_FLOAT);
@Nonnull
class="kw">private class="kw">final OptionalArg<RelativeFloat> pitchArg = this.withOptionalArg("pitch", "server.commands.teleport.pitch.desc", ArgTypes.RELATIVE_FLOAT);
@Nonnull
class="kw">private class="kw">final OptionalArg<RelativeFloat> rollArg = this.withOptionalArg("roll", "server.commands.teleport.roll.desc", ArgTypes.RELATIVE_FLOAT);
class="kw">public TeleportToCoordinatesCommand() {
super("server.commands.teleport.toCoordinates.desc");
this.requirePermission(HytalePermissions.fromCommand("teleport.self"));
}
@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;
HeadRotation var7 = var2.getComponent(var3, HeadRotation.getComponentType());
assert var7 != null;
Vector3d var8 = new Vector3d(var6.getPosition());
Rotation3f var9 = new Rotation3f(var7.getRotation());
Rotation3f var10 = new Rotation3f(var6.getRotation());
Coord var11 = this.xArg.get(var1);
Coord var12 = this.yArg.get(var1);
Coord var13 = this.zArg.get(var1);
double var14 = var11.resolveXZ(var8.x());
double var16 = var13.resolveXZ(var8.z());
double var18 = var12.resolveYAtWorldCoords(var8.y(), var5, var14, var16);
float var20 = this.yawArg.provided(var1) ? this.yawArg.get(var1).resolve(var9.yaw() * (180.0F / (float)Math.PI)) * (float) (Math.PI / 180.0) : Float.NaN;
float var21 = this.pitchArg.provided(var1)
? this.pitchArg.get(var1).resolve(var9.pitch() * (180.0F / (float)Math.PI)) * (float) (Math.PI / 180.0)
: Float.NaN;
float var22 = this.rollArg.provided(var1)
? this.rollArg.get(var1).resolve(var9.roll() * (180.0F / (float)Math.PI)) * (float) (Math.PI / 180.0)
: Float.NaN;
Teleport var23 = Teleport.createForPlayer(new Vector3d(var14, var18, var16), new Rotation3f(var10.pitch(), var20, var10.roll()))
.setHeadRotation(new Rotation3f(var21, var20, var22));
var2.addComponent(var3, Teleport.getComponentType(), var23);
boolean var24 = this.yawArg.provided(var1) || this.pitchArg.provided(var1) || this.rollArg.provided(var1);
if (var24) {
float var25 = Float.isNaN(var20) ? var9.yaw() * (180.0F / (float)Math.PI) : var20 * (180.0F / (float)Math.PI);
float var26 = Float.isNaN(var21) ? var9.pitch() * (180.0F / (float)Math.PI) : var21 * (180.0F / (float)Math.PI);
float var27 = Float.isNaN(var22) ? var9.roll() * (180.0F / (float)Math.PI) : var22 * (180.0F / (float)Math.PI);
var1.sendMessage(
Message.translation("server.commands.teleport.teleportedToCoordinatesWithLook")
.param("x", var14)
.param("y", var18)
.param("z", var16)
.param("yaw", var25)
.param("pitch", var26)
.param("roll", var27)
);
} else {
var1.sendMessage(Message.translation("server.commands.teleport.teleportedToCoordinates").param("x", var14).param("y", var18).param("z", var16));
}
var2.ensureAndGetComponent(var3, TeleportHistory.getComponentType())
.append(var5, var8, var9, String.format("Teleport to (%s, %s, %s)", var14, var18, var16));
}
}