Search in sources :

Example 6 with BoundingBox

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

the class NMSImpl method getCollisionBox.

@Override
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
    WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
    Block type = CraftMagicNumbers.getBlock(block);
    BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
    AxisAlignedBB aabb = type.a(world, pos, world.getType(pos));
    return aabb == null ? BoundingBox.EMPTY : new BoundingBox(aabb.a, aabb.b, aabb.c, aabb.d, aabb.e, aabb.f);
}
Also used : AxisAlignedBB(net.minecraft.server.v1_8_R3.AxisAlignedBB) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) BoundingBox(net.citizensnpcs.api.util.BoundingBox) CraftBlock(org.bukkit.craftbukkit.v1_8_R3.block.CraftBlock) Block(net.minecraft.server.v1_8_R3.Block) WorldServer(net.minecraft.server.v1_8_R3.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 7 with BoundingBox

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

the class BoundingBoxExaminer method isPassable.

@Override
public PassableState isPassable(BlockSource source, PathPoint point) {
    Vector pos = point.getVector();
    Material up = source.getMaterialAt(pos.getBlockX(), pos.getBlockY() + 2, pos.getBlockZ());
    Material down = source.getMaterialAt(pos.getBlockX(), pos.getBlockY() - 1, pos.getBlockZ());
    if (!MinecraftBlockExaminer.canStandIn(up) && MinecraftBlockExaminer.canStandOn(down)) {
        BoundingBox above = source.getCollisionBox(pos.getBlockX(), pos.getBlockY() + 2, pos.getBlockZ());
        BoundingBox below = source.getCollisionBox(pos.getBlockX(), pos.getBlockY() - 1, pos.getBlockZ());
        float height = (float) (above.minY - below.maxY);
        if (height < this.height) {
            return PassableState.UNPASSABLE;
        }
    }
    return PassableState.IGNORE;
}
Also used : BoundingBox(net.citizensnpcs.api.util.BoundingBox) Material(org.bukkit.Material) Vector(org.bukkit.util.Vector)

Example 8 with BoundingBox

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

the class NMSImpl method getCollisionBox.

@Override
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
    WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
    VoxelShape shape = ((CraftBlock) block).getNMS().getCollisionShape(world, ((CraftBlock) block).getPosition());
    return shape.isEmpty() ? new BoundingBox(0, 0, 0, 0, 0, 0) : NMSBoundingBox.wrap(shape.getBoundingBox());
}
Also used : VoxelShape(net.minecraft.server.v1_14_R1.VoxelShape) BoundingBox(net.citizensnpcs.api.util.BoundingBox) WorldServer(net.minecraft.server.v1_14_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_14_R1.CraftWorld)

Example 9 with BoundingBox

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

the class NMSImpl method getCollisionBox.

@Override
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
    WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
    BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
    AxisAlignedBB aabb = world.getType(pos).c(world, pos);
    if (aabb == null) {
        aabb = world.getType(pos).d(world, pos);
    }
    return new BoundingBox(aabb.a, aabb.b, aabb.c, aabb.d, aabb.e, aabb.f);
}
Also used : AxisAlignedBB(net.minecraft.server.v1_10_R1.AxisAlignedBB) BlockPosition(net.minecraft.server.v1_10_R1.BlockPosition) BoundingBox(net.citizensnpcs.api.util.BoundingBox) WorldServer(net.minecraft.server.v1_10_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_10_R1.CraftWorld)

Example 10 with BoundingBox

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

the class NMSImpl method setSize.

public static void setSize(Entity entity, float f, float f1, boolean justCreated) {
    if ((f != entity.width) || (f1 != entity.length)) {
        float f2 = entity.width;
        entity.width = f;
        entity.length = f1;
        BoundingBox bb = NMSBoundingBox.wrap(entity.getBoundingBox());
        entity.a(new AxisAlignedBB(bb.minX, bb.minY, bb.minZ, bb.minX + entity.width, bb.minY + entity.length, bb.minZ + entity.width));
        if ((entity.width > f2) && (!justCreated) && (!entity.world.isClientSide))
            entity.move(EnumMoveType.SELF, (f2 - entity.width) / 2, 0.0D, (f2 - entity.width) / 2);
    }
}
Also used : AxisAlignedBB(net.minecraft.server.v1_13_R2.AxisAlignedBB) BoundingBox(net.citizensnpcs.api.util.BoundingBox)

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