specified conditions for creative fly controls
This commit is contained in:
1 parent
0ad542236c
commit
d35769a365
4 files changed
+71
-28
No files matched your search
@@ -584,6 +584,15 @@ public class CarpetSettings
|
||||
|
||||
@Rule(
|
||||
desc = "Creative No Clip",
|
||||
extra = {
|
||||
"On servers it needs to be set on both ",
|
||||
"client and server to function properly.",
|
||||
"Has no effect when set on the server only",
|
||||
"Can allow to phase through walls",
|
||||
"if only set on the carpet client side",
|
||||
"but requires some trapdoor magic to",
|
||||
"allow the player to enter blocks"
|
||||
},
|
||||
category = {CREATIVE, CLIENT}
|
||||
)
|
||||
public static boolean creativeNoClip = false;
|
||||
@@ -591,12 +600,22 @@ public class CarpetSettings
|
||||
|
||||
@Rule(
|
||||
desc = "Creative flying speed multiplier",
|
||||
extra = {
|
||||
"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}
|
||||
)
|
||||
public static double creativeFlySpeed = 1.0f;
|
||||
|
||||
@Rule(
|
||||
desc = "Creative air drag",
|
||||
extra = {
|
||||
"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}
|
||||
)
|
||||
public static double creativeFlyDrag = 0.91f;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
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.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
public abstract class LivingEntity_creativeFlyMixin extends Entity
|
||||
{
|
||||
@Shadow public float flyingSpeed;
|
||||
|
||||
public LivingEntity_creativeFlyMixin(EntityType<?> type, World world)
|
||||
{
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "travel", constant = @Constant(floatValue = 0.91F), expect = 2)
|
||||
private float drag(float original)
|
||||
{
|
||||
if (CarpetSettings.creativeFlyDrag != 0.91D && (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 (CarpetSettings.creativeFlySpeed != 1.0D && (Object)this instanceof PlayerEntity)
|
||||
{
|
||||
PlayerEntity self = (PlayerEntity)(Object)(this);
|
||||
if (self.abilities.flying && !onGround)
|
||||
cir.setReturnValue(flyingSpeed* (float)CarpetSettings.creativeFlySpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,6 @@ public abstract class LivingEntity_scarpetEventsMixin extends Entity implements
|
||||
|
||||
@Shadow protected boolean jumping;
|
||||
|
||||
@Shadow public float flyingSpeed;
|
||||
|
||||
public LivingEntity_scarpetEventsMixin(EntityType<?> type, World world)
|
||||
{
|
||||
super(type, world);
|
||||
@@ -52,29 +50,4 @@ public abstract class LivingEntity_scarpetEventsMixin extends Entity implements
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,8 @@
|
||||
"PistonHandler_movableTEMixin",
|
||||
"PlayerEntity_creativeNoClipMixin",
|
||||
"PistonBlockEntity_creativeNoClipMixin",
|
||||
"BlockItem_creativeNoClipMixin"
|
||||
"BlockItem_creativeNoClipMixin",
|
||||
"LivingEntity_creativeFlyMixin"
|
||||
|
||||
],
|
||||
"client": [
|
||||
|
||||
Reference in new issue
Block a user