Search in sources :

Example 6 with Vec3D

use of net.minecraft.server.v1_12_R1.Vec3D in project Citizens2 by CitizensDev.

the class PlayerNavigation method a.

@Override
public boolean a(PathEntity paramPathEntity, double paramDouble) {
    if (paramPathEntity == null) {
        this.c = null;
        return false;
    }
    if (!paramPathEntity.a(this.c)) {
        this.c = paramPathEntity;
    }
    q_();
    if (this.c.d() <= 0) {
        return false;
    }
    this.d = paramDouble;
    Vec3D localVec3D = c();
    this.j = this.e;
    this.k = localVec3D;
    return true;
}
Also used : Vec3D(net.minecraft.server.v1_12_R1.Vec3D)

Example 7 with Vec3D

use of net.minecraft.server.v1_12_R1.Vec3D in project Citizens2 by CitizensDev.

the class PlayerNavigation method a.

@Override
protected boolean a(Vec3D paramVec3D1, Vec3D paramVec3D2, int paramInt1, int paramInt2, int paramInt3) {
    int j = MathHelper.floor(paramVec3D1.x);
    int k = MathHelper.floor(paramVec3D1.z);
    double d1 = paramVec3D2.x - paramVec3D1.x;
    double d2 = paramVec3D2.z - paramVec3D1.z;
    double d3 = d1 * d1 + d2 * d2;
    if (d3 < 1.0E-8D) {
        return false;
    }
    double d4 = 1.0D / Math.sqrt(d3);
    d1 *= d4;
    d2 *= d4;
    paramInt1 += 2;
    paramInt3 += 2;
    if (!a(j, (int) paramVec3D1.y, k, paramInt1, paramInt2, paramInt3, paramVec3D1, d1, d2)) {
        return false;
    }
    paramInt1 -= 2;
    paramInt3 -= 2;
    double d5 = 1.0D / Math.abs(d1);
    double d6 = 1.0D / Math.abs(d2);
    double d7 = j - paramVec3D1.x;
    double d8 = k - paramVec3D1.z;
    if (d1 >= 0.0D) {
        d7 += 1.0D;
    }
    if (d2 >= 0.0D) {
        d8 += 1.0D;
    }
    d7 /= d1;
    d8 /= d2;
    int m = d1 < 0.0D ? -1 : 1;
    int n = d2 < 0.0D ? -1 : 1;
    int i1 = MathHelper.floor(paramVec3D2.x);
    int i2 = MathHelper.floor(paramVec3D2.z);
    int i3 = i1 - j;
    int i4 = i2 - k;
    while ((i3 * m > 0) || (i4 * n > 0)) {
        if (d7 < d8) {
            d7 += d5;
            j += m;
            i3 = i1 - j;
        } else {
            d8 += d6;
            k += n;
            i4 = i2 - k;
        }
        if (!a(j, (int) paramVec3D1.y, k, paramInt1, paramInt2, paramInt3, paramVec3D1, d1, d2)) {
            return false;
        }
    }
    return true;
}
Also used : PathPoint(net.minecraft.server.v1_12_R1.PathPoint)

Example 8 with Vec3D

use of net.minecraft.server.v1_12_R1.Vec3D in project Citizens2 by CitizensDev.

the class NMSImpl method flyingMoveLogic.

