diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index e7c7a5f6..fe099c00 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -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; diff --git a/src/main/java/carpet/mixins/LivingEntity_creativeFlyMixin.java b/src/main/java/carpet/mixins/LivingEntity_creativeFlyMixin.java new file mode 100644 index 00000000..4d1410df --- /dev/null +++ b/src/main/java/carpet/mixins/LivingEntity_creativeFlyMixin.java @@ -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 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); + } + } +} diff --git a/src/main/java/carpet/mixins/LivingEntity_scarpetEventsMixin.java b/src/main/java/carpet/mixins/LivingEntity_scarpetEventsMixin.java index 5d30edac..57eeaa7a 100644 --- a/src/main/java/carpet/mixins/LivingEntity_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/LivingEntity_scarpetEventsMixin.java @@ -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 cir) - { - if ((Object)this instanceof PlayerEntity) - { - PlayerEntity self = (PlayerEntity)(Object)(this); - if (self.abilities.flying && !onGround) - cir.setReturnValue(flyingSpeed* (float)CarpetSettings.creativeFlySpeed); - } - } } diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index f8e4b733..46ccfed2 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -159,7 +159,8 @@ "PistonHandler_movableTEMixin", "PlayerEntity_creativeNoClipMixin", "PistonBlockEntity_creativeNoClipMixin", - "BlockItem_creativeNoClipMixin" + "BlockItem_creativeNoClipMixin", + "LivingEntity_creativeFlyMixin" ], "client": [