Search in sources :

Example 6 with AxisAlignedBB

use of net.minecraft.server.v1_15_R1.AxisAlignedBB in project MechanicsMain by WeaponMechanics.

the class v1_16_R3 method getHitBox.

@Override
public HitBox getHitBox(Block block) {
    if (block.isEmpty() || block.isLiquid() || block.isPassable())
        return null;
    BoundingBox boundingBox = block.getBoundingBox();
    HitBox hitBox = new HitBox(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ());
    hitBox.setBlockHitBox(block);
    if (WeaponMechanics.getBasicConfigurations().getBool("Check_Accurate_Hitboxes", true)) {
        CraftBlock craftBlock = (CraftBlock) block;
        List<AxisAlignedBB> voxelShape = craftBlock.getNMS().getCollisionShape(craftBlock.getCraftWorld().getHandle(), craftBlock.getPosition()).d();
        if (voxelShape.size() > 1) {
            int x = block.getX();
            int y = block.getY();
            int z = block.getZ();
            for (AxisAlignedBB boxPart : voxelShape) {
                hitBox.addVoxelShapePart(new HitBox(x + boxPart.minX, y + boxPart.minY, z + boxPart.minZ, x + boxPart.maxX, y + boxPart.maxY, z + boxPart.maxZ));
            }
        }
    }
    return hitBox;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_16_R3.AxisAlignedBB) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) BoundingBox(org.bukkit.util.BoundingBox) CraftBlock(org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock)

Example 7 with AxisAlignedBB

use of net.minecraft.server.v1_15_R1.AxisAlignedBB in project MechanicsMain by WeaponMechanics.

the class v1_12_R1 method getHitBox.

@Override
public HitBox getHitBox(org.bukkit.entity.Entity entity) {
    if (entity.isInvulnerable() || !entity.getType().isAlive() || entity.isDead())
        return null;
    AxisAlignedBB aabb = ((CraftEntity) entity).getHandle().getBoundingBox();
    HitBox hitBox = new HitBox(aabb.a, aabb.b, aabb.c, aabb.d, aabb.e, aabb.f);
    hitBox.setLivingEntity((LivingEntity) entity);
    if (entity instanceof ComplexLivingEntity && WeaponMechanics.getBasicConfigurations().getBool("Check_Accurate_Hitboxes", true)) {
        for (ComplexEntityPart entityPart : ((ComplexLivingEntity) entity).getParts()) {
            AxisAlignedBB boxPart = ((CraftEntity) entityPart).getHandle().getBoundingBox();
            hitBox.addVoxelShapePart(new HitBox(boxPart.a, boxPart.b, boxPart.c, boxPart.d, boxPart.e, boxPart.f));
        }
    }
    return hitBox;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_12_R1.AxisAlignedBB) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) ComplexEntityPart(org.bukkit.entity.ComplexEntityPart) ComplexLivingEntity(org.bukkit.entity.ComplexLivingEntity)

Example 8 with AxisAlignedBB

use of net.minecraft.server.v1_15_R1.AxisAlignedBB 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;
        entity.a(new AxisAlignedBB(entity.getBoundingBox().a, entity.getBoundingBox().b, entity.getBoundingBox().c, entity.getBoundingBox().a + entity.width, entity.getBoundingBox().b + entity.length, entity.getBoundingBox().c + entity.width));
        if ((entity.width > f2) && (!justCreated) && (!entity.world.isClientSide))
            entity.move((f2 - entity.width) / 2, 0.0D, (f2 - entity.width) / 2);
    }
}
Also used : AxisAlignedBB(net.minecraft.server.v1_10_R1.AxisAlignedBB)

Example 9 with AxisAlignedBB

use of net.minecraft.server.v1_15_R1.AxisAlignedBB in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method a.

@Override
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);
    Object localObject1 = PathType.BLOCKED;
    double d = paramEntityInsentient.width / 2.0D;
    BlockPosition localBlockPosition = new BlockPosition(paramEntityInsentient);
    for (int i = paramInt1; i < paramInt1 + paramInt4; i++) {
        for (int k = paramInt2; k < paramInt2 + paramInt5; k++) {
            for (int m = paramInt3; m < paramInt3 + paramInt6; m++) {
                PathType localPathType2 = a(paramIBlockAccess, i, k, m);
                if ((localPathType2 == PathType.DOOR_WOOD_CLOSED) && (paramBoolean1) && (paramBoolean2)) {
                    localPathType2 = PathType.WALKABLE;
                }
                if ((localPathType2 == PathType.DOOR_OPEN) && (!paramBoolean2)) {
                    localPathType2 = PathType.BLOCKED;
                }
                if ((localPathType2 == PathType.RAIL) && (!(paramIBlockAccess.getType(localBlockPosition).getBlock() instanceof BlockMinecartTrackAbstract)) && (!(paramIBlockAccess.getType(localBlockPosition.down()).getBlock() instanceof BlockMinecartTrackAbstract))) {
                    localPathType2 = PathType.FENCE;
                }
                if ((i == paramInt1) && (k == paramInt2) && (m == paramInt3)) {
                    localObject1 = localPathType2;
                }
                if ((k > paramInt2) && (localPathType2 != PathType.OPEN)) {
                    AxisAlignedBB localAxisAlignedBB = new AxisAlignedBB(i - d + 0.5D, paramInt2 + 0.001D, m - d + 0.5D, i + d + 0.5D, paramInt2 + paramEntityInsentient.length, m + d + 0.5D);
                    if (!paramEntityInsentient.world.b(localAxisAlignedBB)) {
                        localPathType2 = PathType.OPEN;
                    }
                }
                localEnumSet.add(localPathType2);
            }
        }
    }
    if (localEnumSet.contains(PathType.FENCE)) {
        return PathType.FENCE;
    }
    Object localObject2 = PathType.BLOCKED;
    for (PathType localPathType1 : localEnumSet) {
        if (paramEntityInsentient.a(localPathType1) < 0.0F) {
            return localPathType1;
        }
        if (paramEntityInsentient.a(localPathType1) >= paramEntityInsentient.a((PathType) localObject2)) {
            localObject2 = localPathType1;
        }
    }
    if ((localObject1 == PathType.OPEN) && (paramEntityInsentient.a((PathType) localObject2) == 0.0F)) {
        return PathType.OPEN;
    }
    return (PathType) localObject2;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_10_R1.AxisAlignedBB) PathType(net.minecraft.server.v1_10_R1.PathType) MutableBlockPosition(net.minecraft.server.v1_10_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_10_R1.BlockPosition) BlockMinecartTrackAbstract(net.minecraft.server.v1_10_R1.BlockMinecartTrackAbstract) PathPoint(net.minecraft.server.v1_10_R1.PathPoint)

