Skip to content
Permalink
Browse files

Turrets now have more reliable targetting and do not glitch between t…

…argets.
  • Loading branch information...
Ri5ux Ri5ux
Ri5ux authored and Ri5ux committed Jul 11, 2019
1 parent 0407091 commit 3b3e374e675b29ccf3bea3a9f89819edd8d20109
Showing with 11 additions and 8 deletions.
  1. +11 −8 src/main/java/org/avp/tile/TileEntityTurret.java
@@ -225,16 +225,19 @@ public Entity findTarget()
{
Entity newTarget = Entities.getRandomEntityInCoordsRange(world, EntityLiving.class, this.pos, 32);

if (this.canTarget(newTarget) && canSee(newTarget))
if (this.targetEntity == null || this.targetEntity != null && this.targetEntity.isDead || this.targetEntity != null && !canSee(this.targetEntity))
{
this.targetEntity = newTarget;

if (this.world.isRemote)
if (this.canTarget(newTarget) && canSee(newTarget))
{
AliensVsPredator.network().sendToAll(new PacketTurretTargetUpdate(this));
}
this.targetEntity = newTarget;

return newTarget;
if (this.world.isRemote)
{
AliensVsPredator.network().sendToAll(new PacketTurretTargetUpdate(this));
}

return newTarget;
}
}

return null;
@@ -472,7 +475,7 @@ public void fire()
this.timeout = this.timeoutMax;
this.targetEntity.attackEntityFrom(DamageSources.bullet, 1F);
this.targetEntity.hurtResistantTime = 0;
this.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.pos.x, this.pos.y, this.pos.z, 1, 1, 1);
this.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.pos.x, this.pos.y, this.pos.z, 0, 0, 0);
Sounds.WEAPON_M56SG.playSound(this.world, this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), 1F, 1F);
}

0 comments on commit 3b3e374

Please sign in to comment.
You can’t perform that action at this time.