mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
fix mix check
This commit is contained in:
parent
2efefe25b3
commit
8e5d2f0dfe
@ -10,6 +10,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static net.minestom.server.utils.location.RelativeVec.CoordinateType.*;
|
||||
|
||||
/**
|
||||
* Common interface for all the relative location arguments.
|
||||
*/
|
||||
@ -44,7 +46,7 @@ abstract class ArgumentRelativeVec extends Argument<RelativeVec> {
|
||||
|
||||
double[] coordinates = new double[split.length];
|
||||
boolean[] isRelative = new boolean[split.length];
|
||||
var type = RelativeVec.CoordinateType.UNDEFINED;
|
||||
var type = UNDEFINED;
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
final String element = split[i];
|
||||
try {
|
||||
@ -52,9 +54,9 @@ abstract class ArgumentRelativeVec extends Argument<RelativeVec> {
|
||||
if (MODIFIER_CHARS.contains(modifierChar)) {
|
||||
isRelative[i] = true;
|
||||
|
||||
if (type == RelativeVec.CoordinateType.UNDEFINED) {
|
||||
type = modifierChar == LOCAL_CHAR ? RelativeVec.CoordinateType.LOCAL : RelativeVec.CoordinateType.RELATIVE;
|
||||
} else if (type != (modifierChar == LOCAL_CHAR ? RelativeVec.CoordinateType.LOCAL : RelativeVec.CoordinateType.RELATIVE)) {
|
||||
if (type == UNDEFINED) {
|
||||
type = modifierChar == LOCAL_CHAR ? LOCAL : RELATIVE;
|
||||
} else if (type != (modifierChar == LOCAL_CHAR ? LOCAL : RELATIVE)) {
|
||||
throw new ArgumentSyntaxException("Cannot mix world & local coordinates (everything must either use ^ or not)", input, MIXED_TYPE_ERROR);
|
||||
}
|
||||
|
||||
@ -63,6 +65,11 @@ abstract class ArgumentRelativeVec extends Argument<RelativeVec> {
|
||||
coordinates[i] = getRelativeNumberParser().apply(potentialNumber).doubleValue();
|
||||
}
|
||||
} else {
|
||||
if (type == UNDEFINED) {
|
||||
type = ABSOLUTE;
|
||||
} else if (type == LOCAL) {
|
||||
throw new ArgumentSyntaxException("Cannot mix world & local coordinates (everything must either use ^ or not)", input, MIXED_TYPE_ERROR);
|
||||
}
|
||||
coordinates[i] = getAbsoluteNumberParser().apply(element).doubleValue();
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
|
@ -123,11 +123,10 @@ public final class RelativeVec {
|
||||
double double14 = dna11.x() * local.z() + dna12.x() * local.y() + dna13.x() * local.x();
|
||||
double double16 = dna11.y() * local.z() + dna12.y() * local.y() + dna13.y() * local.x();
|
||||
double double18 = dna11.z() * local.z() + dna12.z() * local.y() + dna13.z() * local.x();
|
||||
return new Vec(double14 + (relativeX ? origin.x() : 0),
|
||||
double16 + (relativeY ? origin.y() : 0),
|
||||
double18 + (relativeZ ? origin.z() : 0));
|
||||
return new Vec(double14 + origin.x(),double16 + origin.y(),double18 + origin.z());
|
||||
}),
|
||||
UNDEFINED((vec, origin, relativeX, relativeY, relativeZ) -> vec);
|
||||
ABSOLUTE(((vec, origin, relativeX1, relativeY1, relativeZ1) -> vec)),
|
||||
UNDEFINED((vec, origin, relativeX, relativeY, relativeZ) -> Vec.ZERO);
|
||||
|
||||
private final CoordinateConverter converter;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user