public boolean attack(Entity entity) { if (RayTracer.rayTrace( entity.getClientLevel(), new Vector(this.mob.pos.getZ(), this.mob.pos.getY(), this.mob.pos.getZ()), new Vector(entity.pos.getX(), entity.pos.getY(), entity.pos.getZ()), false) != null) { return false; } else { this.mob.attackTime = 5; this.attackDelay = this.random.nextInt(20) + 10; int damage = (int) ((this.random.nextFloat() + this.random.nextFloat()) / 2 * this.damage + 1); entity.hurt(this.mob, damage); this.noActionTime = 0; return true; } }
public void hurt(Entity cause, int damage) { super.hurt(cause, damage); if (cause instanceof Arrow) { cause = ((Arrow) cause).getOwner(); } if (cause != null && !cause.getClass().equals(this.mob.getClass())) { this.attackTarget = cause; } }