public static void flyingMoveLogic(EntityLiving entity, float f, float f1) {
    if ((entity.cu()) || (entity.bA())) {
        if (entity.isInWater()) {
            double d1 = entity.locY;
            float f4 = entity instanceof EntityPolarBear ? 0.98F : 0.8F;
            float f3 = 0.02F;
            float f2 = EnchantmentManager.a(Enchantments.DEPTH_STRIDER, entity);
            if (f2 > 3.0F) {
                f2 = 3.0F;
            }
            if (!entity.onGround) {
                f2 *= 0.5F;
            }
            if (f2 > 0.0F) {
                f4 += (0.54600006F - f4) * f2 / 3.0F;
                f3 += (entity.cq() - f3) * f2 / 3.0F;
            }
            entity.a(f, f1, f3);
            entity.move(EnumMoveType.SELF, entity.motX, entity.motY, entity.motZ);
            entity.motX *= f4;
            entity.motY *= 0.800000011920929D;
            entity.motZ *= f4;
            if (!entity.isNoGravity()) {
                entity.motY -= 0.02D;
            }
            if ((entity.positionChanged) && (entity.c(entity.motX, entity.motY + 0.6000000238418579D - entity.locY + d1, entity.motZ))) {
                entity.motY = 0.30000001192092896D;
            }
        } else if ((entity.ao()) && ((!(entity instanceof EntityHuman)) || (!((EntityHuman) entity).abilities.isFlying))) {
            double d1 = entity.locY;
            entity.a(f, f1, 0.02F);
            entity.move(EnumMoveType.SELF, entity.motX, entity.motY, entity.motZ);
            entity.motX *= 0.5D;
            entity.motY *= 0.5D;
            entity.motZ *= 0.5D;
            if (!entity.isNoGravity()) {
                entity.motY -= 0.02D;
            }
            if ((entity.positionChanged) && (entity.c(entity.motX, entity.motY + 0.6000000238418579D - entity.locY + d1, entity.motZ))) {
                entity.motY = 0.30000001192092896D;
            }
        } else if (entity.cH()) {
            if (entity.motY > -0.5D) {
                entity.fallDistance = 1.0F;
            }
            Vec3D vec3d = entity.aB();
            float f5 = entity.pitch * 0.017453292F;
            double d0 = Math.sqrt(vec3d.x * vec3d.x + vec3d.z * vec3d.z);
            double d2 = Math.sqrt(entity.motX * entity.motX + entity.motZ * entity.motZ);
            double d3 = vec3d.b();
            float f6 = MathHelper.cos(f5);
            f6 = (float) (f6 * f6 * Math.min(1.0D, d3 / 0.4D));
            entity.motY += -0.08D + f6 * 0.06D;
            if ((entity.motY < 0.0D) && (d0 > 0.0D)) {
                double d4 = entity.motY * -0.1D * f6;
                entity.motY += d4;
                entity.motX += vec3d.x * d4 / d0;
                entity.motZ += vec3d.z * d4 / d0;
            }
            if (f5 < 0.0F) {
                double d4 = d2 * -MathHelper.sin(f5) * 0.04D;
                entity.motY += d4 * 3.2D;
                entity.motX -= vec3d.x * d4 / d0;
                entity.motZ -= vec3d.z * d4 / d0;
            }
            if (d0 > 0.0D) {
                entity.motX += (vec3d.x / d0 * d2 - entity.motX) * 0.1D;
                entity.motZ += (vec3d.z / d0 * d2 - entity.motZ) * 0.1D;
            }
            entity.motX *= 0.9900000095367432D;
            entity.motY *= 0.9800000190734863D;
            entity.motZ *= 0.9900000095367432D;
            entity.move(EnumMoveType.SELF, entity.motX, entity.motY, entity.motZ);
            if ((entity.positionChanged) && (!entity.world.isClientSide)) {
                double d4 = Math.sqrt(entity.motX * entity.motX + entity.motZ * entity.motZ);
                double d5 = d2 - d4;
                float f7 = (float) (d5 * 10.0D - 3.0D);
                if (f7 > 0.0F) {
                    entity.a(entity.e((int) f7), 1.0F, 1.0F);
                    entity.damageEntity(DamageSource.FLY_INTO_WALL, f7);
                }
            }
            if ((entity.onGround) && (!entity.world.isClientSide) && (entity.getFlag(7)) && (!CraftEventFactory.callToggleGlideEvent(entity, false).isCancelled())) {
                entity.setFlag(7, false);
            }
        } else {
            float f8 = 0.91F;
            BlockPosition.PooledBlockPosition blockposition_pooledblockposition = BlockPosition.PooledBlockPosition.d(entity.locX, entity.getBoundingBox().b - 1.0D, entity.locZ);
            if (entity.onGround) {
                f8 = entity.world.getType(blockposition_pooledblockposition).getBlock().frictionFactor * 0.91F;
            }
            float f4 = 0.16277136F / (f8 * f8 * f8);
            float f3;
            if (entity.onGround) {
                f3 = entity.cq() * f4;
            } else {
                f3 = entity.aR;
            }
            entity.a(f, f1, f3);
            f8 = 0.91F;
            if (entity.onGround) {
                f8 = entity.world.getType(blockposition_pooledblockposition.e(entity.locX, entity.getBoundingBox().b - 1.0D, entity.locZ)).getBlock().frictionFactor * 0.91F;
            }
            if (entity.m_()) {
                entity.motX = MathHelper.a(entity.motX, -0.15000000596046448D, 0.15000000596046448D);
                entity.motZ = MathHelper.a(entity.motZ, -0.15000000596046448D, 0.15000000596046448D);
                entity.fallDistance = 0.0F;
                if (entity.motY < -0.15D) {
                    entity.motY = -0.15D;
                }
                boolean flag = (entity.isSneaking()) && ((entity instanceof EntityHuman));
                if ((flag) && (entity.motY < 0.0D)) {
                    entity.motY = 0.0D;
                }
            }
            entity.move(EnumMoveType.SELF, entity.motX, entity.motY, entity.motZ);
            if ((entity.positionChanged) && (entity.m_())) {
                entity.motY = 0.2D;
            }
            if (entity.hasEffect(MobEffects.LEVITATION)) {
                entity.motY += (0.05D * (entity.getEffect(MobEffects.LEVITATION).getAmplifier() + 1) - entity.motY) * 0.2D;
            } else {
                blockposition_pooledblockposition.e(entity.locX, 0.0D, entity.locZ);
                if ((entity.world.isClientSide) && ((!entity.world.isLoaded(blockposition_pooledblockposition)) || (!entity.world.getChunkAtWorldCoords(blockposition_pooledblockposition).p()))) {
                    if (entity.locY > 0.0D) {
                        entity.motY = -0.1D;
                    } else {
                        entity.motY = 0.0D;
                    }
                } else if (!entity.isNoGravity()) {
                    entity.motY -= 0.08D;
                }
            }
            entity.motY *= 0.9800000190734863D;
            entity.motX *= f8;
            entity.motZ *= f8;
            blockposition_pooledblockposition.t();
        }
    }
    entity.aF = entity.aG;
    double d1 = entity.locX - entity.lastX;
    double d0 = entity.locZ - entity.lastZ;
    float f2 = MathHelper.sqrt(d1 * d1 + d0 * d0) * 4.0F;
    if (f2 > 1.0F) {
        f2 = 1.0F;
    }
    entity.aG += (f2 - entity.aG) * 0.4F;
    entity.aH += entity.aG;
}
Also used : EntityHuman(net.minecraft.server.v1_11_R1.EntityHuman) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) EntityPolarBear(net.minecraft.server.v1_11_R1.EntityPolarBear) Vec3D(net.minecraft.server.v1_11_R1.Vec3D)

