RotateCommand.java
net.minecraft.server.commands.RotateCommand
信息
- 全限定名:net.minecraft.server.commands.RotateCommand
- 类型:public class
- 包:net.minecraft.server.commands
- 源码路径:src/main/java/net/minecraft/server/commands/RotateCommand.java
- 起始行号:L15
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) @ L16
- 方法名:register
- 源码定位:L16
- 返回类型:void
- 修饰符:public static
参数:
- dispatcher: CommandDispatcher
说明:
TODO
private static int rotate(CommandSourceStack source, Entity entity, Coordinates rotation) @ L69
- 方法名:rotate
- 源码定位:L69
- 返回类型:int
- 修饰符:private static
参数:
- source: CommandSourceStack
- entity: Entity
- rotation: Coordinates
说明:
TODO
private static int rotate(CommandSourceStack source, Entity entity, LookAt facing) @ L78
- 方法名:rotate
- 源码定位:L78
- 返回类型:int
- 修饰符:private static
参数:
- source: CommandSourceStack
- entity: Entity
- facing: LookAt
说明:
TODO
代码
public class RotateCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
dispatcher.register(
Commands.literal("rotate")
.requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS))
.then(
Commands.argument("target", EntityArgument.entity())
.then(
Commands.argument("rotation", RotationArgument.rotation())
.executes(c -> rotate(c.getSource(), EntityArgument.getEntity(c, "target"), RotationArgument.getRotation(c, "rotation")))
)
.then(
Commands.literal("facing")
.then(
Commands.literal("entity")
.then(
Commands.argument("facingEntity", EntityArgument.entity())
.executes(
c -> rotate(
c.getSource(),
EntityArgument.getEntity(c, "target"),
new LookAt.LookAtEntity(EntityArgument.getEntity(c, "facingEntity"), EntityAnchorArgument.Anchor.FEET)
)
)
.then(
Commands.argument("facingAnchor", EntityAnchorArgument.anchor())
.executes(
c -> rotate(
c.getSource(),
EntityArgument.getEntity(c, "target"),
new LookAt.LookAtEntity(
EntityArgument.getEntity(c, "facingEntity"),
EntityAnchorArgument.getAnchor(c, "facingAnchor")
)
)
)
)
)
)
.then(
Commands.argument("facingLocation", Vec3Argument.vec3())
.executes(
c -> rotate(
c.getSource(),
EntityArgument.getEntity(c, "target"),
new LookAt.LookAtPosition(Vec3Argument.getVec3(c, "facingLocation"))
)
)
)
)
)
);
}
private static int rotate(CommandSourceStack source, Entity entity, Coordinates rotation) {
Vec2 rot = rotation.getRotation(source);
float relativeOrAbsoluteYRot = rotation.isYRelative() ? rot.y - entity.getYRot() : rot.y;
float relativeOrAbsoluteXRot = rotation.isXRelative() ? rot.x - entity.getXRot() : rot.x;
entity.forceSetRotation(relativeOrAbsoluteYRot, rotation.isYRelative(), relativeOrAbsoluteXRot, rotation.isXRelative());
source.sendSuccess(() -> Component.translatable("commands.rotate.success", entity.getDisplayName()), true);
return 1;
}
private static int rotate(CommandSourceStack source, Entity entity, LookAt facing) {
facing.perform(source, entity);
source.sendSuccess(() -> Component.translatable("commands.rotate.success", entity.getDisplayName()), true);
return 1;
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Commands.argument(), Commands.hasPermission(), Commands.literal()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
EntityAnchorArgument.anchor(), EntityAnchorArgument.getAnchor()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
EntityArgument.entity(), EntityArgument.getEntity()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
RotationArgument.getRotation(), RotationArgument.rotation()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Vec3Argument.getVec3(), Vec3Argument.vec3()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Component.translatable()
- 引用位置:
-
- 引用位置:
参数/方法调用/构造调用 - 关联成员:
LookAt.LookAtEntity(), LookAt.LookAtPosition(), LookAtEntity(), LookAtPosition()
- 引用位置:
-
- 引用位置:
参数
- 引用位置: