use of stevekung.mods.moreplanets.planets.nibiru.dimension.WorldProviderNibiru in project MorePlanets by SteveKunG.
the class BlockElectricalFire method updateTick.
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
if (world.getGameRules().getBoolean("doFireTick")) {
if (!world.isAreaLoaded(pos, 2)) {
return;
}
if (!this.canPlaceBlockAt(world, pos)) {
world.setBlockToAir(pos);
}
Block block = world.getBlockState(pos.down()).getBlock();
boolean flag = block.isFireSource(world, pos.down(), EnumFacing.UP);
if (!flag && world.isRaining() && this.canDie(world, pos)) {
world.setBlockToAir(pos);
} else {
int i = state.getValue(AGE);
if (i < 15) {
state = state.withProperty(AGE, i + rand.nextInt(3) / 2);
world.setBlockState(pos, state, 4);
}
world.scheduleUpdate(pos, this, this.tickRate(world) + rand.nextInt(10));
if (!flag) {
if (!this.canNeighborCatchFire(world, pos)) {
if ((!world.getBlockState(pos.down()).isSideSolid(world, pos.down(), EnumFacing.UP) || i > 3) && world.provider instanceof WorldProviderNibiru) {
world.setBlockToAir(pos);
}
return;
}
if (!this.canCatchFire(world, pos.down(), EnumFacing.UP) && i == 15 && rand.nextInt(4) == 0) {
world.setBlockToAir(pos);
return;
}
}
boolean flag1 = world.isBlockinHighHumidity(pos);
int j = 0;
if (flag1) {
j = -50;
}
this.tryCatchFire(world, pos.east(), 300 + j, rand, i, EnumFacing.WEST);
this.tryCatchFire(world, pos.west(), 300 + j, rand, i, EnumFacing.EAST);
this.tryCatchFire(world, pos.down(), 250 + j, rand, i, EnumFacing.UP);
this.tryCatchFire(world, pos.up(), 250 + j, rand, i, EnumFacing.DOWN);
this.tryCatchFire(world, pos.north(), 300 + j, rand, i, EnumFacing.SOUTH);
this.tryCatchFire(world, pos.south(), 300 + j, rand, i, EnumFacing.NORTH);
for (int k = -1; k <= 1; ++k) {
for (int l = -1; l <= 1; ++l) {
for (int i1 = -1; i1 <= 4; ++i1) {
if (k != 0 || i1 != 0 || l != 0) {
int j1 = 100;
if (i1 > 1) {
j1 += (i1 - 1) * 100;
}
BlockPos blockpos = pos.add(k, i1, l);
int k1 = this.getNeighborEncouragement(world, blockpos);
if (k1 > 0) {
int l1 = (k1 + 40 + world.getDifficulty().getId() * 7) / (i + 30);
if (flag1) {
l1 /= 2;
}
if (l1 > 0 && rand.nextInt(j1) <= l1 && (!world.isRaining() || !this.canDie(world, blockpos))) {
int i2 = i + rand.nextInt(5) / 4;
if (i2 > 15) {
i2 = 15;
}
world.setBlockState(blockpos, state.withProperty(AGE, i2), 3);
}
}
}
}
}
}
}
}
}
use of stevekung.mods.moreplanets.planets.nibiru.dimension.WorldProviderNibiru in project MorePlanets by SteveKunG.
the class EntityEventHandler method onLivingUpdate.
@SubscribeEvent
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
EntityLivingBase living = event.getEntityLiving();
World world = living.world;
if (living instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) living;
if (player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) || this.isInOxygen(world, player)) {
player.removePotionEffect(MPPotions.INFECTED_SPORE);
}
if (player.isPotionActive(MPPotions.DARK_ENERGY_PROTECTION)) {
player.removePotionEffect(MPPotions.DARK_ENERGY);
}
if (world.provider instanceof WorldProviderNibiru) {
if (!this.isGodPlayer(player) && !player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) && !(world.getBiome(player.getPosition()) instanceof BiomeGreenVeinFields)) {
if (world.isRainingAt(player.getPosition())) {
player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 40));
}
if (player.ticksExisted % 128 == 0 && !this.isInOxygen(world, player)) {
player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80));
}
}
}
if (!world.isRemote && world.provider instanceof IMeteorType) {
this.spawnMeteors(world, player, (IMeteorType) world.provider);
}
} else {
if (ConfigManagerMP.moreplanets_planet_settings.enableInfectedSporeForMobs && world.provider instanceof WorldProviderNibiru) {
if (!EntityEffectUtils.isGalacticraftMob(living) && !(living instanceof EntityJuicer) && !(world.getBiome(living.getPosition()) instanceof BiomeGreenVeinFields)) {
if (living.ticksExisted % 128 == 0) {
living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80));
} else if (world.isRainingAt(living.getPosition())) {
living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 40));
}
}
}
}
if (living instanceof IMob) {
for (BlockVec3Dim vec : TileEntityShieldGenerator.LOADED_GENERATORS) {
if (vec != null && vec.dim == GCCoreUtil.getDimensionID(world)) {
TileEntity tile = vec.getTileEntity();
if (tile instanceof TileEntityShieldGenerator) {
TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
if (!living.world.isRemote && !living.isDead && shield.isInsideShield(living.getPosition()) && !shield.disabled && shield.enableShield && shield.shieldCapacity > 0) {
if (!shield.enableDamage) {
double d4 = living.getDistance(tile.getPos().getX(), tile.getPos().getY(), tile.getPos().getZ());
double d6 = living.posX - tile.getPos().getX();
double d8 = living.posY - tile.getPos().getY();
double d10 = living.posZ - tile.getPos().getZ();
double d11 = MathHelper.sqrt(d6 * d6 + d8 * d8 + d10 * d10);
d6 /= d11;
d8 /= d11;
d10 /= d11;
double d13 = (0.0D - d4) * 2.0D / 10.0D;
double d14 = d13;
double knockback = 10.0D;
living.motionX -= d6 * d14 / knockback;
living.motionY -= d8 * d14 / knockback;
living.motionZ -= d10 * d14 / knockback;
}
UUID uuid;
try {
uuid = UUID.fromString(shield.ownerUUID);
} catch (Exception e) {
// default uuid :)
uuid = UUID.fromString("eef3a603-1c1b-4c98-8264-d2f04b231ef4");
}
if (living.world.getPlayerEntityByUUID(uuid) != null) {
if (living.ticksExisted % 8 == 0) {
((WorldServer) living.world).spawnParticle(EnumParticleTypes.CRIT_MAGIC, living.posX, living.posY, living.posZ, 20, 0.0D, 0.5D, 0.0D, 1.0D);
}
if (shield.enableDamage) {
living.attackEntityFrom(DamageSource.causePlayerDamage(living.world.getPlayerEntityByUUID(uuid)), shield.shieldDamage);
}
} else {
if (living.ticksExisted % 8 == 0) {
((WorldServer) living.world).spawnParticle(EnumParticleTypes.CRIT_MAGIC, living.posX, living.posY, living.posZ, 20, 0.0D, 0.5D, 0.0D, 1.0D);
}
if (shield.enableDamage) {
living.attackEntityFrom(DamageSource.GENERIC, shield.shieldDamage);
}
}
float motion = MathHelper.sqrt(living.motionX * living.motionX + living.motionZ * living.motionZ);
shield.shieldCapacity -= motion * 2;
}
}
}
}
}
}
use of stevekung.mods.moreplanets.planets.nibiru.dimension.WorldProviderNibiru in project MorePlanets by SteveKunG.
the class WorldTickEventHandler method onWeatherTick.
@SubscribeEvent
public void onWeatherTick(WeatherTickEvent event) {
World world = event.getWorld();
BlockPos pos = event.getStrikePos();
if (DimensionManager.getWorld(ConfigManagerMP.moreplanets_dimension.idDimensionDiona) != null) {
if (world.provider instanceof WorldProviderDiona) {
if (this.canBeamStrike(world, pos) && world.rand.nextInt(75000) == 0) {
if (world.isBlockLoaded(pos)) {
EntityAlienBeam beam = new EntityAlienBeam(world, pos.getX(), pos.getY(), pos.getZ());
beam.spawnWeather();
}
}
}
}
if (DimensionManager.getWorld(ConfigManagerMP.moreplanets_dimension.idDimensionNibiru) != null) {
if (world.provider instanceof WorldProviderNibiru) {
boolean raining = world.isRaining();
boolean thunder = world.isThundering();
Biome biome = world.getBiome(pos);
if (world.provider.canDoLightning(event.getChunk()) && raining && thunder && world.rand.nextInt(1000) == 0) {
if (world.isRainingAt(pos)) {
EntityNibiruLightningBolt boltFire = new EntityNibiruLightningBolt(world, pos.getX(), pos.getY(), pos.getZ(), true);
boltFire.spawnWeather();
}
}
if (world.rand.nextInt(16) == 0) {
BlockPos pos1 = pos.down();
if (world.isAreaLoaded(pos1, 1)) {
if (world.canBlockFreezeNoWater(pos1)) {
world.setBlockState(pos1, MPBlocks.INFECTED_ICE.getDefaultState());
}
}
if (raining) {
if (world.canSnowAt(pos, true)) {
world.setBlockState(pos, biome == MPBiomes.COLD_GREEN_VEIN_MOUTAINS ? MPBlocks.PURIFIED_SNOW_LAYER.getDefaultState() : MPBlocks.INFECTED_SNOW_LAYER.getDefaultState());
}
if (world.getBiome(pos1).canRain()) {
world.getBlockState(pos1).getBlock().fillWithRain(world, pos1);
}
}
}
if (biome instanceof BiomeInfectedDesert || biome instanceof BiomeInfectedMountains || biome instanceof BiomeInfectedBadlands) {
if (world.rand.nextInt(250000) == 0) {
EntityNibiruLightningBolt bolt = new EntityNibiruLightningBolt(world, pos.getX(), pos.getY(), pos.getZ(), false);
bolt.spawnWeather();
}
}
}
}
}
use of stevekung.mods.moreplanets.planets.nibiru.dimension.WorldProviderNibiru in project MorePlanets by SteveKunG.
the class ClientEventHandler method onAddRainParticle.
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onAddRainParticle(AddRainParticleEvent event) {
World world = event.getWorld();
BlockPos pos = new BlockPos(event.getX(), event.getY(), event.getZ());
Biome biome = world.getBiome(pos);
if (world.provider instanceof WorldProviderNibiru) {
event.setCanceled(true);
if (biome == MPBiomes.GREEN_VEIN_FIELDS || biome == MPBiomes.GREEN_VEIN_FIELD_SHORE) {
MorePlanetsMod.PROXY.spawnParticle(EnumParticleTypesMP.PURIFIED_RAIN, event.getX(), event.getY(), event.getZ());
} else {
MorePlanetsMod.PROXY.spawnParticle(EnumParticleTypesMP.INFECTED_RAIN, event.getX(), event.getY(), event.getZ());
}
}
}
Aggregations