Search in sources :

Example 51 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project MorePlanets by SteveKunG.

the class EntityZeliusCreeper method explode.

@Override
protected void explode() {
    if (!this.world.isRemote) {
        boolean flag = this.world.getGameRules().getBoolean("mobGriefing");
        if (this.getPowered()) {
            this.world.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionRadius * 2, flag);
            List<EntityLivingBase> list = this.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(this.posX - this.explosionRadius * 2, this.posY - this.explosionRadius * 2, this.posZ - this.explosionRadius * 2, this.posX + this.explosionRadius * 2, this.posY + this.explosionRadius * 2, this.posZ + this.explosionRadius * 2));
            for (EntityLivingBase living : list) {
                living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_CRYSTALLIZE, 240, 1));
            }
        } else {
            List<EntityLivingBase> list = this.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(this.posX - this.explosionRadius, this.posY - this.explosionRadius, this.posZ - this.explosionRadius, this.posX + this.explosionRadius, this.posY + this.explosionRadius, this.posZ + this.explosionRadius));
            for (EntityLivingBase living : list) {
                living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_CRYSTALLIZE, 120, 1));
            }
            this.world.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionRadius, flag);
        }
        this.setDead();
        this.spawnLingeringCloud();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 52 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project MorePlanets by SteveKunG.

the class EntityAlienBeam method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    if (this.lightningState == 2) {
        this.world.playSound(null, this.posX, this.posY, this.posZ, MPSounds.ALIEN_BEAM, SoundCategory.WEATHER, 100.0F, 0.8F + this.rand.nextFloat() * 0.2F);
    }
    --this.lightningState;
    if (this.lightningState < 0) {
        if (this.boltLivingTime == 0) {
            this.setDead();
        } else if (this.lightningState < -this.rand.nextInt(10)) {
            --this.boltLivingTime;
            this.lightningState = 1;
            this.boltVertex = this.rand.nextLong();
        }
    }
    if (this.lightningState >= 0) {
        if (!this.world.isRemote) {
            double d0 = 1.0D;
            List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, new AxisAlignedBB(this.posX - d0, this.posY - d0, this.posZ - d0, this.posX + d0, this.posY + 6.0D + d0, this.posZ + d0));
            for (int i = 0; i < list.size(); ++i) {
                Entity entity = list.get(i);
                entity.attackEntityFrom(DamageSource.LIGHTNING_BOLT, 10.0F);
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity)

Example 53 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project MorePlanets by SteveKunG.

the class EntityDarkLightningBolt method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    if (this.lightningState == 2) {
        this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, MPSounds.LOUD_THUNDER, SoundCategory.WEATHER, 5000.0F, 0.8F + this.rand.nextFloat() * 0.2F);
    }
    --this.lightningState;
    if (this.lightningState < 0) {
        if (this.boltLivingTime == 0) {
            this.setDead();
        } else if (this.lightningState < -this.rand.nextInt(10)) {
            --this.boltLivingTime;
            this.lightningState = 1;
            this.boltVertex = this.rand.nextLong();
        }
    }
    if (this.lightningState >= 0) {
        if (this.world.isRemote) {
            this.world.setLastLightningBolt(2);
        } else {
            double d0 = 1.0D;
            List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, new AxisAlignedBB(this.posX - d0, this.posY - d0, this.posZ - d0, this.posX + d0, this.posY + 6.0D + d0, this.posZ + d0));
            for (int i = 0; i < list.size(); ++i) {
                Entity entity = list.get(i);
                if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode) {
                    return;
                }
                if (entity instanceof EntityLivingBase) {
                    ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, 60, 0, false, false));
                }
                entity.attackEntityFrom(DamageSource.LIGHTNING_BOLT, 10.0F);
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 54 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project MorePlanets by SteveKunG.

the class TileEntityDarkEnergyReceiver method update.

