Search in sources :

Example 6 with Vec3D

use of net.minecraft.server.v1_16_R2.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_16_R2.Vec3D in project Citizens2 by CitizensDev.

the class PlayerNavigation method n.

@Override
protected void n() {
    Vec3D localVec3D1 = c();
    int i1 = this.c.d();
    for (int i2 = this.c.e(); i2 < this.c.d(); i2++) {
        if (this.c.a(i2).b != Math.floor(localVec3D1.y)) {
            i1 = i2;
            break;
        }
    }
    this.f = (this.a.width > 0.75F ? this.a.width / 2.0F : 0.75F - this.a.width / 2.0F);
    Vec3D localVec3D2 = this.c.f();
    if ((MathHelper.e((float) (this.a.locX - (localVec3D2.x + 0.5D))) < this.f) && (MathHelper.e((float) (this.a.locZ - (localVec3D2.z + 0.5D))) < this.f) && (Math.abs(this.a.locY - localVec3D2.y) < 1.0D)) {
        this.c.c(this.c.e() + 1);
    }
    int i3 = MathHelper.f(this.a.width);
    int i4 = MathHelper.f(this.a.length);
    int i5 = i3;
    for (int i6 = i1 - 1; i6 >= this.c.e(); i6--) {
        if (a(localVec3D1, this.c.a(this.a, i6), i3, i4, i5)) {
            this.c.c(i6);
            break;
        }
    }
    a(localVec3D1);
}
Also used : Vec3D(net.minecraft.server.v1_12_R1.Vec3D) PathPoint(net.minecraft.server.v1_12_R1.PathPoint)

Example 8 with Vec3D

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

the class NMSImpl method setSize.

