use of nex.entity.monster.EntitySpore in project NetherEx by LogicTechCorp.
the class ExplosionSpore method doExplosionA.
@Override
public void doExplosionA() {
if (!world.isRemote) {
Set<BlockPos> set = Sets.newHashSet();
for (int j = 0; j < 16; ++j) {
for (int k = 0; k < 16; ++k) {
for (int l = 0; l < 16; ++l) {
if (j == 0 || j == 15 || k == 0 || k == 15 || l == 0 || l == 15) {
double d0 = (double) ((float) j / 15.0F * 2.0F - 1.0F);
double d1 = (double) ((float) k / 15.0F * 2.0F - 1.0F);
double d2 = (double) ((float) l / 15.0F * 2.0F - 1.0F);
double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
d0 = d0 / d3;
d1 = d1 / d3;
d2 = d2 / d3;
float f = explosionSize * (0.7F + world.rand.nextFloat() * 0.6F);
double d4 = explosionX;
double d6 = explosionY;
double d8 = explosionZ;
for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) {
BlockPos blockpos = new BlockPos(d4, d6, d8);
IBlockState iblockstate = world.getBlockState(blockpos);
if (iblockstate.getMaterial() != Material.AIR) {
float f2 = exploder != null ? exploder.getExplosionResistance(this, world, blockpos, iblockstate) : iblockstate.getBlock().getExplosionResistance(world, blockpos, (Entity) null, this);
f -= (f2 + 0.3F) * 0.3F;
}
if (f > 0.0F && (exploder == null || exploder.verifyExplosion(this, world, blockpos, iblockstate, f))) {
set.add(blockpos);
}
d4 += d0 * 0.30000001192092896D;
d6 += d1 * 0.30000001192092896D;
d8 += d2 * 0.30000001192092896D;
}
}
}
}
}
affectedBlockPositions.addAll(set);
float f3 = explosionSize * 2.0F;
int k1 = MathHelper.floor(explosionX - (double) f3 - 1.0D);
int l1 = MathHelper.floor(explosionX + (double) f3 + 1.0D);
int i2 = MathHelper.floor(explosionY - (double) f3 - 1.0D);
int i1 = MathHelper.floor(explosionY + (double) f3 + 1.0D);
int j2 = MathHelper.floor(explosionZ - (double) f3 - 1.0D);
int j1 = MathHelper.floor(explosionZ + (double) f3 + 1.0D);
List<Entity> list = world.getEntitiesWithinAABBExcludingEntity(exploder, new AxisAlignedBB((double) k1, (double) i2, (double) j2, (double) l1, (double) i1, (double) j1));
ForgeEventFactory.onExplosionDetonate(world, this, list, f3);
Vec3d vec3d = new Vec3d(explosionX, explosionY, explosionZ);
for (Entity entity : list) {
if (!entity.isImmuneToExplosions()) {
double d12 = entity.getDistance(explosionX, explosionY, explosionZ) / (double) f3;
if (d12 <= 1.0D) {
double d5 = entity.posX - explosionX;
double d7 = entity.posY + (double) entity.getEyeHeight() - explosionY;
double d9 = entity.posZ - explosionZ;
double d13 = (double) MathHelper.sqrt(d5 * d5 + d7 * d7 + d9 * d9);
if (d13 != 0.0D) {
d5 = d5 / d13;
d7 = d7 / d13;
d9 = d9 / d13;
double d14 = (double) world.getBlockDensity(vec3d, entity.getEntityBoundingBox());
double d10 = (1.0D - d12) * d14;
if (!(entity instanceof EntitySporeCreeper) && !(entity instanceof EntitySpore)) {
entity.attackEntityFrom(DamageSource.causeExplosionDamage(this), (float) ((int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f3 + 1.0D)));
}
if (entity instanceof EntityLivingBase) {
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(NetherExEffects.SPORE, 2400, 0));
}
double d11 = d10;
if (entity instanceof EntityLivingBase) {
d11 = EnchantmentProtection.getBlastDamageReduction((EntityLivingBase) entity, d10);
}
entity.motionX += d5 * d11;
entity.motionY += d7 * d11;
entity.motionZ += d9 * d11;
if (entity instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) entity;
if (!entityplayer.isSpectator() && (!entityplayer.isCreative() || !entityplayer.capabilities.isFlying)) {
playerKnockbackMap.put(entityplayer, new Vec3d(d5 * d10, d7 * d10, d9 * d10));
}
}
}
}
}
}
}
}
use of nex.entity.monster.EntitySpore 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 nex.entity.monster.EntitySpore in project NetherEx by LogicTechCorp.
the class ExplosionSpore method doExplosionB.
@Override
public void doExplosionB(boolean spawnParticles) {
world.playSound(null, explosionX, explosionY, explosionZ, NetherExSoundEvents.ENTITY_EXPLODE_SPORE, SoundCategory.HOSTILE, 4.0F, (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
if (explosionSize >= 2.0F && isSmoking) {
NetherEx.proxy.spawnParticle(world, explosionX, explosionY, explosionZ, 1.0D, 0.0D, 0.0D, NetherExParticleTypes.SPORE_EXPLOSION_HUGE);
} else {
NetherEx.proxy.spawnParticle(world, explosionX, explosionY, explosionZ, 1.0D, 0.0D, 0.0D, NetherExParticleTypes.SPORE_EXPLOSION_LARGE);
}
if (!world.isRemote) {
if (isSmoking) {
for (BlockPos pos : affectedBlockPositions) {
IBlockState iblockstate = world.getBlockState(pos);
Block block = iblockstate.getBlock();
if (iblockstate.getMaterial() != Material.AIR) {
if (block.canDropFromExplosion(this)) {
block.dropBlockAsItemWithChance(world, pos, world.getBlockState(pos), 1.0F / explosionSize, 0);
}
block.onBlockExploded(world, pos, this);
}
}
}
if (isFlaming) {
for (BlockPos pos : affectedBlockPositions) {
if (world.getBlockState(pos).getMaterial() == Material.AIR && world.getBlockState(pos.down()).isFullBlock() && explosionRNG.nextInt(ConfigHandler.entity.sporeCreeper.chanceOfSporeSpawning) == 0) {
EntitySpore spore = new EntitySpore(world, 0);
spore.setPosition((double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D);
world.spawnEntity(spore);
}
}
}
}
}
use of nex.entity.monster.EntitySpore in project NetherEx by LogicTechCorp.
the class ModelSpore method render.
@Override
public void render(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float rotationYaw, float rotationPitch, float scale) {
EntitySpore spore = (EntitySpore) entity;
if (spore.getStage() == 0) {
stageOne.render(scale);
} else if (spore.getStage() == 1) {
stageOne.render(scale);
stageTwo.render(scale);
} else if (spore.getStage() == 2) {
stageOne.render(scale);
stageTwo.render(scale);
stageThreeInner.render(scale);
stageThreeOuter.render(scale);
} else if (spore.getStage() == 3) {
stageOne.render(scale);
stageTwo.render(scale);
stageThreeInner.render(scale);
stageThreeOuter.render(scale);
stageFour.render(scale);
} else {
stageOne.render(scale);
stageTwo.render(scale);
stageThreeInner.render(scale);
stageThreeOuter.render(scale);
stageFour.render(scale);
stageFive.render(scale);
}
}
Aggregations