use of net.minecraft.entity.EntityLiving in project NetherEx by LogicTechCorp.
the class EventHandler method onLivingUpdate.
@SubscribeEvent
public static void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
World world = event.getEntityLiving().getEntityWorld();
BlockPos pos = new BlockPos(event.getEntityLiving());
EntityLivingBase entity = event.getEntityLiving();
boolean canFreeze = !(entity instanceof EntityPlayer) && !Arrays.asList(ConfigHandler.potionEffect.freeze.blacklist).contains(EntityList.getKey(entity).toString());
if (world.getBiomeForCoordsBody(pos) == NetherExBiomes.ARCTIC_ABYSS) {
if (canFreeze && !entity.isPotionActive(NetherExEffects.FREEZE) && world.rand.nextInt(ConfigHandler.biome.arcticAbyss.chanceOfFreezing) == 0) {
entity.addPotionEffect(new PotionEffect(NetherExEffects.FREEZE, 300, 0));
}
}
if (entity instanceof EntityLiving && canFreeze) {
if (!entity.isPotionActive(NetherExEffects.FREEZE)) {
if (((EntityLiving) entity).isAIDisabled()) {
((EntityLiving) entity).setNoAI(false);
entity.setSilent(false);
}
} else {
((EntityLiving) entity).setNoAI(true);
entity.setSilent(true);
if (world.rand.nextInt(ConfigHandler.potionEffect.freeze.chanceOfThawing) == 0) {
entity.removePotionEffect(NetherExEffects.FREEZE);
}
}
}
if (entity instanceof EntityPlayer && entity.isPotionActive(NetherExEffects.FREEZE)) {
entity.setPosition(entity.prevPosX, entity.posY, entity.prevPosZ);
}
boolean canSpawnSpore = entity instanceof EntityPlayer || !Arrays.asList(ConfigHandler.potionEffect.spore.blacklist).contains(EntityList.getKey(entity).toString());
if (canSpawnSpore && entity.isPotionActive(NetherExEffects.SPORE) && world.rand.nextInt(ConfigHandler.potionEffect.spore.chanceOfSporeSpawning) == 0) {
if (world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos).expand(1, 1, 1)).size() < 3) {
BlockPos newPos = pos.offset(EnumFacing.Plane.HORIZONTAL.random(world.rand));
if (!world.isRemote && world.isAirBlock(newPos) && world.getBlockState(newPos.down()).isSideSolid(world, newPos.down(), EnumFacing.UP)) {
EntitySpore spore = new EntitySpore(world, 0);
spore.setPosition(newPos.getX(), newPos.getY(), newPos.getZ());
world.spawnEntity(spore);
}
}
}
boolean canSpawnGhastling = entity instanceof EntityPlayer && world.provider.getDimension() == DimensionType.NETHER.getId();
if (canSpawnGhastling && entity.isPotionActive(NetherExEffects.LOST) && world.rand.nextInt(ConfigHandler.potionEffect.lost.chanceOfGhastlingSpawning) == 0) {
BlockPos newPos = pos.add(0, 5, 0).offset(entity.getHorizontalFacing().getOpposite(), 5);
if (!world.isRemote && world.isAirBlock(newPos)) {
EntityGhastling ghastling = new EntityGhastling(world);
ghastling.setPosition(newPos.getX(), newPos.getY(), newPos.getZ());
ghastling.setAttackTarget(entity);
world.spawnEntity(ghastling);
}
}
}
use of net.minecraft.entity.EntityLiving in project ArsMagica2 by Mithion.
the class AIShakeHead method shouldAnimate.
public boolean shouldAnimate() {
EntityLiving living = getEntity();
if (living.getAttackTarget() == null)
return false;
if (living.getHealth() > living.getMaxHealth() - 4)
return false;
IAnimatedEntity entity = (IAnimatedEntity) living;
return entity.getAnimID() == 0 && living.getRNG().nextInt(30) == 0;
}
use of net.minecraft.entity.EntityLiving in project ArsMagica2 by Mithion.
the class EntityAIHurricane method continueExecuting.
@Override
public boolean continueExecuting() {
EntityLivingBase AITarget = ((EntityLiving) host).getAttackTarget();
if (host.hitCount >= 10) {
((IArsMagicaBoss) host).setCurrentAction(BossActions.IDLE);
cooldownTicks = 20;
return false;
}
if (AITarget == null || AITarget.isDead || ((IArsMagicaBoss) host).getTicksInCurrentAction() > BossActions.SPINNING.getMaxActionTime()) {
if (!host.worldObj.isRemote) {
int y = (int) host.posY + 1;
for (int x = -1; x <= 1; ++x) {
for (int z = -1; z <= 1; ++z) {
while (!host.worldObj.canBlockSeeTheSky((int) host.posX + x, y, (int) host.posZ + z) && host.worldObj.getBlock((int) host.posX + x, y, (int) host.posZ + z) != Blocks.bedrock) {
host.worldObj.func_147478_e((int) host.posX + x, y++, (int) host.posZ + z, true);
}
y = (int) host.posY + 2;
}
}
}
List<EntityLivingBase> nearbyEntities = host.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, host.boundingBox.expand(2, 2, 2));
for (EntityLivingBase ent : nearbyEntities) {
if (ent == host)
continue;
AMVector3 movement = MathUtilities.GetMovementVectorBetweenPoints(new AMVector3(host), new AMVector3(ent));
float factor = 2.15f;
double x = -(movement.x * factor);
double y = 2.5f;
double z = -(movement.z * factor);
ent.attackEntityFrom(DamageSources.causeEntityWindDamage(host), 12);
ent.addVelocity(x, y, z);
if (ent instanceof EntityPlayer) {
AMNetHandler.INSTANCE.sendVelocityAddPacket(host.worldObj, ent, x, y, z);
}
ent.fallDistance = 0f;
}
((IArsMagicaBoss) host).setCurrentAction(BossActions.IDLE);
cooldownTicks = 20;
return false;
}
return true;
}
use of net.minecraft.entity.EntityLiving in project ArsMagica2 by Mithion.
the class ParticleApproachEntity method doUpdate.
@Override
public void doUpdate() {
if (target == null) {
this.finish();
return;
}
double posX;
double posZ;
double posY = particle.posY;
double angle;
double distanceToTarget = particle.getDistanceSqToEntity(target);
double deltaZ = target.posZ - particle.posZ;
double deltaX = target.posX - particle.posX;
angle = Math.atan2(deltaZ, deltaX);
double radians = angle;
posX = particle.posX + (approachSpeed * Math.cos(radians));
posZ = particle.posZ + (approachSpeed * Math.sin(radians));
double deltaY;
if (target instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving) target;
deltaY = posY - (entityliving.posY + entityliving.getEyeHeight());
} else if (target instanceof EntityItem) {
deltaY = posY - target.posY;
} else {
deltaY = (target.boundingBox.minY + target.boundingBox.maxY) / 2D - posY;
}
double horizontalDistance = MathHelper.sqrt_double(deltaX * deltaX + deltaZ * deltaZ);
float pitchRotation = (float) (-Math.atan2(deltaY, horizontalDistance));
double pitchRadians = pitchRotation;
posY = particle.posY - (approachSpeed * Math.sin(pitchRadians));
if (distanceToTarget <= (targetDistance * targetDistance)) {
this.finish();
} else {
particle.setPosition(posX, posY, posZ);
}
}
use of net.minecraft.entity.EntityLiving in project ArsMagica2 by Mithion.
the class ParticleFleeEntity method doUpdate.
@Override
public void doUpdate() {
double posX;
double posZ;
double posY = particle.posY;
double angle;
double distanceToTarget = particle.getDistanceToEntity(target);
double deltaZ = particle.posZ - target.posZ;
double deltaX = particle.posX - target.posX;
angle = Math.atan2(deltaZ, deltaX);
double radians = angle;
posX = particle.posX + (fleeSpeed * Math.cos(radians));
posZ = particle.posZ + (fleeSpeed * Math.sin(radians));
double deltaY;
if (target instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving) target;
deltaY = posY - (entityliving.posY + (double) entityliving.getEyeHeight());
} else {
deltaY = (target.boundingBox.minY + target.boundingBox.maxY) / 2D - posY;
}
double horizontalDistance = MathHelper.sqrt_double(deltaX * deltaX + deltaZ * deltaZ);
float pitchRotation = (float) (-Math.atan2(deltaY, horizontalDistance));
double pitchRadians = pitchRotation;
posY = particle.posY + (fleeSpeed * Math.sin(pitchRadians));
if (distanceToTarget > targetDistance) {
this.finish();
} else {
particle.setPosition(posX, posY, posZ);
}
}
Aggregations