Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
1.4 kB
2
Indexable
Never
    public static void update(Player player) {
        player.getCapability(ShinobiCapabilityHandler.SHINOBI_CAPABILITY).ifPresent(capability -> {
            if (capability.getChakraControl() && !player.isCrouching()) {
                Vec3 movement = player.getDeltaMovement();

                BlockPos keepSteadyBlockPos = new BlockPos(player.getX(), Math.round(player.getY() - 0.5D), player.getZ());
                BlockPos pushUpBlockPos = new BlockPos(player.getX(), Math.round(player.getY()), player.getZ());

                double motionY = movement.y();

                if (Minecraft.getInstance().level.getBlockState(pushUpBlockPos).is(Blocks.WATER)) {
                    motionY = 0.2D;
                }
                else if (Minecraft.getInstance().level.getBlockState(keepSteadyBlockPos).is(Blocks.WATER)) {
                    if (movement.y < 0.0D) {
                        player.resetFallDistance();
                        player.setOnGround(true);

                        if (player.isFallFlying()) {
                            player.stopFallFlying();
                        }
                        player.bob += (movement.y() - player.bob);

                        motionY = 0.0D;
                    }
                }
                player.setDeltaMovement(movement.x(), motionY, movement.z());
            }
        });
    }