use of stevekung.mods.moreplanets.module.planets.nibiru.entity.EntityVeinFloater in project MorePlanets by SteveKunG.
the class EntityNibiruLightningBolt method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
if (this.lightningState == 2) {
this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, this.world.rand.nextInt(5) == 0 ? SoundEvents.ENTITY_LIGHTNING_THUNDER : MPSounds.LOUD_THUNDER, SoundCategory.WEATHER, 20.0F, 0.8F + this.rand.nextFloat() * 0.2F);
this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_LIGHTNING_IMPACT, SoundCategory.WEATHER, 2.0F, 0.5F + 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();
BlockPos blockpos = new BlockPos(this);
if (!this.world.isRemote && this.fire && this.world.getGameRules().getBoolean("doFireTick")) {
if (this.world.isAreaLoaded(blockpos, 10) && this.world.getBlockState(blockpos).getMaterial() == Material.AIR && NibiruBlocks.ELECTRICAL_FIRE.canPlaceBlockAt(this.world, blockpos)) {
this.world.setBlockState(blockpos, NibiruBlocks.ELECTRICAL_FIRE.getDefaultState());
}
if (this.world.rand.nextInt(4) == 0) {
for (int i = 0; i < 4; ++i) {
BlockPos blockpos1 = blockpos.add(this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1);
if (this.world.getBlockState(blockpos1).getMaterial() == Material.AIR && NibiruBlocks.ELECTRICAL_FIRE.canPlaceBlockAt(this.world, blockpos1)) {
this.world.setBlockState(blockpos1, NibiruBlocks.ELECTRICAL_FIRE.getDefaultState());
}
}
}
}
}
}
if (this.lightningState >= 0) {
if (this.world.isRemote) {
this.world.setLastLightningBolt(2);
} else {
double d0 = 3.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 EntityVeinFloater)) {
entity.attackEntityFrom(DamageSource.LIGHTNING_BOLT, 8.0F);
entity.setFire(8);
}
}
}
}
}
use of stevekung.mods.moreplanets.module.planets.nibiru.entity.EntityVeinFloater in project MorePlanets by SteveKunG.
the class TileEntityVeinPortal method update.
@Override
public void update() {
super.update();
if (this.age < 5L) {
this.age++;
}
if (!this.world.isRemote) {
if (this.age < 5L) {
ArrayList<TileEntity> attachedList = new ArrayList<>();
for (int x = this.getPos().getX() - 1; x < this.getPos().getX() + 2; x++) {
for (int z = this.getPos().getZ() - 1; z < this.getPos().getZ() + 2; z++) {
TileEntity tile = this.world.getTileEntity(new BlockPos(x, this.getPos().getY(), z));
if (tile instanceof TileEntityVeinPortal) {
attachedList.add(tile);
}
}
}
if (attachedList.size() == 9) {
this.world.setBlockState(this.getPos(), NibiruBlocks.VEIN_PORTAL.getDefaultState(), 3);
TileEntityVeinPortal portal = this;
this.isMiddle = true;
this.world.setTileEntity(this.getPos(), portal);
for (int x = -1; x < 2; x++) {
for (int z = -1; z < 2; z++) {
BlockPos vecToAdd = new BlockPos(this.getPos().getX() + x, this.getPos().getY(), this.getPos().getZ() + z);
if (!vecToAdd.equals(this.getPos())) {
this.world.setBlockState(vecToAdd, NibiruBlocks.VEIN_PORTAL.getDefaultState(), 3);
this.delayToTeleport = 120;
}
}
}
}
if (this.isMiddle) {
if (!this.spawnedBoss) {
EntityVeinFloater vein = new EntityVeinFloater(this.world);
vein.setLocationAndAngles(this.getPos().getX() + 0.5D, this.getPos().getY() + 64, this.getPos().getZ() + 0.5D, 0.0F, 0.0F);
this.world.spawnEntity(vein);
this.spawnedBoss = true;
}
for (int yRender = this.pos.getY(); yRender < 99; yRender++) {
this.world.setBlockToAir(new BlockPos(this.pos.getX(), yRender + 1, this.pos.getZ()));
this.world.notifyBlockUpdate(this.pos, this.world.getBlockState(this.pos), NibiruBlocks.VEIN_PORTAL.getDefaultState(), 3);
}
}
}
}
if (this.isMiddle) {
EntityPlayer player = this.world.getClosestPlayer(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), 64, false);
List<EntityVeinFloater> vein = this.world.getEntitiesWithinAABB(EntityVeinFloater.class, new AxisAlignedBB(this.getPos().getX() - 256, this.getPos().getY() - 256, this.getPos().getZ() - 256, this.getPos().getX() + 256, this.getPos().getY() + 256, this.getPos().getZ() + 256));
if (this.delayToTeleport > 0) {
this.delayToTeleport--;
}
if (this.delayToTeleport == 1) {
if (player instanceof EntityPlayerMP) {
EntityPlayerMP playerMP = (EntityPlayerMP) player;
playerMP.dismountRidingEntity();
playerMP.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 120, 10));
playerMP.connection.setPlayerLocation(playerMP.posX, playerMP.posY + 64, playerMP.posZ, playerMP.rotationYaw, playerMP.rotationPitch);
}
}
if (this.renderTicks % 50 == 0 && vein.isEmpty()) {
this.isMiddle = false;
}
}
}
Aggregations