Search in sources :

Example 1 with HitBox

use of me.deecaad.weaponmechanics.weapon.projectile.HitBox in project MechanicsMain by WeaponMechanics.

the class v1_9_R2 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_9_R2.AxisAlignedBB) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) ComplexEntityPart(org.bukkit.entity.ComplexEntityPart) ComplexLivingEntity(org.bukkit.entity.ComplexLivingEntity)

Example 2 with HitBox

use of me.deecaad.weaponmechanics.weapon.projectile.HitBox in project MechanicsMain by WeaponMechanics.

the class v1_11_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_11_R1.AxisAlignedBB) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) ComplexEntityPart(org.bukkit.entity.ComplexEntityPart) ComplexLivingEntity(org.bukkit.entity.ComplexLivingEntity)

Example 3 with HitBox

use of me.deecaad.weaponmechanics.weapon.projectile.HitBox 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 4 with HitBox

use of me.deecaad.weaponmechanics.weapon.projectile.HitBox 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 5 with HitBox

use of me.deecaad.weaponmechanics.weapon.projectile.HitBox in project MechanicsMain by WeaponMechanics.

the class IWeaponCompatibility method getHitBox.

/**
 * If block is air, liquid or some other passable block (e.g. torch, flower)
 * then this method WILL always return null. Basically if this method returns null
 * means that block is passable.
 *
 * @param block the block
 * @return the block's hit box or null if its passable for example
 */
default HitBox getHitBox(Block block) {
    // This default should only be used after 1.17
    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);
    // This default should only be used after 1.17 R1
    if (WeaponMechanics.getBasicConfigurations().getBool("Check_Accurate_Hitboxes", true)) {
        Collection<BoundingBox> voxelShape = block.getCollisionShape().getBoundingBoxes();
        if (voxelShape.size() > 1) {
            int x = block.getX();
            int y = block.getY();
            int z = block.getZ();
            for (BoundingBox boxPart : voxelShape) {
                hitBox.addVoxelShapePart(new HitBox(x + boxPart.getMinX(), y + boxPart.getMinY(), z + boxPart.getMinZ(), x + boxPart.getMaxX(), y + boxPart.getMaxY(), z + boxPart.getMaxZ()));
            }
        }
    }
    return hitBox;
}
Also used : HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) BoundingBox(org.bukkit.util.BoundingBox)

Aggregations

HitBox (me.deecaad.weaponmechanics.weapon.projectile.HitBox)25 Vector (org.bukkit.util.Vector)7 Entity (org.bukkit.entity.Entity)6 BoundingBox (org.bukkit.util.BoundingBox)6 Block (org.bukkit.block.Block)5 ComplexEntityPart (org.bukkit.entity.ComplexEntityPart)5 ComplexLivingEntity (org.bukkit.entity.ComplexLivingEntity)5 LivingEntity (org.bukkit.entity.LivingEntity)5 ArrayList (java.util.ArrayList)4 IWeaponCompatibility (me.deecaad.weaponmechanics.compatibility.IWeaponCompatibility)4 Chunk (org.bukkit.Chunk)3 World (org.bukkit.World)3 BlockIterator (org.bukkit.util.BlockIterator)3 HashMap (java.util.HashMap)2 Ray (me.deecaad.weaponmechanics.weapon.explode.raytrace.Ray)2 TraceResult (me.deecaad.weaponmechanics.weapon.explode.raytrace.TraceResult)2 RayTraceResult (me.deecaad.weaponmechanics.weapon.projectile.weaponprojectile.RayTraceResult)2 AxisAlignedBB (net.minecraft.server.v1_10_R1.AxisAlignedBB)2 AxisAlignedBB (net.minecraft.server.v1_11_R1.AxisAlignedBB)2 AxisAlignedBB (net.minecraft.server.v1_12_R1.AxisAlignedBB)2