validators to creative movement controls
This commit is contained in:
1 parent
a4750f7238
commit
9afd1f3211
3 files changed
+22
-17
No files matched your search
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -17,17 +17,6 @@ public abstract class Validator<T>
|
||||
public abstract T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string);
|
||||
public String description() {return null;}
|
||||
|
||||
public static class POSITIVE_NUMBER<T extends Number> extends Validator<T>
|
||||
{
|
||||
@Override
|
||||
public T validate(ServerCommandSource source, ParsedRule<T> 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<T> extends Validator<T>
|
||||
{
|
||||
@Override
|
||||
@@ -119,4 +108,15 @@ public abstract class Validator<T>
|
||||
@Override
|
||||
public String description() { return "Must be a positive number";}
|
||||
}
|
||||
|
||||
public static class PROBABILITY <T extends Number> extends Validator<T>
|
||||
{
|
||||
@Override
|
||||
public T validate(ServerCommandSource source, ParsedRule<T> 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";}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user