Skip to content

Commit

Permalink
NoFall: Added AntiBounce option
Browse files Browse the repository at this point in the history
Disables bouncing on slime-block and bed upon landing.
  • Loading branch information
DesiCow authored and arlomcwalter committed Feb 3, 2023
1 parent f0fe2bd commit 974b0b4
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ public class NoFall extends Module {
.build()
);

private final Setting<Boolean> 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;
Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/meteor-client.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"BannerBlockEntityRendererMixin",
"BeaconBlockEntityRendererMixin",
"BeaconScreenMixin",
"BedBlockMixin",
"BiomeColorsMixin",
"BlockCollisionSpliteratorMixin",
"BlockEntityRenderDispatcherMixin",
Expand Down

0 comments on commit 974b0b4

Please sign in to comment.