Search in sources :

Example 66 with BlockPosition

use of net.minecraft.server.v1_13_R1.BlockPosition in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method a.

public PathType a(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3, EntityHumanNPC paramEntityInsentient, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean1, boolean paramBoolean2) {
    EnumSet<PathType> localEnumSet = EnumSet.noneOf(PathType.class);
    PathType localPathType1 = PathType.BLOCKED;
    BlockPosition localBlockPosition = new BlockPosition(paramEntityInsentient);
    localPathType1 = a(paramIBlockAccess, paramInt1, paramInt2, paramInt3, paramInt4, paramInt5, paramInt6, paramBoolean1, paramBoolean2, localEnumSet, localPathType1, localBlockPosition);
    if (localEnumSet.contains(PathType.FENCE)) {
        return PathType.FENCE;
    }
    Object localObject = PathType.BLOCKED;
    for (PathType localPathType2 : localEnumSet) {
        if (paramEntityInsentient.a(localPathType2) < 0.0F) {
            return localPathType2;
        }
        if (paramEntityInsentient.a(localPathType2) >= paramEntityInsentient.a((PathType) localObject)) {
            localObject = localPathType2;
        }
    }
    if ((localPathType1 == PathType.OPEN) && (paramEntityInsentient.a((PathType) localObject) == 0.0F)) {
        return PathType.OPEN;
    }
    return (PathType) localObject;
}
Also used : PathType(net.minecraft.server.v1_12_R1.PathType) MutableBlockPosition(net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition)

Example 67 with BlockPosition

use of net.minecraft.server.v1_13_R1.BlockPosition in project Citizens2 by CitizensDev.

the class PlayerNavigation method b2.

private PathEntity b2(BlockPosition paramBlockPosition) {
    if (!b()) {
        return null;
    }
    if ((this.c != null) && (!this.c.b()) && (paramBlockPosition.equals(this.q))) {
        return this.c;
    }
    this.q = paramBlockPosition;
    float f1 = i();
    this.b.methodProfiler.a("pathfind");
    BlockPosition localBlockPosition = new BlockPosition(this.a);
    int i1 = (int) (f1 + 8.0F);
    ChunkCache localChunkCache = new ChunkCache(this.b, localBlockPosition.a(-i1, -i1, -i1), localBlockPosition.a(i1, i1, i1), 0);
    PathEntity localPathEntity = this.r.a(localChunkCache, this.a, this.q, f1);
    this.b.methodProfiler.b();
    return localPathEntity;
}
Also used : ChunkCache(net.minecraft.server.v1_12_R1.ChunkCache) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) PathEntity(net.minecraft.server.v1_12_R1.PathEntity) PathPoint(net.minecraft.server.v1_12_R1.PathPoint)

Example 68 with BlockPosition

use of net.minecraft.server.v1_13_R1.BlockPosition in project Citizens2 by CitizensDev.

the class NMSImpl method getTargetNavigator.

@Override
public MCNavigator getTargetNavigator(org.bukkit.entity.Entity entity, Iterable<Vector> dest, final NavigatorParameters params) {
    List<PathPoint> list = Lists.<PathPoint>newArrayList(Iterables.<Vector, PathPoint>transform(dest, new Function<Vector, PathPoint>() {

        @Override
        public PathPoint apply(Vector input) {
            return new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ());
        }
    }));
    PathPoint last = list.size() > 0 ? list.get(list.size() - 1) : null;
    final PathEntity path = new PathEntity(list, last != null ? new BlockPosition(last.a, last.b, last.c) : null, true);
    return getTargetNavigator(entity, params, new Function<NavigationAbstract, Boolean>() {

        @Override
        public Boolean apply(NavigationAbstract input) {
            return input.a(path, params.speed());
        }
    });
}
Also used : PathPoint(net.minecraft.server.v1_16_R3.PathPoint) Function(com.google.common.base.Function) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) NavigationAbstract(net.minecraft.server.v1_16_R3.NavigationAbstract) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) Vector(org.bukkit.util.Vector)

Example 69 with BlockPosition

use of net.minecraft.server.v1_13_R1.BlockPosition 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 70 with BlockPosition

use of net.minecraft.server.v1_13_R1.BlockPosition in project Citizens2 by CitizensDev.

the class PlayerNavigation method superD_.

protected void superD_() {
    if (this.c == null)
        return;
    for (int var0 = 0; var0 < this.c.e(); var0++) {
        PathPoint var1 = this.c.a(var0);
        PathPoint var2 = (var0 + 1 < this.c.e()) ? this.c.a(var0 + 1) : null;
        IBlockData var3 = this.b.getType(new BlockPosition(var1.a, var1.b, var1.c));
        if (var3.a(Blocks.CAULDRON)) {
            this.c.a(var0, var1.a(var1.a, var1.b + 1, var1.c));
            if (var2 != null && var1.b >= var2.b)
                this.c.a(var0 + 1, var1.a(var2.a, var1.b + 1, var2.c));
        }
    }
}
Also used : PathPoint(net.minecraft.server.v1_16_R3.PathPoint) IBlockData(net.minecraft.server.v1_16_R3.IBlockData) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) BaseBlockPosition(net.minecraft.server.v1_16_R3.BaseBlockPosition) PathPoint(net.minecraft.server.v1_16_R3.PathPoint)

Aggregations

BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)57 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)36 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)34 Location (org.bukkit.Location)32 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)30 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)30 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)27 BlockPosition (net.minecraft.server.v1_15_R1.BlockPosition)26 BlockPosition (net.minecraft.server.v1_14_R1.BlockPosition)24 Chunk (org.bukkit.Chunk)24 ArrayList (java.util.ArrayList)22 List (java.util.List)19 Map (java.util.Map)17 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)17 Iterator (java.util.Iterator)14 HashMap (java.util.HashMap)12 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)11 ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)10 SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)10 BlockPosition (net.minecraft.server.v1_13_R2.BlockPosition)10