use of omtteam.openmodularturrets.blocks.turretheads.BlockAbstractTurretHead in project OpenModularTurrets by OpenModularTurretsTeam.
the class RocketProjectile method onHitBlock.
@Override
@ParametersAreNonnullByDefault
public void onHitBlock(IBlockState hitBlock, BlockPos pos) {
if (hitBlock.getBlock() instanceof BlockAbstractTurretHead) {
return;
}
if (!hitBlock.getMaterial().isSolid()) {
// Go through non solid block
return;
}
if (!getEntityWorld().isRemote) {
float strength = ConfigHandler.canRocketsDestroyBlocks ? 2.3F : 0.1F;
getEntityWorld().createExplosion(null, posX, posY, posZ, strength, true);
AxisAlignedBB axis = new AxisAlignedBB(this.posX - 5, this.posY - 5, this.posZ - 5, this.posX + 5, this.posY + 5, this.posZ + 5);
List<EntityLivingBase> targets = getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, axis);
for (Entity mob : targets) {
int damage = ConfigHandler.getRocketTurretSettings().getDamage();
if (isAmped) {
if (mob instanceof EntityLivingBase) {
EntityLivingBase elb = (EntityLivingBase) mob;
damage += ((int) elb.getHealth() * (0.08F * amp_level));
}
}
if (mob instanceof EntityPlayer) {
if (canDamagePlayer((EntityPlayer) mob)) {
mob.attackEntityFrom(new NormalDamageSource("rocket"), damage);
mob.hurtResistantTime = 0;
}
}
if (ConfigHandler.isCanRocketsHurtEnderDragon() && mob instanceof EntityDragon) {
((EntityDragon) mob).setHealth(((EntityDragon) mob).getHealth() - damage);
mob.hurtResistantTime = 0;
} else {
mob.attackEntityFrom(new NormalDamageSource("rocket"), damage);
mob.hurtResistantTime = 0;
}
}
}
this.setDead();
}
use of omtteam.openmodularturrets.blocks.turretheads.BlockAbstractTurretHead in project OpenModularTurrets by OpenModularTurretsTeam.
the class TurretHead method update.
@Override
public void update() {
setSide();
this.base = getBaseFromWorld();
//Is this the client?
if (this.getWorld().isRemote) {
updateRotationAnimation();
return;
}
//Is the turret head block still there?
if (!(this.getWorld().getBlockState(this.getPos()).getBlock() instanceof BlockAbstractTurretHead)) {
return;
}
//Send a block update after every 5 ticks of inactivity?
if (this.ticks % 5 == 0) {
this.getWorld().notifyBlockUpdate(this.pos, this.getWorld().getBlockState(pos), this.getWorld().getBlockState(pos), 3);
}
this.ticks++;
//Is turret base present and valid?
if (this.base == null || this.base.getTier() < this.turretTier) {
this.getWorld().destroyBlock(this.pos, true);
return;
}
//Is turret base active?
if (!base.isActive()) {
return;
}
//Real time tick updates
TurretHeadUtil.updateSolarPanelAddon(base);
concealmentChecks();
//Is there enough power to shoot?
if ((base.getEnergyLevel(EnumFacing.DOWN) < getPowerRequiredForNextShot())) {
return;
}
//Warn players
if (base.isAttacksPlayers() && ConfigHandler.globalCanTargetPlayers) {
TurretHeadUtil.warnPlayers(base, base.getWorld(), this.pos, getTurretRange());
}
//turret tick rate;
if (target == null && targetingTicks < ConfigHandler.getTurretTargetSearchTicks()) {
targetingTicks++;
} else {
//Validate current target, get a new one if necessary
targetingChecks();
//Aim at target
if (target != null && isTargetInYawPitch(target)) {
this.rotationXZ = TurretHeadUtil.getAimYaw(this.target, this.pos) + 3.2F;
this.rotationXY = TurretHeadUtil.getAimPitch(this.target, this.pos);
}
targetingTicks = 0;
}
if (target != null || this.autoFire) {
// has cooldown passed?
if (this.ticks < (this.getTurretFireRate() * (1 - TurretHeadUtil.getFireRateUpgrades(base)))) {
return;
}
// Is there ammo?
ItemStack ammo = getAmmoStack();
if (ammo == ItemStackTools.getEmptyStack() && this.requiresAmmo()) {
//TODO: Play some kind of clicking sound?
return;
}
//Finally, try to shoot if criteria is met.
if (target != null) {
doTargetedShot(this.target, ammo);
} else if (this.autoFire) {
doBlindShot(ammo);
}
//If we made it this far, reset ticks to zero?
this.ticks = 0;
}
}
use of omtteam.openmodularturrets.blocks.turretheads.BlockAbstractTurretHead in project OpenModularTurrets by OpenModularTurretsTeam.
the class BlazingClayProjectile method onHitBlock.
@Override
@ParametersAreNonnullByDefault
public void onHitBlock(IBlockState hitBlock, BlockPos pos) {
if (hitBlock.getBlock() instanceof BlockAbstractTurretHead) {
return;
}
if (!hitBlock.getMaterial().isSolid()) {
// Go through non solid block
return;
}
if (!getEntityWorld().isRemote) {
AxisAlignedBB axis = new AxisAlignedBB(this.posX - 5, this.posY - 5, this.posZ - 5, this.posX + 5, this.posY + 5, this.posZ + 5);
List<EntityLivingBase> targets = getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, axis);
int damage = ConfigHandler.getIncendiaryTurretSettings().getDamage();
for (Entity mob : targets) {
if (mob instanceof EntityPlayer) {
if (canDamagePlayer((EntityPlayer) mob)) {
mob.attackEntityFrom(new NormalDamageSource("bullet"), damage);
mob.hurtResistantTime = 0;
mob.setFire(5);
playSound();
}
} else {
mob.attackEntityFrom(new NormalDamageSource("bullet"), damage);
mob.hurtResistantTime = 0;
mob.setFire(5);
playSound();
}
}
this.setDead();
}
}
Aggregations