summaryrefslogtreecommitdiff
path: root/src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/Waterwalk.java
blob: 7949203e8c0c089ad9f1646cc09d7b9110a822f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.arslaancodes.arslaansmagichax.modules.impl;

import com.arslaancodes.arslaansmagichax.modules.Category;
import com.arslaancodes.arslaansmagichax.modules.Module;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Blocks;

public class Waterwalk extends Module {
    public Waterwalk() {
        super("Waterwalk", "Allows you to walk on water.", -1, Category.MOVEMENT);
    }

    @Override
    public void tick() {
        if (!this.isEnabled() || mc.player == null) return;

        BlockPos blockBelow = mc.player.blockPosition().below();

        if (mc.level.getBlockState(blockBelow).is(Blocks.WATER)) {
            if (mc.player.getDeltaMovement().y < 0) {
                mc.player.setDeltaMovement(mc.player.getDeltaMovement().x, 0.0, mc.player.getDeltaMovement().z);

                if (!mc.player.isJumping()) mc.player.setPosRaw(mc.player.getX(), Math.floor(mc.player.getY()), mc.player.getZ());
            }
            mc.player.setOnGround(true);
        }
    }
}