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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations