untested - creativeFlySpeed, creativeFlyDrag

This commit is contained in:
gnembon committed 2020-05-07 19:16:04 -03:00
1 parent 983f24a87d
commit 0ad542236c
2 files changed
+47

No files matched your search

+14
View File
@@ -69,6 +69,7 @@ public class CarpetSettings
) )
public static int portalSurvivalDelay = 80; public static int portalSurvivalDelay = 80;
private static class OneHourMaxDelayLimit extends Validator<Integer> { private static class OneHourMaxDelayLimit extends Validator<Integer> {
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) { @Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
return (newValue > 0 && newValue <= 72000) ? newValue : null; return (newValue > 0 && newValue <= 72000) ? newValue : null;
@@ -586,4 +587,17 @@ public class CarpetSettings
category = {CREATIVE, CLIENT} category = {CREATIVE, CLIENT}
) )
public static boolean creativeNoClip = false; public static boolean creativeNoClip = false;
@Rule(
desc = "Creative flying speed multiplier",
category = {CREATIVE, CLIENT}
)
public static double creativeFlySpeed = 1.0f;
@Rule(
desc = "Creative air drag",
category = {CREATIVE, CLIENT}
)
public static double creativeFlyDrag = 0.91f;
} }
@@ -1,5 +1,6 @@
package carpet.mixins; package carpet.mixins;
import carpet.CarpetSettings;
import carpet.fakes.EntityInterface; import carpet.fakes.EntityInterface;
import carpet.fakes.LivingEntityInterface; import carpet.fakes.LivingEntityInterface;
import carpet.script.EntityEventsGroup; import carpet.script.EntityEventsGroup;
@@ -7,12 +8,17 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(LivingEntity.class) @Mixin(LivingEntity.class)
public abstract class LivingEntity_scarpetEventsMixin extends Entity implements LivingEntityInterface public abstract class LivingEntity_scarpetEventsMixin extends Entity implements LivingEntityInterface
@@ -22,6 +28,8 @@ public abstract class LivingEntity_scarpetEventsMixin extends Entity implements
@Shadow protected boolean jumping; @Shadow protected boolean jumping;
@Shadow public float flyingSpeed;
public LivingEntity_scarpetEventsMixin(EntityType<?> type, World world) public LivingEntity_scarpetEventsMixin(EntityType<?> type, World world)
{ {
super(type, world); super(type, world);
@@ -44,4 +52,29 @@ public abstract class LivingEntity_scarpetEventsMixin extends Entity implements
{ {
return jumping; return jumping;
} }
@ModifyConstant(method = "travel", constant = @Constant(floatValue = 0.91F), expect = 2)
private float drag(float original)
{
if ((Object)this instanceof PlayerEntity)
{
PlayerEntity self = (PlayerEntity)(Object)(this);
if (self.abilities.flying && !onGround)
return (float)CarpetSettings.creativeFlyDrag;
}
return original;
}
@Inject(method = "getMovementSpeed(F)F", at = @At("HEAD"), cancellable = true)
private void flyingAltSpeed(float slipperiness, CallbackInfoReturnable<Float> cir)
{
if ((Object)this instanceof PlayerEntity)
{
PlayerEntity self = (PlayerEntity)(Object)(this);
if (self.abilities.flying && !onGround)
cir.setReturnValue(flyingSpeed* (float)CarpetSettings.creativeFlySpeed);
}
}
} }