Example 10 with AxisAlignedBB

use of net.minecraft.server.v1_15_R1.AxisAlignedBB in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method a.

@Override
public PathType a(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3, EntityInsentient paramEntityInsentient, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean1, boolean paramBoolean2) {
    EnumSet<PathType> localEnumSet = EnumSet.noneOf(PathType.class);
    Object localObject1 = PathType.BLOCKED;
    double d = paramEntityInsentient.width / 2.0D;
    BlockPosition localBlockPosition = new BlockPosition(paramEntityInsentient);
    for (int i = paramInt1; i < paramInt1 + paramInt4; i++) {
        for (int k = paramInt2; k < paramInt2 + paramInt5; k++) {
            for (int m = paramInt3; m < paramInt3 + paramInt6; m++) {
                PathType localPathType2 = a(paramIBlockAccess, i, k, m);
                if ((localPathType2 == PathType.DOOR_WOOD_CLOSED) && (paramBoolean1) && (paramBoolean2)) {
                    localPathType2 = PathType.WALKABLE;
                }
                if ((localPathType2 == PathType.DOOR_OPEN) && (!paramBoolean2)) {
                    localPathType2 = PathType.BLOCKED;
                }
                if ((localPathType2 == PathType.RAIL) && (!(paramIBlockAccess.getType(localBlockPosition).getBlock() instanceof BlockMinecartTrackAbstract)) && (!(paramIBlockAccess.getType(localBlockPosition.down()).getBlock() instanceof BlockMinecartTrackAbstract))) {
                    localPathType2 = PathType.FENCE;
                }
                if ((i == paramInt1) && (k == paramInt2) && (m == paramInt3)) {
                    localObject1 = localPathType2;
                }
                if ((k > paramInt2) && (localPathType2 != PathType.OPEN)) {
                    AxisAlignedBB localAxisAlignedBB = new AxisAlignedBB(i - d + 0.5D, paramInt2 + 0.001D, m - d + 0.5D, i + d + 0.5D, paramInt2 + paramEntityInsentient.length, m + d + 0.5D);
                    if (!paramEntityInsentient.world.b(localAxisAlignedBB)) {
                        localPathType2 = PathType.OPEN;
                    }
                }
                localEnumSet.add(localPathType2);
            }
        }
    }
    if (localEnumSet.contains(PathType.FENCE)) {
        return PathType.FENCE;
    }
    Object localObject2 = PathType.BLOCKED;
    for (PathType localPathType1 : localEnumSet) {
        if (paramEntityInsentient.a(localPathType1) < 0.0F) {
            return localPathType1;
        }
        if (paramEntityInsentient.a(localPathType1) >= paramEntityInsentient.a((PathType) localObject2)) {
            localObject2 = localPathType1;
        }
    }
    if ((localObject1 == PathType.OPEN) && (paramEntityInsentient.a((PathType) localObject2) == 0.0F)) {
        return PathType.OPEN;
    }
    return (PathType) localObject2;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_10_R1.AxisAlignedBB) PathType(net.minecraft.server.v1_10_R1.PathType) MutableBlockPosition(net.minecraft.server.v1_10_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_10_R1.BlockPosition) BlockMinecartTrackAbstract(net.minecraft.server.v1_10_R1.BlockMinecartTrackAbstract) PathPoint(net.minecraft.server.v1_10_R1.PathPoint)

Aggregations

List (java.util.List)25 Entity (org.bukkit.entity.Entity)23 Iterator (java.util.Iterator)21 ArrayList (java.util.ArrayList)14 AxisAlignedBB (net.minecraft.server.v1_12_R1.AxisAlignedBB)14 AxisAlignedBB (net.minecraft.server.v1_10_R1.AxisAlignedBB)13 HitBox (me.deecaad.weaponmechanics.weapon.projectile.HitBox)12 AxisAlignedBB (net.minecraft.server.v1_11_R1.AxisAlignedBB)12 ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)11 SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)11 AxisAlignedBB (net.minecraft.server.v1_8_R3.AxisAlignedBB)9 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)8 LivingEntity (org.bukkit.entity.LivingEntity)8 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)7 AxisAlignedBB (net.minecraft.server.v1_16_R3.AxisAlignedBB)7 AxisAlignedBB (net.minecraft.server.v1_9_R2.AxisAlignedBB)7 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)6 BoundingBox (net.citizensnpcs.api.util.BoundingBox)5 Location (org.bukkit.Location)5 AxisAlignedBB (net.minecraft.server.v1_13_R2.AxisAlignedBB)4