| 1 | package com.jellypudding.offlineclient.modules.movement;
|
| 2 |
|
| 3 | import com.jellypudding.offlineclient.event.Subscribe;
|
| 4 | import com.jellypudding.offlineclient.event.events.TickEvent;
|
| 5 | import com.jellypudding.offlineclient.module.Category;
|
| 6 | import com.jellypudding.offlineclient.module.Module;
|
| 7 | import com.jellypudding.offlineclient.modules.misc.Timer;
|
| 8 | import com.jellypudding.offlineclient.setting.EnumSetting;
|
| 9 | import com.jellypudding.offlineclient.setting.NumberSetting;
|
| 10 | import net.minecraft.world.level.block.Blocks;
|
| 11 | import net.minecraft.world.level.block.PowderSnowBlock;
|
| 12 | import net.minecraft.world.phys.Vec3;
|
| 13 |
|
| 14 | public final class QuickClimb extends Module {
|
| 15 |
|
| 16 | public enum Mode { VELOCITY, TIMER }
|
| 17 |
|
| 18 | private static final String TIMER_KEY = "quickclimb";
|
| 19 |
|
| 20 | private final EnumSetting<Mode> mode = new EnumSetting<>("Mode",
|
| 21 | "How the climb is sped up.", Mode.VELOCITY)
|
| 22 | .describe(Mode.VELOCITY, "Sets your climbing speed straight to the value below.")
|
| 23 | .describe(Mode.TIMER, "Speeds the whole game up whilst you climb.");
|
| 24 | private final NumberSetting speed = new NumberSetting("Speed",
|
| 25 | "How fast you climb in blocks a tick. Vanilla is 0.2.", 0.3, 0.15, 2, 0.05, " blocks")
|
| 26 | .under(mode, Mode.VELOCITY);
|
| 27 | private final NumberSetting timer = new NumberSetting("Timer",
|
| 28 | "Game speed whilst climbing. 1 does nothing.", 1.44, 1, 3, 0.01, "x")
|
| 29 | .min(1).under(mode, Mode.TIMER);
|
| 30 |
|
| 31 | public QuickClimb() {
|
| 32 | super("QuickClimb", "Climb ladders and vines and powder snow much faster.", Category.MOVEMENT);
|
| 33 | addSettings(mode, speed, timer);
|
| 34 | }
|
| 35 |
|
| 36 | @Override
|
| 37 | public String getSuffix() {
|
| 38 | return mode.getValueString();
|
| 39 | }
|
| 40 |
|
| 41 | @Override
|
| 42 | protected void onDisable() {
|
| 43 | Timer.override(TIMER_KEY, 1f);
|
| 44 | }
|
| 45 |
|
| 46 | @Subscribe
|
| 47 | private void onTick(TickEvent event) {
|
| 48 | boolean climbing = inGame() && climbing();
|
| 49 | if (mode.is(Mode.TIMER)) {
|
| 50 | Timer.override(TIMER_KEY, climbing ? timer.getFloat() : 1f);
|
| 51 | return;
|
| 52 | }
|
| 53 | Timer.override(TIMER_KEY, 1f);
|
| 54 | if (!climbing) {
|
| 55 | return;
|
| 56 | }
|
| 57 | Vec3 velocity = mc.player.getDeltaMovement();
|
| 58 | mc.player.setDeltaMovement(velocity.x, speed.getValue(), velocity.z);
|
| 59 | }
|
| 60 |
|
| 61 | // Vanilla climbs whilst pushing into the ladder or holding jump.
|
| 62 | // Leather boots make powder snow climbable the same way.
|
| 63 | private boolean climbing() {
|
| 64 | if (!mc.player.horizontalCollision && !mc.options.keyJump.isDown()) {
|
| 65 | return false;
|
| 66 | }
|
| 67 | if (mc.player.onClimbable()) {
|
| 68 | return true;
|
| 69 | }
|
| 70 | return mc.player.getInBlockState().is(Blocks.POWDER_SNOW)
|
| 71 | && PowderSnowBlock.canEntityWalkOnPowderSnow(mc.player);
|
| 72 | }
|
| 73 | }
|
| 74 |
|