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();
}
}
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);
}
}
}
}
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);
}
}
}
}
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++;
}
}
}
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;
}
}
Aggregations