@Override
public void update() {
    super.update();
    if (!this.world.isRemote) {
        if (this.activated && !this.disabled) {
            if (!this.successful) {
                int radius = 32;
                List<Entity> entity = this.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(this.pos.getX() - radius, this.pos.getY() - radius, this.pos.getZ() - radius, this.pos.getX() + radius, this.pos.getY() + radius, this.pos.getZ() + radius));
                for (Entity around : entity) {
                    if (around instanceof EntityLivingBase) {
                        EntityLivingBase living = (EntityLivingBase) around;
                        if (!(living instanceof EntityPlayer)) {
                            living.addPotionEffect(new PotionEffect(MPPotions.DARK_ENERGY, 200, 0));
                        }
                        if (around instanceof EntityPlayer) {
                            EntityPlayer player = (EntityPlayer) around;
                            if (!player.capabilities.isCreativeMode && !player.isPotionActive(MPPotions.DARK_ENERGY_PROTECTION)) {
                                player.addPotionEffect(new PotionEffect(MPPotions.DARK_ENERGY, 200, 0));
                            }
                        }
                    }
                }
            }
            if (this.activatedTick < this.getSuccessfulTick()) {
                if (this.activatedTick % 20 == 0) {
                    this.world.playSound(null, this.pos.getX(), this.pos.getY(), this.pos.getZ(), MPSounds.MACHINE_ACTIVATE_AMBIENT, SoundCategory.BLOCKS, 1.0F, 1.025F);
                }
                if (this.activatedTick >= this.getSuccessfulTick() - 5 && this.activatedTick <= this.getSuccessfulTick()) {
                    this.world.playSound(null, this.pos.getX(), this.pos.getY(), this.pos.getZ(), MPSounds.MACHINE_STOP, SoundCategory.BLOCKS, 1.0F, 1.0F);
                }
                if (!this.failed) {
                    if (this.world.rand.nextInt(50) == 0) {
                        EntityDarkLightningBolt bolt = new EntityDarkLightningBolt(this.world);
                        bolt.setLocationAndAngles(this.pos.getX() + 3, this.pos.getY() + 2.5D, this.pos.getZ() + 3, 0.0F, 0.0F);
                        this.world.spawnEntity(bolt);
                    }
                    if (this.world.rand.nextInt(50) == 0) {
                        EntityDarkLightningBolt bolt = new EntityDarkLightningBolt(this.world);
                        bolt.setLocationAndAngles(this.pos.getX() - 3, this.pos.getY() + 2.5D, this.pos.getZ() + 3, 0.0F, 0.0F);
                        this.world.spawnEntity(bolt);
                    }
                    if (this.world.rand.nextInt(50) == 0) {
                        EntityDarkLightningBolt bolt = new EntityDarkLightningBolt(this.world);
                        bolt.setLocationAndAngles(this.pos.getX() + 3, this.pos.getY() + 2.5D, this.pos.getZ() - 3, 0.0F, 0.0F);
                        this.world.spawnEntity(bolt);
                    }
                    if (this.world.rand.nextInt(50) == 0) {
                        EntityDarkLightningBolt bolt = new EntityDarkLightningBolt(this.world);
                        bolt.setLocationAndAngles(this.pos.getX() - 3, this.pos.getY() + 2.5D, this.pos.getZ() - 3, 0.0F, 0.0F);
                        this.world.spawnEntity(bolt);
                    }
                    this.activatedTick++;
                }
            }
            if (this.failed) {
                this.failedTick++;
                if (this.world.rand.nextInt(12) == 0) {
                    EntityDarkLightningBolt bolt = new EntityDarkLightningBolt(this.world);
                    bolt.setLocationAndAngles(this.pos.getX() + 3, this.pos.getY() + 2.5D, this.pos.getZ() + 3, 0.0F, 0.0F);
                    this.world.spawnEntity(bolt);
                }
                if (this.world.rand.nextInt(12) == 0) {
                    EntityDarkLightningBolt bolt = new EntityDarkLightningBolt(this.world);
                    bolt.setLocationAndAngles(this.pos.getX() - 3, this.pos.getY() + 2.5D, this.pos.getZ() + 3, 0.0F, 0.0F);
                    this.world.spawnEntity(bolt);
                }
                if (this.world.rand.nextInt(12) == 0) {
                    EntityDarkLightningBolt bolt = new EntityDarkLightningBolt(this.world);
                    bolt.setLocationAndAngles(this.pos.getX() + 3, this.pos.getY() + 2.5D, this.pos.getZ() - 3, 0.0F, 0.0F);
                    this.world.spawnEntity(bolt);
                }
                if (this.world.rand.nextInt(12) == 0) {
                    EntityDarkLightningBolt bolt = new EntityDarkLightningBolt(this.world);
                    bolt.setLocationAndAngles(this.pos.getX() - 3, this.pos.getY() + 2.5D, this.pos.getZ() - 3, 0.0F, 0.0F);
                    this.world.spawnEntity(bolt);
                }
                if (this.failedTick % 20 == 0) {
                    this.world.playSound(null, this.pos.getX(), this.pos.getY(), this.pos.getZ(), MPSounds.MACHINE_ACTIVATE_AMBIENT, SoundCategory.BLOCKS, 1.0F, 1.025F);
                    this.world.playSound(null, this.pos.getX(), this.pos.getY(), this.pos.getZ(), MPSounds.MACHINE_DANGER, SoundCategory.BLOCKS, 5.0F, 1.0F);
                }
            }
            if (TileEntityDarkEnergyReceiver.checkValidMultiblock(this.pos, this.world)) {
                this.failed = true;
            }
            if (this.getEnergyStoredGC() < 20000.0F) {
                this.failed = true;
            }
            for (int yRender = this.pos.getY(); yRender < 256; yRender++) {
                IBlockState state = this.world.getBlockState(new BlockPos(this.pos.getX(), yRender, this.pos.getZ()));
                Block block = state.getBlock();
                if (state.isOpaqueCube() && block != DionaBlocks.DARK_ENERGY_CORE) {
                    this.failed = true;
                }
                if (this.facing == 0 || this.facing == 180) {
                    block = this.world.getBlockState(new BlockPos(this.pos.getX() + 1, yRender + 1, this.pos.getZ())).getBlock();
                    if (state.isOpaqueCube() && block != DionaBlocks.DARK_ENERGY_CORE) {
                        this.failed = true;
                    }
                    block = this.world.getBlockState(new BlockPos(this.pos.getX() - 1, yRender + 1, this.pos.getZ())).getBlock();
                    if (state.isOpaqueCube() && block != DionaBlocks.DARK_ENERGY_CORE) {
                        this.failed = true;
                    }
                }
                if (this.facing == -90 || this.facing == 90) {
                    block = this.world.getBlockState(new BlockPos(this.pos.getX(), yRender + 1, this.pos.getZ() + 1)).getBlock();
                    if (state.isOpaqueCube() && block != DionaBlocks.DARK_ENERGY_CORE) {
                        this.failed = true;
                    }
                    block = this.world.getBlockState(new BlockPos(this.pos.getX(), yRender + 1, this.pos.getZ() - 1)).getBlock();
                    if (state.isOpaqueCube() && block != DionaBlocks.DARK_ENERGY_CORE) {
                        this.failed = true;
                    }
                }
            }
            if (this.activatedTick == this.getSuccessfulTick()) {
                if (!this.successful) {
                    if (this.world.getBlockState(this.getPos().up()).getBlock() != DionaBlocks.DARK_ENERGY_CORE) {
                        EntityDarkLightningBolt bolt = new EntityDarkLightningBolt(this.world);
                        bolt.setLocationAndAngles(this.pos.getX(), this.pos.getY() + 2.5D, this.pos.getZ(), 0.0F, 0.0F);
                        this.world.playSound((EntityPlayer) null, this.pos.getX(), this.pos.getY() + 2.5D, this.pos.getZ(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, (1.0F + (this.world.rand.nextFloat() - this.world.rand.nextFloat()) * 0.2F) * 0.7F);
                        this.world.spawnEntity(bolt);
                        this.world.setBlockState(this.getPos().up(), DionaBlocks.DARK_ENERGY_CORE.getDefaultState());
                    }
                    for (Map.Entry<BlockPos, IBlockState> list : multiBlockLists.entrySet()) {
                        IBlockState state = list.getValue();
                        BlockPos pos = this.pos.add(list.getKey());
                        if (state != MPBlocks.DUNGEON_GLOWSTONE.getDefaultState() && state != DionaBlocks.INFECTED_CRYSTALLIZE_SLIME_BLOCK.getDefaultState()) {
                            for (int i = 0; i < 120; i++) {
                                MorePlanetsCore.PROXY.spawnParticle(EnumParticleTypesMP.DARK_PORTAL, pos.getX() + this.world.rand.nextDouble() * 1.0D, pos.getY() + this.world.rand.nextDouble() * 1.0D, pos.getZ() + this.world.rand.nextDouble() * 1.0D, 0.0D, -this.world.rand.nextDouble(), 0.0D);
                            }
                            this.world.setBlockToAir(pos);
                        } else {
                            this.world.setBlockState(pos, Blocks.OBSIDIAN.getDefaultState());
                        }
                    }
                    this.setDisabled(0, true);
                    this.activatedMessage = true;
                    this.successful = true;
                    FMLClientHandler.instance().getClient().player.sendMessage(new JsonUtil().text(GCCoreUtil.translate("gui.status.dark_energy_core_created.name")).setStyle(new JsonUtil().colorFromConfig("green")));
                }
            }
            if (this.failedTick > 600) {
                if (!this.spawnedBlackHole) {
                    EntityBlackHole blackHole = new EntityBlackHole(this.world);
                    blackHole.setLocationAndAngles(this.pos.getX() + 0.5D, this.pos.getY() + 2.0D, this.pos.getZ() + 0.5D, 0.0F, 0.0F);
                    this.world.spawnEntity(blackHole);
                    this.world.createExplosion(null, this.pos.getX(), this.pos.getY(), this.pos.getZ(), 5.0F, true);
                    this.world.destroyBlock(this.pos, false);
                    this.spawnedBlackHole = true;
                }
            }
        }
    } else {
        if (this.activated && !this.successful) {
            this.solarRotate++;
            this.solarRotate %= 180;
            if (this.getEnergyStoredGC() > 0.0F && !this.failed) {
                if (this.rodUp < 58) {
                    this.rodUp++;
                }
            } else {
                if (this.rodUp > 0) {
                    this.rodUp -= 0.25F;
                }
            }
        }
        if (this.successful && this.solarRotate < 180) {
            this.solarRotate++;
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) SPacketUpdateTileEntity(net.minecraft.network.play.server.SPacketUpdateTileEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) PotionEffect(net.minecraft.potion.PotionEffect) EntityBlackHole(stevekung.mods.moreplanets.entity.EntityBlackHole) EntityDarkLightningBolt(stevekung.mods.moreplanets.module.planets.diona.entity.EntityDarkLightningBolt) JsonUtil(stevekung.mods.moreplanets.util.JsonUtil) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) IMultiBlock(micdoodle8.mods.galacticraft.core.tile.IMultiBlock) BlockPos(net.minecraft.util.math.BlockPos) Map(java.util.Map) HashMap(java.util.HashMap)

Example 55 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project MorePlanets by SteveKunG.

the class WorldTickEventHandler method adjustPosToNearbyEntity.

private BlockPos adjustPosToNearbyEntity(World world, BlockPos pos) {
    BlockPos blockpos = world.getPrecipitationHeight(pos);
    AxisAlignedBB axisalignedbb = new AxisAlignedBB(blockpos, new BlockPos(blockpos.getX(), world.getHeight(), blockpos.getZ()));
    List<EntityLivingBase> list = world.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb, living -> living != null && living.isEntityAlive() && world.canSeeSky(living.getPosition()));
    if (!list.isEmpty()) {
        return list.get(world.rand.nextInt(list.size())).getPosition();
    } else {
        if (blockpos.getY() == -1) {
            blockpos = blockpos.up(2);
        }
        return blockpos;
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)597 BlockPos (net.minecraft.util.math.BlockPos)194 Entity (net.minecraft.entity.Entity)133 EntityPlayer (net.minecraft.entity.player.EntityPlayer)119 IBlockState (net.minecraft.block.state.IBlockState)110 Vec3d (net.minecraft.util.math.Vec3d)95 EntityLivingBase (net.minecraft.entity.EntityLivingBase)93 EnumFacing (net.minecraft.util.EnumFacing)88 ItemStack (net.minecraft.item.ItemStack)77 World (net.minecraft.world.World)69 TileEntity (net.minecraft.tileentity.TileEntity)67 List (java.util.List)48 ArrayList (java.util.ArrayList)47 RayTraceResult (net.minecraft.util.math.RayTraceResult)45 EntityItem (net.minecraft.entity.item.EntityItem)43 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)41 Block (net.minecraft.block.Block)36 PotionEffect (net.minecraft.potion.PotionEffect)36 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)25 Nullable (javax.annotation.Nullable)24