Example 9 with Vec3D

use of net.minecraft.server.v1_12_R1.Vec3D in project Citizens2 by CitizensDev.

the class PlayerNavigation method a.

@Override
public boolean a(PathEntity paramPathEntity, double paramDouble) {
    if (paramPathEntity == null) {
        this.c = null;
        return false;
    }
    if (!paramPathEntity.a(this.c)) {
        this.c = paramPathEntity;
    }
    d();
    if (this.c.d() == 0) {
        return false;
    }
    this.d = paramDouble;
    Vec3D localVec3D = c();
    this.h = this.g;
    this.i = localVec3D;
    return true;
}
Also used : Vec3D(net.minecraft.server.v1_11_R1.Vec3D)

Example 10 with Vec3D

use of net.minecraft.server.v1_12_R1.Vec3D in project Citizens2 by CitizensDev.

the class NMSImpl method flyingMoveLogic.

public static void flyingMoveLogic(EntityLiving entity, float f, float f1) {
    if ((entity.ct()) || (entity.bA())) {
        if ((entity.isInWater()) && ((!(entity instanceof EntityHuman)) || (!((EntityHuman) entity).abilities.isFlying))) {
            double d1 = entity.locY;
            float f4 = entity instanceof EntityPolarBear ? 0.98F : 0.8F;
            float f3 = 0.02F;
            float f2 = EnchantmentManager.d(entity);
            if (f2 > 3.0F) {
                f2 = 3.0F;
            }
            if (!entity.onGround) {
                f2 *= 0.5F;
            }
            if (f2 > 0.0F) {
                f4 += (0.54600006F - f4) * f2 / 3.0F;
                f3 += (entity.cp() - f3) * f2 / 3.0F;
            }
            entity.a(f, f1, f3);
            entity.move(entity.motX, entity.motY, entity.motZ);
            entity.motX *= f4;
            entity.motY *= 0.800000011920929D;
            entity.motZ *= f4;
            if (!entity.isNoGravity()) {
                entity.motY -= 0.02D;
            }
            if ((entity.positionChanged) && (entity.c(entity.motX, entity.motY + 0.6000000238418579D - entity.locY + d1, entity.motZ))) {
                entity.motY = 0.30000001192092896D;
            }
        } else if ((entity.ao()) && ((!(entity instanceof EntityHuman)) || (!((EntityHuman) entity).abilities.isFlying))) {
            double d1 = entity.locY;
            entity.a(f, f1, 0.02F);
            entity.move(entity.motX, entity.motY, entity.motZ);
            entity.motX *= 0.5D;
            entity.motY *= 0.5D;
            entity.motZ *= 0.5D;
            if (!entity.isNoGravity()) {
                entity.motY -= 0.02D;
            }
            if ((entity.positionChanged) && (entity.c(entity.motX, entity.motY + 0.6000000238418579D - entity.locY + d1, entity.motZ))) {
                entity.motY = 0.30000001192092896D;
            }
        } else if (entity.cG()) {
            if (entity.motY > -0.5D) {
                entity.fallDistance = 1.0F;
            }
            Vec3D vec3d = entity.aB();
            float f5 = entity.pitch * 0.017453292F;
            double d0 = Math.sqrt(vec3d.x * vec3d.x + vec3d.z * vec3d.z);
            double d2 = Math.sqrt(entity.motX * entity.motX + entity.motZ * entity.motZ);
            double d3 = vec3d.b();
            float f6 = MathHelper.cos(f5);
            f6 = (float) (f6 * f6 * Math.min(1.0D, d3 / 0.4D));
            entity.motY += -0.08D + f6 * 0.06D;
            if ((entity.motY < 0.0D) && (d0 > 0.0D)) {
                double d4 = entity.motY * -0.1D * f6;
                entity.motY += d4;
                entity.motX += vec3d.x * d4 / d0;
                entity.motZ += vec3d.z * d4 / d0;
            }
            if (f5 < 0.0F) {
                double d4 = d2 * -MathHelper.sin(f5) * 0.04D;
                entity.motY += d4 * 3.2D;
                entity.motX -= vec3d.x * d4 / d0;
                entity.motZ -= vec3d.z * d4 / d0;
            }
            if (d0 > 0.0D) {
                entity.motX += (vec3d.x / d0 * d2 - entity.motX) * 0.1D;
                entity.motZ += (vec3d.z / d0 * d2 - entity.motZ) * 0.1D;
            }
            entity.motX *= 0.9900000095367432D;
            entity.motY *= 0.9800000190734863D;
            entity.motZ *= 0.9900000095367432D;
            entity.move(entity.motX, entity.motY, entity.motZ);
            if ((entity.positionChanged) && (!entity.world.isClientSide)) {
                double d4 = Math.sqrt(entity.motX * entity.motX + entity.motZ * entity.motZ);
                double d5 = d2 - d4;
                float f7 = (float) (d5 * 10.0D - 3.0D);
                if (f7 > 0.0F) {
                    entity.a(entity.e((int) f7), 1.0F, 1.0F);
                    entity.damageEntity(DamageSource.FLY_INTO_WALL, f7);
                }
            }
            if ((entity.onGround) && (!entity.world.isClientSide) && (entity.getFlag(7)) && (!CraftEventFactory.callToggleGlideEvent(entity, false).isCancelled())) {
                entity.setFlag(7, false);
            }
        } else {
            float f8 = 0.91F;
            BlockPosition.PooledBlockPosition blockposition_pooledblockposition = BlockPosition.PooledBlockPosition.d(entity.locX, entity.getBoundingBox().b - 1.0D, entity.locZ);
            if (entity.onGround) {
                f8 = entity.world.getType(blockposition_pooledblockposition).getBlock().frictionFactor * 0.91F;
            }
            float f4 = 0.16277136F / (f8 * f8 * f8);
            float f3;
            if (entity.onGround) {
                f3 = entity.cp() * f4;
            } else {
                f3 = entity.aS;
            }
            entity.a(f, f1, f3);
            f8 = 0.91F;
            if (entity.onGround) {
                f8 = entity.world.getType(blockposition_pooledblockposition.e(entity.locX, entity.getBoundingBox().b - 1.0D, entity.locZ)).getBlock().frictionFactor * 0.91F;
            }
            if (entity.m_()) {
                entity.motX = MathHelper.a(entity.motX, -0.15000000596046448D, 0.15000000596046448D);
                entity.motZ = MathHelper.a(entity.motZ, -0.15000000596046448D, 0.15000000596046448D);
                entity.fallDistance = 0.0F;
                if (entity.motY < -0.15D) {
                    entity.motY = -0.15D;
                }
                boolean flag = (entity.isSneaking()) && ((entity instanceof EntityHuman));
                if ((flag) && (entity.motY < 0.0D)) {
                    entity.motY = 0.0D;
                }
            }
            entity.move(entity.motX, entity.motY, entity.motZ);
            if ((entity.positionChanged) && (entity.m_())) {
                entity.motY = 0.2D;
            }
            if (entity.hasEffect(MobEffects.LEVITATION)) {
                entity.motY += (0.05D * (entity.getEffect(MobEffects.LEVITATION).getAmplifier() + 1) - entity.motY) * 0.2D;
            } else {
                blockposition_pooledblockposition.e(entity.locX, 0.0D, entity.locZ);
                if ((entity.world.isClientSide) && ((!entity.world.isLoaded(blockposition_pooledblockposition)) || (!entity.world.getChunkAtWorldCoords(blockposition_pooledblockposition).p()))) {
                    if (entity.locY > 0.0D) {
                        entity.motY = -0.1D;
                    } else {
                        entity.motY = 0.0D;
                    }
                } else if (!entity.isNoGravity()) {
                    entity.motY -= 0.08D;
                }
            }
            entity.motY *= 0.9800000190734863D;
            entity.motX *= f8;
            entity.motZ *= f8;
            blockposition_pooledblockposition.t();
        }
    }
    entity.aG = entity.aH;
    double d1 = entity.locX - entity.lastX;
    double d0 = entity.locZ - entity.lastZ;
    float f2 = MathHelper.sqrt(d1 * d1 + d0 * d0) * 4.0F;
    if (f2 > 1.0F) {
        f2 = 1.0F;
    }
    entity.aH += (f2 - entity.aH) * 0.4F;
    entity.aI += entity.aH;
}
Also used : EntityHuman(net.minecraft.server.v1_10_R1.EntityHuman) BlockPosition(net.minecraft.server.v1_10_R1.BlockPosition) EntityPolarBear(net.minecraft.server.v1_10_R1.EntityPolarBear) Vec3D(net.minecraft.server.v1_10_R1.Vec3D)