public static void setSize(Entity entity, boolean justCreated) {
    try {
        EntitySize entitysize = (EntitySize) SIZE_FIELD_GETTER.invoke(entity);
        EntityPose entitypose = entity.getPose();
        EntitySize entitysize1 = entity.a(entitypose);
        SIZE_FIELD_SETTER.invoke(entity, entitysize1);
        HEAD_HEIGHT.invoke(entity, HEAD_HEIGHT_METHOD.invoke(entity, entitypose, entitysize1));
        if (entitysize1.width < entitysize.width && false) /* TODO: PREVIOUS CITIZENS ADDITION ?reason */
        {
            double d0 = entitysize1.width / 2.0D;
            entity.a(new AxisAlignedBB(entity.locX() - d0, entity.locY(), entity.locZ() - d0, entity.locX() + d0, entity.locY() + entitysize1.height, entity.locZ() + d0));
        } else {
            AxisAlignedBB axisalignedbb = entity.getBoundingBox();
            entity.a(new AxisAlignedBB(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ, axisalignedbb.minX + entitysize1.width, axisalignedbb.minY + entitysize1.height, axisalignedbb.minZ + entitysize1.width));
            if (entitysize1.width > entitysize.width && !justCreated && !entity.world.isClientSide) {
                float f = entitysize.width - entitysize1.width;
                entity.move(EnumMoveType.SELF, new Vec3D(f, 0.0D, f));
            }
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Also used : AxisAlignedBB(net.minecraft.server.v1_16_R3.AxisAlignedBB) EntitySize(net.minecraft.server.v1_16_R3.EntitySize) Vec3D(net.minecraft.server.v1_16_R3.Vec3D) EntityPose(net.minecraft.server.v1_16_R3.EntityPose)

Example 9 with Vec3D

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

the class NMSImpl method flyingMoveLogic.

public static void flyingMoveLogic(EntityLiving entity, Vec3D vec3d) {
    if (entity.doAITick() || entity.cs()) {
        double d0 = 0.08D;
        boolean flag = ((entity.getMot()).y <= 0.0D);
        if (flag && entity.hasEffect(MobEffects.SLOW_FALLING)) {
            d0 = 0.01D;
            entity.fallDistance = 0.0F;
        }
        Fluid fluid = entity.world.getFluid(entity.getChunkCoordinates());
        if (entity.isInWater() && /*&& entity.cT() */
        !entity.a(fluid.getType())) {
            double d1 = entity.locY();
            float f = entity.isSprinting() ? 0.9F : 0.8F;
            float f1 = 0.02F;
            float f2 = EnchantmentManager.e(entity);
            if (f2 > 3.0F)
                f2 = 3.0F;
            if (!entity.isOnGround())
                f2 *= 0.5F;
            if (f2 > 0.0F) {
                f += (0.54600006F - f) * f2 / 3.0F;
                f1 += (entity.dN() - f1) * f2 / 3.0F;
            }
            if (entity.hasEffect(MobEffects.DOLPHINS_GRACE))
                f = 0.96F;
            entity.a(f1, vec3d);
            entity.move(EnumMoveType.SELF, entity.getMot());
            Vec3D vec3d1 = entity.getMot();
            if (entity.positionChanged && entity.isClimbing())
                vec3d1 = new Vec3D(vec3d1.x, 0.2D, vec3d1.z);
            entity.setMot(vec3d1.d(f, 0.800000011920929D, f));
            Vec3D vec3d2 = entity.a(d0, flag, entity.getMot());
            entity.setMot(vec3d2);
            if (entity.positionChanged && entity.e(vec3d2.x, vec3d2.y + 0.6D - entity.locY() + d1, vec3d2.z))
                entity.setMot(vec3d2.x, 0.30000001192092896D, vec3d2.z);
        } else if (entity.aQ() && /*&& entity.cT()*/
        !entity.a(fluid.getType())) {
            double d1 = entity.locY();
            entity.a(0.02F, vec3d);
            entity.move(EnumMoveType.SELF, entity.getMot());
            if (entity.b(TagsFluid.LAVA) <= entity.cx()) {
                entity.setMot(entity.getMot().d(0.5D, 0.8D, 0.5D));
                Vec3D vec3D = entity.a(d0, flag, entity.getMot());
                entity.setMot(vec3D);
            } else {
                entity.setMot(entity.getMot().a(0.5D));
            }
            if (!entity.isNoGravity())
                entity.setMot(entity.getMot().add(0.0D, -d0 / 4.0D, 0.0D));
            Vec3D vec3d3 = entity.getMot();
            if (entity.positionChanged && entity.e(vec3d3.x, vec3d3.y + 0.6D - entity.locY() + d1, vec3d3.z))
                entity.setMot(vec3d3.x, 0.3D, vec3d3.z);
        } else if (entity.isGliding()) {
            Vec3D vec3d4 = entity.getMot();
            if (vec3d4.y > -0.5D)
                entity.fallDistance = 1.0F;
            Vec3D vec3d5 = entity.getLookDirection();
            float f = entity.pitch * 0.017453292F;
            double d2 = Math.sqrt(vec3d5.x * vec3d5.x + vec3d5.z * vec3d5.z);
            double d3 = Math.sqrt(entity.c(vec3d4));
            double d4 = vec3d5.f();
            float f3 = MathHelper.cos(f);
            f3 = (float) (f3 * f3 * Math.min(1.0D, d4 / 0.4D));
            vec3d4 = entity.getMot().add(0.0D, d0 * (-1.0D + f3 * 0.75D), 0.0D);
            if (vec3d4.y < 0.0D && d2 > 0.0D) {
                double d5 = vec3d4.y * -0.1D * f3;
                vec3d4 = vec3d4.add(vec3d5.x * d5 / d2, d5, vec3d5.z * d5 / d2);
            }
            if (f < 0.0F && d2 > 0.0D) {
                double d5 = d3 * -MathHelper.sin(f) * 0.04D;
                vec3d4 = vec3d4.add(-vec3d5.x * d5 / d2, d5 * 3.2D, -vec3d5.z * d5 / d2);
            }
            if (d2 > 0.0D)
                vec3d4 = vec3d4.add((vec3d5.x / d2 * d3 - vec3d4.x) * 0.1D, 0.0D, (vec3d5.z / d2 * d3 - vec3d4.z) * 0.1D);
            entity.setMot(vec3d4.d(0.9900000095367432D, 0.9800000190734863D, 0.9900000095367432D));
            entity.move(EnumMoveType.SELF, entity.getMot());
            if (entity.positionChanged && !entity.world.isClientSide) {
                double d5 = Math.sqrt(entity.c(entity.getMot()));
                double d6 = d3 - d5;
                float f4 = (float) (d6 * 10.0D - 3.0D);
                if (f4 > 0.0F) {
                    try {
                        entity.playSound((SoundEffect) ENTITY_GET_SOUND_FALL.invoke(entity, (int) f4), 1.0F, 1.0F);
                    } catch (Throwable e) {
                        e.printStackTrace();
                    }
                    entity.damageEntity(DamageSource.FLY_INTO_WALL, f4);
                }
            }
            if (entity.isOnGround() && !entity.world.isClientSide && entity.getFlag(7) && !CraftEventFactory.callToggleGlideEvent(entity, false).isCancelled())
                entity.setFlag(7, false);
        } else {
            BlockPosition blockposition = new BlockPosition(entity.locX(), (entity.getBoundingBox()).minY - 0.5000001D, // entity.ar();
            entity.locZ());
            float f5 = entity.world.getType(blockposition).getBlock().getFrictionFactor();
            float f = entity.isOnGround() ? (f5 * 0.91F) : 0.91F;
            Vec3D vec3d6 = entity.a(vec3d, f5);
            double d7 = vec3d6.y;
            if (entity.hasEffect(MobEffects.LEVITATION)) {
                d7 += (0.05D * (entity.getEffect(MobEffects.LEVITATION).getAmplifier() + 1) - vec3d6.y) * 0.2D;
                entity.fallDistance = 0.0F;
            } else if (entity.world.isClientSide && !entity.world.isLoaded(blockposition)) {
                if (entity.locY() > 0.0D) {
                    d7 = -0.1D;
                } else {
                    d7 = 0.0D;
                }
            } else if (!entity.isNoGravity()) {
                d7 -= d0;
            }
            entity.setMot(vec3d6.x * f, d7 * 0.9800000190734863D, vec3d6.z * f);
        }
    }
    entity.a(entity, entity instanceof EntityBird);
}
Also used : Fluid(net.minecraft.server.v1_16_R3.Fluid) TagsFluid(net.minecraft.server.v1_16_R3.TagsFluid) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) EntityBird(net.minecraft.server.v1_16_R3.EntityBird) Vec3D(net.minecraft.server.v1_16_R3.Vec3D)

Example 10 with Vec3D

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

the class PlayerNavigation method c.

@Override
public void c() {
    this.e++;
    if (this.m)
        j();
    if (m())
        return;
    if (a()) {
        l();
    } else if (this.c != null && !this.c.c()) {
        Vec3D vec3D1 = b();
        Vec3D vec3D2 = this.c.a(this.a);
        if (vec3D1.y > vec3D2.y && !this.a.isOnGround() && MathHelper.floor(vec3D1.x) == MathHelper.floor(vec3D2.x) && MathHelper.floor(vec3D1.z) == MathHelper.floor(vec3D2.z))
            this.c.a();
    }
    if (m())
        return;
    Vec3D var0 = this.c.a(this.a);
    BlockPosition var1 = new BlockPosition(var0);
    this.a.getControllerMove().a(var0.x, this.b.getType(var1.down()).isAir() ? var0.y : PathfinderNormal.a(this.b, var1), var0.z, this.d);
}
Also used : BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) BaseBlockPosition(net.minecraft.server.v1_16_R3.BaseBlockPosition) Vec3D(net.minecraft.server.v1_16_R3.Vec3D)

Aggregations

Vec3D (net.minecraft.server.v1_16_R3.Vec3D)11 Vec3D (net.minecraft.server.v1_15_R1.Vec3D)10 Vec3D (net.minecraft.server.v1_14_R1.Vec3D)9 Vec3D (net.minecraft.server.v1_12_R1.Vec3D)7 Vec3D (net.minecraft.server.v1_10_R1.Vec3D)5 Vec3D (net.minecraft.server.v1_11_R1.Vec3D)5 Vec3D (net.minecraft.server.v1_8_R3.Vec3D)4 Gravity (net.citizensnpcs.trait.Gravity)3 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)2 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)2 AxisAlignedBB (net.minecraft.server.v1_12_R1.AxisAlignedBB)2 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)2 MovingObjectPosition (net.minecraft.server.v1_12_R1.MovingObjectPosition)2 BlockPosition (net.minecraft.server.v1_14_R1.BlockPosition)2 AxisAlignedBB (net.minecraft.server.v1_16_R3.AxisAlignedBB)2 BaseBlockPosition (net.minecraft.server.v1_16_R3.BaseBlockPosition)2 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)2 PathPoint (net.minecraft.server.v1_16_R3.PathPoint)2 AxisAlignedBB (net.minecraft.server.v1_8_R3.AxisAlignedBB)2 LivingEntity (org.bukkit.entity.LivingEntity)2