diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index fe099c00..d37f3f13 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -605,18 +605,23 @@ public class CarpetSettings "having it set on the decicated server has no effect", "but this also means it will work on vanilla servers as well" }, - category = {CREATIVE, CLIENT} + category = {CREATIVE, CLIENT}, + validate = Validator.NONNEGATIVE_NUMBER.class ) - public static double creativeFlySpeed = 1.0f; + public static double creativeFlySpeed = 1.0; @Rule( desc = "Creative air drag", extra = { + "Increased drag will slow down your flight", + "So need to adjust speed accordingly", + "With 1.0 drag, using speed of 11 seems to matching vanilla speeds.", "Purely client side setting, meaning that", "having it set on the decicated server has no effect", "but this also means it will work on vanilla servers as well" }, - category = {CREATIVE, CLIENT} + category = {CREATIVE, CLIENT}, + validate = Validator.PROBABILITY.class ) - public static double creativeFlyDrag = 0.91f; + public static double creativeFlyDrag = 0.09; } diff --git a/src/main/java/carpet/mixins/LivingEntity_creativeFlyMixin.java b/src/main/java/carpet/mixins/LivingEntity_creativeFlyMixin.java index 4d1410df..c50a364c 100644 --- a/src/main/java/carpet/mixins/LivingEntity_creativeFlyMixin.java +++ b/src/main/java/carpet/mixins/LivingEntity_creativeFlyMixin.java @@ -27,11 +27,11 @@ public abstract class LivingEntity_creativeFlyMixin extends Entity @ModifyConstant(method = "travel", constant = @Constant(floatValue = 0.91F), expect = 2) private float drag(float original) { - if (CarpetSettings.creativeFlyDrag != 0.91D && (Object)this instanceof PlayerEntity) + if (CarpetSettings.creativeFlyDrag != 0.09 && (Object)this instanceof PlayerEntity) { PlayerEntity self = (PlayerEntity)(Object)(this); if (self.abilities.flying && ! onGround ) - return (float)CarpetSettings.creativeFlyDrag; + return (float)(1.0-CarpetSettings.creativeFlyDrag); } return original; } diff --git a/src/main/java/carpet/settings/Validator.java b/src/main/java/carpet/settings/Validator.java index 56bf64a0..8b561ff6 100644 --- a/src/main/java/carpet/settings/Validator.java +++ b/src/main/java/carpet/settings/Validator.java @@ -17,17 +17,6 @@ public abstract class Validator public abstract T validate(ServerCommandSource source, ParsedRule currentRule, T newValue, String string); public String description() {return null;} - public static class POSITIVE_NUMBER extends Validator - { - @Override - public T validate(ServerCommandSource source, ParsedRule currentRule, T newValue, String string) - { - return newValue.doubleValue() > 0 ? newValue : null; - } - @Override - public String description() { return "Must be a positive number"; } - } - public static class _COMMAND extends Validator { @Override @@ -119,4 +108,15 @@ public abstract class Validator @Override public String description() { return "Must be a positive number";} } + + public static class PROBABILITY extends Validator + { + @Override + public T validate(ServerCommandSource source, ParsedRule currentRule, T newValue, String string) + { + return (newValue.doubleValue() >= 0 && newValue.doubleValue() <= 1 )? newValue : null; + } + @Override + public String description() { return "Must be between 0 and 1";} + } }