From 974b0b413b43e7e71cfb871373f6017aa6cc5f98 Mon Sep 17 00:00:00 2001 From: DesiCow Date: Fri, 3 Feb 2023 20:39:34 +0530 Subject: [PATCH] NoFall: Added AntiBounce option Disables bouncing on slime-block and bed upon landing. --- .../meteorclient/mixin/BedBlockMixin.java | 25 +++++++++++++++++++ .../meteorclient/mixin/SlimeBlockMixin.java | 6 +++++ .../systems/modules/movement/NoFall.java | 11 ++++++++ src/main/resources/meteor-client.mixins.json | 1 + 4 files changed, 43 insertions(+) create mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/BedBlockMixin.java diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/BedBlockMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/BedBlockMixin.java new file mode 100644 index 0000000000..f53340d819 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/BedBlockMixin.java @@ -0,0 +1,25 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.movement.NoFall; +import net.minecraft.block.BedBlock; +import net.minecraft.entity.Entity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import static meteordevelopment.meteorclient.MeteorClient.mc; + +@Mixin(BedBlock.class) +public class BedBlockMixin { + @Inject(method = "bounceEntity", at = @At("HEAD"), cancellable = true) + private void onBounceEntity(Entity entity, CallbackInfo info) { + if (Modules.get().get(NoFall.class).cancelBounce() && entity == mc.player) info.cancel(); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/SlimeBlockMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/SlimeBlockMixin.java index 27a0d7455e..89faf7390b 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/SlimeBlockMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/SlimeBlockMixin.java @@ -6,6 +6,7 @@ package meteordevelopment.meteorclient.mixin; import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.movement.NoFall; import meteordevelopment.meteorclient.systems.modules.movement.NoSlow; import net.minecraft.block.BlockState; import net.minecraft.block.SlimeBlock; @@ -25,4 +26,9 @@ public class SlimeBlockMixin { private void onSteppedOn(World world, BlockPos pos, BlockState state, Entity entity, CallbackInfo info) { if (Modules.get().get(NoSlow.class).slimeBlock() && entity == mc.player) info.cancel(); } + + @Inject(method = "bounce", at = @At("HEAD"), cancellable = true) + private void onBounce(Entity entity, CallbackInfo info) { + if (Modules.get().get(NoFall.class).cancelBounce() && entity == mc.player) info.cancel(); + } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java index 821d3e6edc..6bc05b35bb 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java @@ -82,6 +82,13 @@ public class NoFall extends Module { .build() ); + private final Setting antiBounce = sgGeneral.add(new BoolSetting.Builder() + .name("anti-bounce") + .description("Disables bouncing on slime-block and bed upon landing.") + .defaultValue(true) + .build() + ); + private boolean placedWater; private BlockPos targetPos; private int timer; @@ -184,6 +191,10 @@ else if (mode.get() == Mode.Place) { } } + public boolean cancelBounce() { + return isActive() && antiBounce.get(); + } + private void useItem(FindItemResult item, boolean placedWater, BlockPos blockPos, boolean interactItem) { if (!item.found()) return; diff --git a/src/main/resources/meteor-client.mixins.json b/src/main/resources/meteor-client.mixins.json index 0aa5e1c57d..3d58689c99 100644 --- a/src/main/resources/meteor-client.mixins.json +++ b/src/main/resources/meteor-client.mixins.json @@ -16,6 +16,7 @@ "BannerBlockEntityRendererMixin", "BeaconBlockEntityRendererMixin", "BeaconScreenMixin", + "BedBlockMixin", "BiomeColorsMixin", "BlockCollisionSpliteratorMixin", "BlockEntityRenderDispatcherMixin",