use of me.deecaad.weaponmechanics.weapon.explode.Explosion in project MechanicsMain by WeaponMechanics.
the class Projectile method shoot.
/**
* Shoots created projectile object
*
* @param projectile the created projectile object
* @param location the location containing pitch and yaw
*/
public WeaponProjectile shoot(WeaponProjectile projectile, Location location) {
WeaponMechanics.getProjectilesRunnable().addProjectile(projectile);
if (mechanics != null)
mechanics.use(new CastData(projectile));
EntityType type = projectileSettings.getProjectileDisguise();
if (type != null) {
FakeEntity fakeEntity;
Object data = projectileSettings.getDisguiseData();
if (type == EntityType.ARMOR_STAND && data != null) {
// Armor stand height * eye height multiplier
// 1.975 * 0.85 = 1.67875
Location offset = new Location(location.getWorld(), 0, -1.67875, 0);
// Add the first offset before actually spawning
location.add(offset);
fakeEntity = CompatibilityAPI.getEntityCompatibility().generateFakeEntity(location, type, data);
fakeEntity.setEquipment(EquipmentSlot.HEAD, (ItemStack) data);
fakeEntity.setInvisible(true);
// Set the offset for new packets
fakeEntity.setOffset(offset);
} else {
fakeEntity = CompatibilityAPI.getEntityCompatibility().generateFakeEntity(location, type, data);
}
projectile.spawnDisguise(fakeEntity);
}
// Handle explosions
Explosion explosion = getConfigurations().getObject(projectile.getWeaponTitle() + ".Explosion", Explosion.class);
if (explosion != null)
explosion.handleExplosion(projectile.getShooter(), projectile, ExplosionTrigger.SPAWN);
return projectile;
}
use of me.deecaad.weaponmechanics.weapon.explode.Explosion in project MechanicsMain by WeaponMechanics.
the class RayTraceResult method handleEntityHit.
private boolean handleEntityHit(WeaponProjectile projectile) {
// Handle worldguard flags
WorldGuardCompatibility worldGuard = CompatibilityAPI.getWorldGuardCompatibility();
Location loc = hitLocation.clone().toLocation(projectile.getWorld());
LivingEntity shooter = projectile.getShooter();
if (!worldGuard.testFlag(loc, shooter instanceof Player ? (Player) shooter : null, "weapon-damage")) {
// is cancelled check
Object obj = worldGuard.getValue(loc, "weapon-damage-message");
if (obj != null && !obj.toString().isEmpty() && shooter != null) {
shooter.sendMessage(StringUtil.color(obj.toString()));
}
return true;
}
boolean backstab = livingEntity.getLocation().getDirection().dot(projectile.getMotion()) > 0.0;
ProjectileHitEntityEvent hitEntityEvent = new ProjectileHitEntityEvent(projectile, livingEntity, hitLocation.clone(), hitPoint, backstab);
Bukkit.getPluginManager().callEvent(hitEntityEvent);
if (hitEntityEvent.isCancelled())
return true;
hitPoint = hitEntityEvent.getPoint();
backstab = hitEntityEvent.isBackStab();
if (!damageHandler.tryUse(livingEntity, projectile, getConfigurations().getDouble(projectile.getWeaponTitle() + ".Damage.Base_Damage"), hitPoint, backstab)) {
// Damage was cancelled
return true;
}
Explosion explosion = getConfigurations().getObject(projectile.getWeaponTitle() + ".Explosion", Explosion.class);
if (explosion != null)
explosion.handleExplosion(projectile.getShooter(), hitLocation.clone().toLocation(projectile.getWorld()), projectile, ExplosionTrigger.ENTITY);
return false;
}
use of me.deecaad.weaponmechanics.weapon.explode.Explosion in project MechanicsMain by WeaponMechanics.
the class RayTraceResult method handleBlockHit.
private boolean handleBlockHit(WeaponProjectile projectile) {
ProjectileHitBlockEvent hitBlockEvent = new ProjectileHitBlockEvent(projectile, block, hitFace, hitLocation.clone());
Bukkit.getPluginManager().callEvent(hitBlockEvent);
if (hitBlockEvent.isCancelled())
return true;
Explosion explosion = getConfigurations().getObject(projectile.getWeaponTitle() + ".Explosion", Explosion.class);
if (explosion != null)
explosion.handleExplosion(projectile.getShooter(), hitLocation.clone().toLocation(projectile.getWorld()), projectile, ExplosionTrigger.BLOCK);
return false;
}
Aggregations