Search in sources :

Example 1 with EntitySporeCreeper

use of nex.entity.monster.EntitySporeCreeper 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));
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) EntitySpore(nex.entity.monster.EntitySpore) IBlockState(net.minecraft.block.state.IBlockState) PotionEffect(net.minecraft.potion.PotionEffect) EntitySporeCreeper(nex.entity.monster.EntitySporeCreeper) Vec3d(net.minecraft.util.math.Vec3d) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with EntitySporeCreeper

use of nex.entity.monster.EntitySporeCreeper in project NetherEx by LogicTechCorp.

the class EntityGoldGolem method initEntityAI.

@Override
protected void initEntityAI() {
    tasks.addTask(1, new EntityAIAttackMelee(this, 1.0D, true));
    tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.9D, 32.0F));
    tasks.addTask(3, new EntityAIMoveThroughVillage(this, 0.6D, true));
    tasks.addTask(4, new EntityAIMoveTowardsRestriction(this, 1.0D));
    tasks.addTask(5, new EntityAIGoldGolemLookAtPigtificate(this));
    tasks.addTask(6, new EntityAIWanderAvoidWater(this, 0.6D));
    tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
    tasks.addTask(8, new EntityAILookIdle(this));
    targetTasks.addTask(1, new EntityAIGoldGolemDefendVillage(this));
    targetTasks.addTask(2, new EntityAIHurtByTarget(this, false));
    targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityLiving.class, 10, false, true, entity -> entity != null && IMob.VISIBLE_MOB_SELECTOR.apply((EntityLiving) entity) && !(entity instanceof EntitySporeCreeper)));
}
Also used : EntityAIGoldGolemDefendVillage(nex.entity.ai.EntityAIGoldGolemDefendVillage) EntityDataManager(net.minecraft.network.datasync.EntityDataManager) NetherExLootTables(nex.init.NetherExLootTables) EntityAIGoldGolemLookAtPigtificate(nex.entity.ai.EntityAIGoldGolemLookAtPigtificate) EntitySporeCreeper(nex.entity.monster.EntitySporeCreeper) Block(net.minecraft.block.Block) EntityGolem(net.minecraft.entity.monster.EntityGolem) EntityLiving(net.minecraft.entity.EntityLiving) Side(net.minecraftforge.fml.relauncher.Side) PigtificateVillage(nex.village.PigtificateVillage) net.minecraft.entity.ai(net.minecraft.entity.ai) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Entity(net.minecraft.entity.Entity) EntityAIGoldGolemDefendVillage(nex.entity.ai.EntityAIGoldGolemDefendVillage) SoundEvents(net.minecraft.init.SoundEvents) PigtificateVillageManager(nex.village.PigtificateVillageManager) World(net.minecraft.world.World) BlockPos(net.minecraft.util.math.BlockPos) DataParameter(net.minecraft.network.datasync.DataParameter) DamageSource(net.minecraft.util.DamageSource) SharedMonsterAttributes(net.minecraft.entity.SharedMonsterAttributes) IBlockState(net.minecraft.block.state.IBlockState) DataSerializers(net.minecraft.network.datasync.DataSerializers) Material(net.minecraft.block.material.Material) EntityLivingBase(net.minecraft.entity.EntityLivingBase) IMob(net.minecraft.entity.monster.IMob) EntityPlayer(net.minecraft.entity.player.EntityPlayer) MathHelper(net.minecraft.util.math.MathHelper) ResourceLocation(net.minecraft.util.ResourceLocation) EnumParticleTypes(net.minecraft.util.EnumParticleTypes) SoundEvent(net.minecraft.util.SoundEvent) EntityLiving(net.minecraft.entity.EntityLiving) EntitySporeCreeper(nex.entity.monster.EntitySporeCreeper) EntityAIGoldGolemLookAtPigtificate(nex.entity.ai.EntityAIGoldGolemLookAtPigtificate) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

IBlockState (net.minecraft.block.state.IBlockState)2 Entity (net.minecraft.entity.Entity)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 BlockPos (net.minecraft.util.math.BlockPos)2 EntitySporeCreeper (nex.entity.monster.EntitySporeCreeper)2 Block (net.minecraft.block.Block)1 Material (net.minecraft.block.material.Material)1 EntityLiving (net.minecraft.entity.EntityLiving)1 SharedMonsterAttributes (net.minecraft.entity.SharedMonsterAttributes)1 net.minecraft.entity.ai (net.minecraft.entity.ai)1 EntityGolem (net.minecraft.entity.monster.EntityGolem)1 IMob (net.minecraft.entity.monster.IMob)1 SoundEvents (net.minecraft.init.SoundEvents)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 DataParameter (net.minecraft.network.datasync.DataParameter)1 DataSerializers (net.minecraft.network.datasync.DataSerializers)1 EntityDataManager (net.minecraft.network.datasync.EntityDataManager)1 PotionEffect (net.minecraft.potion.PotionEffect)1 DamageSource (net.minecraft.util.DamageSource)1