Search in sources :

Example 1 with Vector4d

use of com.enderio.core.common.vecmath.Vector4d in project EnderIO by SleepyTrousers.

the class GliderUpgrade method onPlayerTick.

@Override
public void onPlayerTick(@Nonnull ItemStack stack, @Nonnull IDarkSteelItem item, @Nonnull EntityPlayer player) {
    if (!DarkSteelController.isGlideActive(player)) {
        return;
    }
    if (!player.onGround && player.motionY < 0 && !player.isSneaking() && !player.isInWater()) {
        double horizontalSpeed = Config.darkSteelGliderHorizontalSpeed;
        double verticalSpeed = Config.darkSteelGliderVerticalSpeed;
        if (player.isSprinting()) {
            verticalSpeed = Config.darkSteelGliderVerticalSpeedSprinting;
        }
        Vector3d look = Util.getLookVecEio(player);
        Vector3d side = new Vector3d();
        side.cross(new Vector3d(0, 1, 0), look);
        Vector3d playerPos = new Vector3d(player.prevPosX, player.prevPosY, player.prevPosZ);
        Vector3d b = new Vector3d(playerPos);
        b.y += 1;
        Vector3d c = new Vector3d(playerPos);
        c.add(side);
        Vector4d plane = new Vector4d();
        VecmathUtil.computePlaneEquation(playerPos, b, c, plane);
        double dist = Math.abs(VecmathUtil.distanceFromPointToPlane(plane, new Vector3d(player.posX, player.posY, player.posZ)));
        double minDist = 0.15;
        if (dist < minDist) {
            double dropRate = (minDist * 10) - (dist * 10);
            verticalSpeed = verticalSpeed + (verticalSpeed * dropRate * 8);
            horizontalSpeed -= (0.02 * dropRate);
        }
        double x = Math.cos(Math.toRadians(player.rotationYawHead + 90)) * horizontalSpeed;
        double z = Math.sin(Math.toRadians(player.rotationYawHead + 90)) * horizontalSpeed;
        player.motionX += x;
        player.motionZ += z;
        player.motionY = verticalSpeed;
        player.fallDistance = 0f;
    }
}
Also used : Vector4d(com.enderio.core.common.vecmath.Vector4d) Vector3d(com.enderio.core.common.vecmath.Vector3d)

Aggregations

Vector3d (com.enderio.core.common.vecmath.Vector3d)1 Vector4d (com.enderio.core.common.vecmath.Vector4d)1