Fix /player look and turn commands reversing yaw and pitch (#1689)
* Fix `/player` `look` and `turn` commands reversing yaw and pitch * Translate a comment to mojmap and update it a bit
This commit is contained in:
1 parent
e7c02ea21a
commit
591153458c
2 files changed
+16
-17
No files matched your search
@@ -87,9 +87,9 @@ public class PlayerCommand
|
|||||||
.then(argument("direction", RotationArgument.rotation())
|
.then(argument("direction", RotationArgument.rotation())
|
||||||
.executes(c -> manipulate(c, ap -> ap.look(RotationArgument.getRotation(c, "direction").getRotation(c.getSource())))))
|
.executes(c -> manipulate(c, ap -> ap.look(RotationArgument.getRotation(c, "direction").getRotation(c.getSource())))))
|
||||||
).then(literal("turn")
|
).then(literal("turn")
|
||||||
.then(literal("left").executes(c -> manipulate(c, ap -> ap.turn(-90, 0))))
|
.then(literal("left").executes(c -> manipulate(c, ap -> ap.turn(0, -90))))
|
||||||
.then(literal("right").executes(c -> manipulate(c, ap -> ap.turn(90, 0))))
|
.then(literal("right").executes(c -> manipulate(c, ap -> ap.turn(0, 90))))
|
||||||
.then(literal("back").executes(c -> manipulate(c, ap -> ap.turn(180, 0))))
|
.then(literal("back").executes(c -> manipulate(c, ap -> ap.turn(0, 180))))
|
||||||
.then(argument("rotation", RotationArgument.rotation())
|
.then(argument("rotation", RotationArgument.rotation())
|
||||||
.executes(c -> manipulate(c, ap -> ap.turn(RotationArgument.getRotation(c, "rotation").getRotation(c.getSource())))))
|
.executes(c -> manipulate(c, ap -> ap.turn(RotationArgument.getRotation(c, "rotation").getRotation(c.getSource())))))
|
||||||
).then(literal("move").executes(c -> manipulate(c, EntityPlayerActionPack::stopMovement))
|
).then(literal("move").executes(c -> manipulate(c, EntityPlayerActionPack::stopMovement))
|
||||||
|
|||||||
@@ -112,27 +112,26 @@ public class EntityPlayerActionPack
|
|||||||
}
|
}
|
||||||
public EntityPlayerActionPack look(Direction direction)
|
public EntityPlayerActionPack look(Direction direction)
|
||||||
{
|
{
|
||||||
switch (direction)
|
return switch (direction)
|
||||||
{
|
{
|
||||||
case NORTH: return look(180, 0);
|
case NORTH -> look(0, 180);
|
||||||
case SOUTH: return look(0, 0);
|
case SOUTH -> look(0, 0);
|
||||||
case EAST: return look(-90, 0);
|
case EAST -> look(0, -90);
|
||||||
case WEST: return look(90, 0);
|
case WEST -> look(0, 90);
|
||||||
case UP: return look(player.getYRot(), -90);
|
case UP -> look(-90, player.getYRot());
|
||||||
case DOWN: return look(player.getYRot(), 90);
|
case DOWN -> look(90, player.getYRot());
|
||||||
}
|
};
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
public EntityPlayerActionPack look(Vec2 rotation)
|
public EntityPlayerActionPack look(Vec2 rotation)
|
||||||
{
|
{
|
||||||
return look(rotation.x, rotation.y);
|
return look(rotation.x, rotation.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityPlayerActionPack look(float yaw, float pitch)
|
public EntityPlayerActionPack look(float pitch, float yaw)
|
||||||
{
|
{
|
||||||
player.setYRot(yaw % 360); //setYaw
|
|
||||||
player.setXRot(Mth.clamp(pitch, -90, 90)); // setPitch
|
player.setXRot(Mth.clamp(pitch, -90, 90)); // setPitch
|
||||||
// maybe player.setPositionAndAngles(player.x, player.y, player.z, yaw, MathHelper.clamp(pitch,-90.0F, 90.0F));
|
player.setYRot(yaw % 360); //setYaw
|
||||||
|
// maybe player.moveTo(player.getX(), player.getY(), player.getZ(), yaw, Mth.clamp(pitch,-90.0F, 90.0F));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,9 +141,9 @@ public class EntityPlayerActionPack
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityPlayerActionPack turn(float yaw, float pitch)
|
public EntityPlayerActionPack turn(float pitch, float yaw)
|
||||||
{
|
{
|
||||||
return look(player.getYRot() + yaw, player.getXRot() + pitch);
|
return look(player.getXRot() + pitch, player.getYRot() + yaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityPlayerActionPack turn(Vec2 rotation)
|
public EntityPlayerActionPack turn(Vec2 rotation)
|
||||||
|
|||||||
Reference in new issue
Block a user