use of net.minecraft.entity.passive.EntityAmbientCreature in project OpenModularTurrets by OpenModularTurretsTeam.
the class TurretHeadUtil method getTarget.
@SuppressWarnings("ConstantConditions")
public static Entity getTarget(TurretBase base, World worldObj, BlockPos pos, int turretRange, TurretHead turret) {
Entity target = null;
if (!worldObj.isRemote && base != null && base.getOwner() != null) {
AxisAlignedBB axis = new AxisAlignedBB(pos.getX() - turretRange - 1, pos.getY() - turretRange - 1, pos.getZ() - turretRange - 1, pos.getX() + turretRange + 1, pos.getY() + turretRange + 1, pos.getZ() + turretRange + 1);
List<EntityLivingBase> targets = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis);
for (EntityLivingBase target1 : targets) {
if (target1 != null && EntityList.getEntityString(target1) != null) {
if (ConfigHandler.validMobBlacklist.contains(EntityList.getEntityString(target1)))
continue;
}
if (base.isAttacksNeutrals() && ConfigHandler.globalCanTargetNeutrals) {
if (target1 instanceof EntityAnimal && !target1.isDead) {
target = target1;
}
}
if (base.isAttacksNeutrals() && ConfigHandler.globalCanTargetNeutrals) {
if (target1 instanceof EntityAmbientCreature && !target1.isDead) {
target = target1;
}
}
if (base.isAttacksMobs() && ConfigHandler.globalCanTargetMobs) {
if (target1.isCreatureType(EnumCreatureType.MONSTER, false) && !target1.isDead) {
target = target1;
}
}
if (base.isAttacksPlayers() && ConfigHandler.globalCanTargetPlayers) {
if (target1 instanceof EntityPlayerMP && !target1.isDead) {
EntityPlayerMP entity = (EntityPlayerMP) target1;
if (!isPlayerOwner(entity, base) && !isPlayerTrusted(entity, base) && !entity.capabilities.isCreativeMode) {
target = target1;
}
}
}
if (target != null && turret != null) {
if (base.isMultiTargeting() && isTargetAlreadyTargeted(base, target)) {
continue;
}
EntityLivingBase targetELB = (EntityLivingBase) target;
if (canTurretSeeTarget(turret, targetELB) && targetELB.getHealth() > 0.0F) {
return target;
}
}
}
}
return null;
}
use of net.minecraft.entity.passive.EntityAmbientCreature in project OpenModularTurrets by OpenModularTurretsTeam.
the class TurretHeadUtil method getTargetWithoutSlowEffect.
@SuppressWarnings("ConstantConditions")
public static Entity getTargetWithoutSlowEffect(TurretBase base, World worldObj, BlockPos pos, int turretRange, TurretHead turret) {
Entity target = null;
if (!worldObj.isRemote && base != null && base.getOwner() != null) {
AxisAlignedBB axis = new AxisAlignedBB(pos.getX() - turretRange - 1, pos.getY() - turretRange - 1, pos.getZ() - turretRange - 1, pos.getX() + turretRange + 1, pos.getY() + turretRange + 1, pos.getZ() + turretRange + 1);
List<EntityLivingBase> targets = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis);
for (EntityLivingBase target1 : targets) {
if (base.isAttacksNeutrals() && ConfigHandler.globalCanTargetNeutrals) {
if (target1 instanceof EntityAnimal && !target1.isDead && !target1.isPotionActive(Potion.getPotionById(2))) {
target = target1;
}
}
if (base.isAttacksNeutrals() && ConfigHandler.globalCanTargetNeutrals) {
if (target1 instanceof EntityAmbientCreature && !target1.isDead && !target1.isPotionActive(Potion.getPotionById(2))) {
target = target1;
}
}
if (base.isAttacksMobs() && ConfigHandler.globalCanTargetMobs) {
if (target1 instanceof IMob && !target1.isDead && !target1.isPotionActive(Potion.getPotionById(2))) {
target = target1;
}
}
if (base.isAttacksPlayers() && ConfigHandler.globalCanTargetPlayers) {
if (target1 instanceof EntityPlayerMP && !target1.isDead && !target1.isPotionActive(Potion.getPotionById(2))) {
EntityPlayerMP entity = (EntityPlayerMP) target1;
if (!entity.getUniqueID().toString().equals(base.getOwner()) && !isPlayerTrusted(entity, base) && !entity.capabilities.isCreativeMode) {
target = target1;
}
}
}
if (target != null && turret != null) {
EntityLivingBase targetELB = (EntityLivingBase) target;
if (base.isMultiTargeting() && isTargetAlreadyTargeted(base, target)) {
continue;
}
if (canTurretSeeTarget(turret, targetELB) && targetELB.getHealth() > 0.0F) {
return target;
}
}
}
}
return null;
}
use of net.minecraft.entity.passive.EntityAmbientCreature in project OpenModularTurrets by OpenModularTurretsTeam.
the class TurretHeadUtil method getTargetWithMinimumRange.
@SuppressWarnings("ConstantConditions")
public static Entity getTargetWithMinimumRange(TurretBase base, World worldObj, BlockPos pos, int turretRange, TurretHead turret) {
Entity target = null;
if (!worldObj.isRemote && base != null && base.getOwner() != null) {
AxisAlignedBB axis = new AxisAlignedBB(pos.getX() - turretRange - 1, pos.getY() - turretRange - 1, pos.getZ() - turretRange - 1, pos.getX() + turretRange + 1, pos.getY() + turretRange + 1, pos.getZ() + turretRange + 1);
List<EntityLivingBase> targets = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis);
for (EntityLivingBase target1 : targets) {
if (base.isAttacksNeutrals() && ConfigHandler.globalCanTargetNeutrals) {
if (target1 instanceof EntityAnimal && !target1.isDead && target1.getDistance(pos.getX(), pos.getY(), pos.getZ()) >= 3) {
target = target1;
}
}
if (base.isAttacksNeutrals() && ConfigHandler.globalCanTargetNeutrals) {
if (target1 instanceof EntityAmbientCreature && !target1.isDead && target1.getDistance(pos.getX(), pos.getY(), pos.getZ()) >= 3) {
target = target1;
}
}
if (base.isAttacksMobs() && ConfigHandler.globalCanTargetMobs) {
if (target1 instanceof IMob && !target1.isDead && target1.getDistance(pos.getX(), pos.getY(), pos.getZ()) >= 3) {
target = target1;
}
}
if (base.isAttacksPlayers() && ConfigHandler.globalCanTargetPlayers) {
if (target1 instanceof EntityPlayerMP && !target1.isDead && target1.getDistance(pos.getX(), pos.getY(), pos.getZ()) >= 3) {
EntityPlayerMP entity = (EntityPlayerMP) target1;
if (!isPlayerOwner(entity, base) && !isPlayerTrusted(entity, base) && !entity.capabilities.isCreativeMode) {
target = target1;
}
}
}
if (target != null && turret != null) {
if (base.isMultiTargeting() && isTargetAlreadyTargeted(base, target)) {
continue;
}
EntityLivingBase targetELB = (EntityLivingBase) target;
if (canTurretSeeTarget(turret, targetELB) && targetELB.getHealth() > 0.0F) {
return target;
}
}
}
}
return null;
}
Aggregations