use of stevekung.mods.moreplanets.module.planets.nibiru.entity.weather.EntityNibiruLightningBolt in project MorePlanets by SteveKunG.
the class EntityVeinFloater method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
MorePlanetsCore.PROXY.addBoss(this);
this.motionY *= 0.5D;
if (this.getHealth() <= 0.0F) {
int i = (300 + this.rand.nextInt(600)) * 20;
WorldInfo worldinfo = this.world.getWorldInfo();
worldinfo.setCleanWeatherTime(0);
worldinfo.setRainTime(i);
worldinfo.setThunderTime(i);
worldinfo.setRaining(true);
worldinfo.setThundering(false);
this.dataManager.set(VINE_PULL, false);
return;
}
int tick = this.ticksExisted;
tick %= 600;
if (this.getHealth() <= this.getMaxHealth() / 2) {
if (!this.isDead) {
if (tick > 300) {
this.dataManager.set(VINE_PULL, true);
} else {
this.dataManager.set(VINE_PULL, false);
}
}
} else {
this.dataManager.set(VINE_PULL, false);
if (!this.world.isRemote && this.ticksExisted % 200 == 0) {
List<EntityVeinFloaterMinion> minionList = this.world.getEntitiesWithinAABB(EntityVeinFloaterMinion.class, new AxisAlignedBB(this.posX - 32, this.posY - 32, this.posZ - 32, this.posX + 32, this.posY + 32, this.posZ + 32));
if (minionList.size() <= 32) {
EntityVeinFloaterMinion tentacle1 = new EntityVeinFloaterMinion(this.world);
tentacle1.setLocationAndAngles(this.posX + 2.0F, this.posY + 12.0F, this.posZ + 2.0F, 0.0F, 0.0F);
tentacle1.setAbsorptionAmount(20.0F);
this.world.spawnEntity(tentacle1);
EntityVeinFloaterMinion tentacle2 = new EntityVeinFloaterMinion(this.world);
tentacle2.setLocationAndAngles(this.posX - 2.0F, this.posY + 12.0F, this.posZ - 2.0F, 0.0F, 0.0F);
tentacle2.setAbsorptionAmount(20.0F);
this.world.spawnEntity(tentacle2);
EntityVeinFloaterMinion tentacle3 = new EntityVeinFloaterMinion(this.world);
tentacle3.setLocationAndAngles(this.posX + 2.0F, this.posY + 12.0F, this.posZ - 2.0F, 0.0F, 0.0F);
tentacle3.setAbsorptionAmount(20.0F);
this.world.spawnEntity(tentacle3);
EntityVeinFloaterMinion tentacle4 = new EntityVeinFloaterMinion(this.world);
tentacle4.setLocationAndAngles(this.posX - 2.0F, this.posY + 12.0F, this.posZ + 2.0F, 0.0F, 0.0F);
tentacle4.setAbsorptionAmount(20.0F);
this.world.spawnEntity(tentacle4);
}
}
}
if (this.getVinePull()) {
int range = 16;
List<EntityPlayer> entitiesAroundBH = this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(this.posX - range, this.posY - range, this.posZ - range, this.posX + range, this.posY + range, this.posZ + range));
for (EntityPlayer entity : entitiesAroundBH) {
if (!entity.capabilities.isCreativeMode) {
double motionX = this.posX - entity.posX;
double motionY = this.posY - entity.posY + 12.0D;
double motionZ = this.posZ - entity.posZ;
entity.motionX = motionX * 0.025F;
entity.motionY = motionY * 0.025F;
entity.motionZ = motionZ * 0.025F;
List<EntityPlayer> entityNearBH = this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(this.posX - 1.0D, this.posY - 1.0D, this.posZ - 1.0D, this.posX + 5.0D, this.posY + 12.5D, this.posZ + 5.0D));
for (EntityPlayer near : entityNearBH) {
near.attackEntityFrom(DamageSource.causeMobDamage(this), 8.0F);
}
}
}
}
if (this.getHealth() <= this.getMaxHealth() / 3) {
int i = (300 + this.rand.nextInt(600)) * 20;
WorldInfo worldinfo = this.world.getWorldInfo();
worldinfo.setCleanWeatherTime(0);
worldinfo.setRainTime(i);
worldinfo.setThunderTime(i);
worldinfo.setRaining(true);
worldinfo.setThundering(true);
if (this.rand.nextFloat() > 0.975F && !this.isDead) {
EntityPlayer player = this.world.getClosestPlayer(this.posX, this.posY, this.posZ, 32, false);
if (player != null && !player.capabilities.isCreativeMode && !player.isDead) {
EntityNibiruLightningBolt bolt = new EntityNibiruLightningBolt(this.world);
bolt.setLocationAndAngles(player.posX, player.posY, player.posZ, 0.0F, 0.0F);
this.world.spawnEntity(bolt);
}
}
}
}
use of stevekung.mods.moreplanets.module.planets.nibiru.entity.weather.EntityNibiruLightningBolt in project MorePlanets by SteveKunG.
the class WorldTickEventHandler method onServerTick.
@SubscribeEvent
public void onServerTick(ServerTickEvent event) {
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if (server == null) {
return;
}
if (event.phase == Phase.START) {
if (WorldTickEventHandler.startedDimensionData == null) {
World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(0);
WorldTickEventHandler.startedDimensionData = (WorldDataStartedDimension) world.getMapStorage().getOrLoadData(WorldDataStartedDimension.class, WorldDataStartedDimension.saveDataID);
if (WorldTickEventHandler.startedDimensionData == null) {
WorldTickEventHandler.startedDimensionData = new WorldDataStartedDimension(WorldDataStartedDimension.saveDataID);
world.getMapStorage().setData(WorldDataStartedDimension.saveDataID, WorldTickEventHandler.startedDimensionData);
}
}
}
if (event.phase == Phase.END) {
World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(ConfigManagerMP.idDimensionDiona);
if (world.provider instanceof WorldProviderDiona) {
if (world instanceof WorldServer) {
WorldServer worldServer = (WorldServer) world;
for (Iterator<Chunk> iterator = world.getPersistentChunkIterable(worldServer.getPlayerChunkMap().getChunkIterator()); iterator.hasNext(); world.profiler.endSection()) {
Chunk chunk = iterator.next();
int j = chunk.x * 16;
int k = chunk.z * 16;
if (world.rand.nextInt(75000) == 0) {
this.updateLCG = this.updateLCG * 3 + 1013904223;
int l = this.updateLCG >> 2;
BlockPos blockpos = this.adjustPosToNearbyEntity(world, new BlockPos(j + (l & 15), 0, k + (l >> 8 & 15)));
if (this.canBeamStrike(world, blockpos)) {
EntityAlienBeam beam = new EntityAlienBeam(world);
beam.setLocationAndAngles(blockpos.getX(), blockpos.getY(), blockpos.getZ(), 0.0F, 0.0F);
world.spawnEntity(beam);
}
}
}
}
}
world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(ConfigManagerMP.idDimensionNibiru);
if (world.provider instanceof WorldProviderNibiru) {
if (world instanceof WorldServer) {
WorldServer worldServer = (WorldServer) world;
for (Iterator<Chunk> iterator = world.getPersistentChunkIterable(worldServer.getPlayerChunkMap().getChunkIterator()); iterator.hasNext(); world.profiler.endSection()) {
Chunk chunk = iterator.next();
int j = chunk.x * 16;
int k = chunk.z * 16;
boolean flag = world.isRaining();
boolean flag1 = world.isThundering();
if (world.provider.canDoLightning(chunk) && flag && flag1 && world.rand.nextInt(1000) == 0) {
this.updateLCG = this.updateLCG * 3 + 1013904223;
int l = this.updateLCG >> 2;
BlockPos blockpos = this.adjustPosToNearbyEntity(world, new BlockPos(j + (l & 15), 0, k + (l >> 8 & 15)));
if (world.isRainingAt(blockpos)) {
world.spawnEntity(new EntityNibiruLightningBolt(world, blockpos.getX(), blockpos.getY(), blockpos.getZ(), true));
}
}
if (world.rand.nextInt(16) == 0) {
this.updateLCG = this.updateLCG * 3 + 1013904223;
int j2 = this.updateLCG >> 2;
BlockPos blockpos1 = world.getPrecipitationHeight(new BlockPos(j + (j2 & 15), 0, k + (j2 >> 8 & 15)));
BlockPos blockpos2 = blockpos1.down();
if (world.canBlockFreezeNoWater(blockpos2)) {
world.setBlockState(blockpos2, NibiruBlocks.INFECTED_ICE.getDefaultState());
}
if (flag && world.canSnowAt(blockpos1, true)) {
world.setBlockState(blockpos1, NibiruBlocks.INFECTED_SNOW_LAYER.getDefaultState());
}
if (flag && world.getBiome(blockpos2).canRain()) {
world.getBlockState(blockpos2).getBlock().fillWithRain(world, blockpos2);
}
}
if (world.getBiome(new BlockPos(j, 0, k)) == MPBiomes.INFECTED_DESERT || world.getBiome(new BlockPos(j, 0, k)) == MPBiomes.INFECTED_EXTREME_HILLS) {
if (world.rand.nextInt(250000) == 0) {
this.updateLCG = this.updateLCG * 3 + 1013904223;
int l = this.updateLCG >> 2;
BlockPos blockpos = this.adjustPosToNearbyEntity(world, new BlockPos(j + (l & 15), 0, k + (l >> 8 & 15)));
world.spawnEntity(new EntityNibiruLightningBolt(world, blockpos.getX(), blockpos.getY(), blockpos.getZ(), false));
}
}
}
}
}
}
}
Aggregations