Aggregations

Vec3D (net.minecraft.server.v1_10_R1.Vec3D)5 Vec3D (net.minecraft.server.v1_11_R1.Vec3D)5 Vec3D (net.minecraft.server.v1_12_R1.Vec3D)5 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)3 PathPoint (net.minecraft.server.v1_12_R1.PathPoint)3 Vec3D (net.minecraft.server.v1_8_R3.Vec3D)3 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)2 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)2 AxisAlignedBB (net.minecraft.server.v1_10_R1.AxisAlignedBB)1 EntityHuman (net.minecraft.server.v1_10_R1.EntityHuman)1 EntityPolarBear (net.minecraft.server.v1_10_R1.EntityPolarBear)1 PathPoint (net.minecraft.server.v1_10_R1.PathPoint)1 AxisAlignedBB (net.minecraft.server.v1_11_R1.AxisAlignedBB)1 EntityHuman (net.minecraft.server.v1_11_R1.EntityHuman)1 EntityPolarBear (net.minecraft.server.v1_11_R1.EntityPolarBear)1 PathPoint (net.minecraft.server.v1_11_R1.PathPoint)1 AxisAlignedBB (net.minecraft.server.v1_12_R1.AxisAlignedBB)1 Block (net.minecraft.server.v1_12_R1.Block)1 EntityBird (net.minecraft.server.v1_12_R1.EntityBird)1 EntityPolarBear (net.minecraft.server.v1_12_R1.EntityPolarBear)1