use of micdoodle8.mods.galacticraft.api.entity.IEntityBreathable in project Galacticraft by micdoodle8.
the class EventHandlerGC method entityLivingEvent.
@SubscribeEvent
public void entityLivingEvent(LivingUpdateEvent event) {
final EntityLivingBase entityLiving = event.entityLiving;
if (entityLiving instanceof EntityPlayerMP) {
GalacticraftCore.handler.onPlayerUpdate((EntityPlayerMP) entityLiving);
if (GalacticraftCore.isPlanetsLoaded) {
AsteroidsModule.playerHandler.onPlayerUpdate((EntityPlayerMP) entityLiving);
}
return;
}
if (entityLiving.ticksExisted % ConfigManagerCore.suffocationCooldown == 0) {
if (entityLiving.worldObj.provider instanceof IGalacticraftWorldProvider) {
if (!(entityLiving instanceof EntityPlayer) && (!(entityLiving instanceof IEntityBreathable) || !((IEntityBreathable) entityLiving).canBreath()) && !((IGalacticraftWorldProvider) entityLiving.worldObj.provider).hasBreathableAtmosphere()) {
if (!OxygenUtil.isAABBInBreathableAirBlock(entityLiving)) {
GCCoreOxygenSuffocationEvent suffocationEvent = new GCCoreOxygenSuffocationEvent.Pre(entityLiving);
MinecraftForge.EVENT_BUS.post(suffocationEvent);
if (suffocationEvent.isCanceled()) {
return;
}
entityLiving.attackEntityFrom(DamageSourceGC.oxygenSuffocation, Math.max(ConfigManagerCore.suffocationDamage / 2, 1));
GCCoreOxygenSuffocationEvent suffocationEventPost = new GCCoreOxygenSuffocationEvent.Post(entityLiving);
MinecraftForge.EVENT_BUS.post(suffocationEventPost);
}
}
}
}
}
use of micdoodle8.mods.galacticraft.api.entity.IEntityBreathable in project Galacticraft by micdoodle8.
the class TileEntityEmergencyBox method scareMobs.
private void scareMobs() {
List<Entity> moblist = this.worldObj.getEntitiesInAABBexcluding(null, mobsAABB, IMob.mobSelector);
if (!moblist.isEmpty()) {
for (Entity entry : moblist) {
if (!(entry instanceof EntityCreature && entry instanceof IEntityBreathable)) {
continue;
}
EntityCreature mob = (EntityCreature) entry;
PathNavigate nav = mob.getNavigator();
if (nav == null) {
continue;
}
Vec3 vecNewTarget = RandomPositionGenerator.findRandomTargetBlockAwayFrom(mob, 12, 5, vec3Centre);
if (vecNewTarget == null) {
vecNewTarget = RandomPositionGenerator.findRandomTargetBlockAwayFrom(mob, 14, 7, vec3Centre);
if (vecNewTarget == null)
continue;
}
double distanceNew = vecNewTarget.squareDistanceTo(thisVec3);
double distanceCurrent = thisVec3.squareDistanceTo(new Vec3(mob.posX, mob.posY, mob.posZ));
if (distanceNew > distanceCurrent) {
Vec3 vecOldTarget = null;
if (nav.getPath() != null && !nav.getPath().isFinished()) {
vecOldTarget = nav.getPath().getPosition(mob);
}
if (vecOldTarget == null || distanceCurrent > vecOldTarget.squareDistanceTo(thisVec3)) {
nav.tryMoveToXYZ(vecNewTarget.xCoord, vecNewTarget.yCoord, vecNewTarget.zCoord, 1.3D);
}
}
}
}
}
Aggregations