summaryrefslogtreecommitdiff
path: root/src/main/java/net/justlearning/arslaan3102/arslaansmagichax/modules/impl/Waterwalk.java
blob: 27e4b15c326c1ce5e428b36e832d73d411b7b9db (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.block.Blocks;
import net.minecraft.util.math.BlockPos;

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.getBlockPos().down();

        if (mc.world.getBlockState(blockBelow).isOf(Blocks.WATER)) {
            if (mc.player.getVelocity().y < 0) {
                mc.player.setVelocity(mc.player.getVelocity().x, 0.0, mc.player.getVelocity().z);

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