mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 18:45:29 +01:00
Fix NumberFormatException in latest builds
This commit is contained in:
parent
af519a3af4
commit
bd8d5a7f74
@ -100,7 +100,7 @@ public class Settings {
|
||||
DEFAULT_REALISTIC_LOOKING("npc.default.realistic-looking", "npc.default.look-close.realistic-looking", false),
|
||||
DEFAULT_SPAWN_NODAMAGE_DURATION("npc.default.spawn-nodamage-ticks", "npc.default.spawn-nodamage-duration",
|
||||
"1s"),
|
||||
DEFAULT_STATIONARY_TICKS("npc.default.stationary-ticks", -1),
|
||||
DEFAULT_STATIONARY_DURATION("npc.default.stationary-ticks", "npc.default.stationary-duration", -1),
|
||||
DEFAULT_STRAIGHT_LINE_TARGETING_DISTANCE("npc.pathfinding.straight-line-targeting-distance", 5),
|
||||
DEFAULT_TALK_CLOSE("npc.default.talk-close.enabled", false),
|
||||
DEFAULT_TALK_CLOSE_RANGE("npc.default.talk-close.range", 5),
|
||||
|
@ -50,10 +50,10 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
.range(Setting.DEFAULT_PATHFINDING_RANGE.asFloat()).debug(Setting.DEBUG_PATHFINDING.asBoolean())
|
||||
.defaultAttackStrategy(MCTargetStrategy.DEFAULT_ATTACK_STRATEGY)
|
||||
.attackRange(Setting.NPC_ATTACK_DISTANCE.asDouble())
|
||||
.updatePathRate(Setting.DEFAULT_PATHFINDER_UPDATE_PATH_RATE.asInt())
|
||||
.updatePathRate(Setting.DEFAULT_PATHFINDER_UPDATE_PATH_RATE.asTicks())
|
||||
.distanceMargin(Setting.DEFAULT_DISTANCE_MARGIN.asDouble())
|
||||
.pathDistanceMargin(Setting.DEFAULT_PATH_DISTANCE_MARGIN.asDouble())
|
||||
.stationaryTicks(Setting.DEFAULT_STATIONARY_TICKS.asInt()).stuckAction(TeleportStuckAction.INSTANCE)
|
||||
.stationaryTicks(Setting.DEFAULT_STATIONARY_DURATION.asTicks()).stuckAction(TeleportStuckAction.INSTANCE)
|
||||
.examiner(new MinecraftBlockExaminer()).useNewPathfinder(Setting.USE_NEW_PATHFINDER.asBoolean())
|
||||
.straightLineTargetingDistance(Setting.DEFAULT_STRAIGHT_LINE_TARGETING_DISTANCE.asFloat())
|
||||
.destinationTeleportMargin(Setting.DEFAULT_DESTINATION_TELEPORT_MARGIN.asDouble());
|
||||
@ -236,7 +236,7 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
} else {
|
||||
root.removeKey("pathfindingrange");
|
||||
}
|
||||
if (defaultParams.stationaryTicks() != Setting.DEFAULT_STATIONARY_TICKS.asTicks()) {
|
||||
if (defaultParams.stationaryTicks() != Setting.DEFAULT_STATIONARY_DURATION.asTicks()) {
|
||||
root.setInt("stationaryticks", defaultParams.stationaryTicks());
|
||||
} else {
|
||||
root.removeKey("stationaryticks");
|
||||
|
@ -9,6 +9,7 @@ import net.citizensnpcs.api.persistence.Persist;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.TraitName;
|
||||
import net.citizensnpcs.api.util.DataKey;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.api.util.Placeholders;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
@ -35,7 +36,8 @@ public class SkinTrait extends Trait {
|
||||
private void checkPlaceholder(boolean update) {
|
||||
if (skinName == null)
|
||||
return;
|
||||
String filled = ChatColor.stripColor(Placeholders.replace(skinName, null, npc).toLowerCase());
|
||||
String filled = ChatColor.stripColor(Placeholders.replace(skinName, null, npc).toLowerCase());
|
||||
Messaging.idebug(() -> skinName + " " + filled + " " + filledPlaceholder);
|
||||
if (!filled.equalsIgnoreCase(skinName) && !filled.equalsIgnoreCase(filledPlaceholder)) {
|
||||
filledPlaceholder = filled;
|
||||
if (update) {
|
||||
|
72
main/src/main/java/net/citizensnpcs/util/Quaternion.java
Normal file
72
main/src/main/java/net/citizensnpcs/util/Quaternion.java
Normal file
@ -0,0 +1,72 @@
|
||||
package net.citizensnpcs.util;
|
||||
|
||||
import org.bukkit.util.EulerAngle;
|
||||
|
||||
public class Quaternion {
|
||||
public final double w;
|
||||
public final double x;
|
||||
public final double y;
|
||||
public final double z;
|
||||
|
||||
public Quaternion(double x, double y, double z, double w) {
|
||||
this.w = w;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public double dot(Quaternion b) {
|
||||
return x * b.x + y * b.y + z * b.z + w * b.w;
|
||||
}
|
||||
|
||||
public double length() {
|
||||
return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
|
||||
}
|
||||
|
||||
public Quaternion mul(double m) {
|
||||
return new Quaternion(x * m, y * m, z * m, w * m);
|
||||
}
|
||||
|
||||
public Quaternion norm() {
|
||||
double length = length();
|
||||
if (length > 0.0001) {
|
||||
double i = fastisqrt(length);
|
||||
return new Quaternion(i * x, i * y, i * z, i * w);
|
||||
}
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
private static double fastisqrt(double x) {
|
||||
double xhalf = 0.5d * x;
|
||||
long i = Double.doubleToLongBits(x);
|
||||
i = 0x5fe6ec85e7de30daL - (i >> 1);
|
||||
x = Double.longBitsToDouble(i);
|
||||
x *= (1.5d - xhalf * x * x);
|
||||
return x;
|
||||
}
|
||||
|
||||
public static Quaternion from(EulerAngle from) {
|
||||
return fromEuler(from.getX(), from.getY(), from.getZ());
|
||||
}
|
||||
|
||||
public static Quaternion fromEuler(double x, double y, double z) {
|
||||
double c1 = Math.cos(x * 0.5);
|
||||
double c2 = Math.cos(y * 0.5);
|
||||
double c3 = Math.cos(z * 0.5);
|
||||
double s1 = Math.sin(x * 0.5);
|
||||
double s2 = Math.sin(y * 0.5);
|
||||
double s3 = Math.sin(z * 0.5);
|
||||
return new Quaternion(s1 * s2 * c3 + c1 * c2 * s3, s1 * c2 * c3 + c1 * s2 * s3, c1 * s2 * c3 - s1 * c2 * s3,
|
||||
c1 * c2 * c3 - s1 * s2 * s3);
|
||||
}
|
||||
|
||||
public static Quaternion lerp(Quaternion a, Quaternion b, double t) {
|
||||
if (a.dot(b) < 0) {
|
||||
b = b.mul(-1);
|
||||
}
|
||||
return new Quaternion(a.x - t * (a.x - b.x), a.y - t * (a.y - b.y), a.z - t * (a.z - b.z),
|
||||
a.w - t * (a.w - b.w));
|
||||
}
|
||||
|
||||
private static final Quaternion ZERO = new Quaternion(0, 0, 0, 0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user