Search in sources :

Example 11 with BoundingBox

use of net.citizensnpcs.api.util.BoundingBox in project Citizens2 by CitizensDev.

the class PlayerControllerLook method a.

public void a(Entity entity, float f, float f1) {
    this.e = entity.locX;
    if ((entity instanceof EntityLiving))
        this.f = (entity.locY + entity.getHeadHeight());
    else {
        BoundingBox bb = NMSBoundingBox.wrap(entity.getBoundingBox());
        this.f = ((bb.minY + bb.maxY) / 2.0D);
    }
    this.g = entity.locZ;
    this.b = f;
    this.c = f1;
    this.d = true;
}
Also used : EntityLiving(net.minecraft.server.v1_13_R2.EntityLiving) BoundingBox(net.citizensnpcs.api.util.BoundingBox)

Example 12 with BoundingBox

use of net.citizensnpcs.api.util.BoundingBox in project Citizens2 by CitizensDev.

the class PlayerNavigation method u.

private int u() {
    BoundingBox bb = NMSBoundingBox.wrap(this.a.getBoundingBox());
    if ((!this.a.isInWater()) || (!t())) {
        return (int) (bb.minY + 0.5D);
    }
    int i = (int) bb.minY;
    Block localBlock = this.b.getType(new BlockPosition(MathHelper.floor(this.a.locX), i, MathHelper.floor(this.a.locZ))).getBlock();
    int j = 0;
    while (localBlock == Blocks.WATER) {
        i++;
        localBlock = this.b.getType(new BlockPosition(MathHelper.floor(this.a.locX), i, MathHelper.floor(this.a.locZ))).getBlock();
        j++;
        if (j > 16) {
            return (int) bb.minY;
        }
    }
    return i;
}
Also used : BoundingBox(net.citizensnpcs.api.util.BoundingBox)

Example 13 with BoundingBox

use of net.citizensnpcs.api.util.BoundingBox in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method b.

@Override
public PathPoint b() {
    int var1;
    BlockPosition var2;
    BoundingBox bb = NMSBoundingBox.wrap(this.b.getBoundingBox());
    if (this.e() && this.b.isInWater()) {
        var1 = (int) bb.minY;
        MutableBlockPosition var8 = new MutableBlockPosition(MathHelper.floor(this.b.locX), var1, MathHelper.floor(this.b.locZ));
        for (Block var3 = this.a.getType(var8).getBlock(); var3 == Blocks.WATER; var3 = this.a.getType(var8).getBlock()) {
            ++var1;
            var8.c(MathHelper.floor(this.b.locX), var1, MathHelper.floor(this.b.locZ));
        }
    } else if (this.b.onGround) {
        var1 = MathHelper.floor(bb.minY + 0.5D);
    } else {
        for (var2 = new BlockPosition(this.b); (this.a.getType(var2).isAir() || this.a.getType(var2).a(this.a, var2, PathMode.LAND)) && var2.getY() > 0; var2 = var2.down()) {
            ;
        }
        var1 = var2.up().getY();
    }
    var2 = new BlockPosition(this.b);
    PathType var9 = this.a(this.b, var2.getX(), var1, var2.getZ());
    if (this.b.a(var9) < 0.0F) {
        HashSet var4 = Sets.newHashSet();
        bb = NMSBoundingBox.wrap(this.b.getBoundingBox());
        var4.add(new BlockPosition(bb.minX, var1, bb.minZ));
        var4.add(new BlockPosition(bb.minX, var1, bb.maxZ));
        var4.add(new BlockPosition(bb.maxX, var1, bb.minZ));
        var4.add(new BlockPosition(bb.maxX, var1, bb.maxZ));
        Iterator var5 = var4.iterator();
        while (var5.hasNext()) {
            BlockPosition var6 = (BlockPosition) var5.next();
            PathType var7 = this.a(this.b, var6);
            if (this.b.a(var7) >= 0.0F) {
                return this.a(var6.getX(), var6.getY(), var6.getZ());
            }
        }
    }
    return this.a(var2.getX(), var1, var2.getZ());
}
Also used : PathType(net.minecraft.server.v1_13_R2.PathType) MutableBlockPosition(net.minecraft.server.v1_13_R2.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_13_R2.BlockPosition) BoundingBox(net.citizensnpcs.api.util.BoundingBox) Iterator(java.util.Iterator) Block(net.minecraft.server.v1_13_R2.Block) MutableBlockPosition(net.minecraft.server.v1_13_R2.BlockPosition.MutableBlockPosition) PathPoint(net.minecraft.server.v1_13_R2.PathPoint) HashSet(java.util.HashSet)

Aggregations

BoundingBox (net.citizensnpcs.api.util.BoundingBox)13 BlockPosition (net.minecraft.server.v1_13_R2.BlockPosition)2 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 EntityHumanNPC (net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC)1 AxisAlignedBB (net.minecraft.server.v1_10_R1.AxisAlignedBB)1 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)1 WorldServer (net.minecraft.server.v1_10_R1.WorldServer)1 AxisAlignedBB (net.minecraft.server.v1_11_R1.AxisAlignedBB)1 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)1 WorldServer (net.minecraft.server.v1_11_R1.WorldServer)1 AxisAlignedBB (net.minecraft.server.v1_12_R1.AxisAlignedBB)1 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)1 WorldServer (net.minecraft.server.v1_12_R1.WorldServer)1 AttributeInstance (net.minecraft.server.v1_13_R2.AttributeInstance)1 AxisAlignedBB (net.minecraft.server.v1_13_R2.AxisAlignedBB)1 Block (net.minecraft.server.v1_13_R2.Block)1 MutableBlockPosition (net.minecraft.server.v1_13_R2.BlockPosition.MutableBlockPosition)1 EntityBird (net.minecraft.server.v1_13_R2.EntityBird)1 EntityHuman (net.minecraft.server.v1_13_R2.EntityHuman)1