Search in sources :

Example 56 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project BetterRain by OreCruncher.

the class StormSplashRenderer method addRainParticles.

public void addRainParticles(final EntityRenderer theThis) {
    if (theThis.mc.gameSettings.particleSetting == 2)
        return;
    if (!DimensionRegistry.hasWeather(EnvironState.getWorld()))
        return;
    float rainStrengthFactor = theThis.mc.theWorld.getRainStrength(1.0F);
    if (!theThis.mc.gameSettings.fancyGraphics)
        rainStrengthFactor /= 2.0F;
    if (rainStrengthFactor <= 0.0F)
        return;
    RANDOM.setSeed((long) theThis.rendererUpdateCount * 312987231L);
    final Entity entity = theThis.mc.getRenderViewEntity();
    final WorldClient worldclient = theThis.mc.theWorld;
    final int playerX = MathHelper.floor_double(entity.posX);
    final int playerY = MathHelper.floor_double(entity.posY);
    final int playerZ = MathHelper.floor_double(entity.posZ);
    double spawnX = 0.0D;
    double spawnY = 0.0D;
    double spawnZ = 0.0D;
    int particlesSpawned = 0;
    int particleCount = (int) (ModOptions.particleCountBase * rainStrengthFactor * rainStrengthFactor);
    if (theThis.mc.gameSettings.particleSetting == 1)
        particleCount >>= 1;
    BlockPos.MutableBlockPos posXZ = new BlockPos.MutableBlockPos();
    for (int j1 = 0; j1 < particleCount; ++j1) {
        final int locX = playerX + RANDOM.nextInt(RANGE) - RANDOM.nextInt(RANGE);
        final int locZ = playerZ + RANDOM.nextInt(RANGE) - RANDOM.nextInt(RANGE);
        posXZ.set(locX, 0, locZ);
        final BlockPos precipHeight = getPrecipitationHeight(worldclient, RANGE / 2, posXZ);
        final BiomeGenBase biome = worldclient.getBiomeGenForCoords(posXZ);
        final boolean hasDust = WeatherUtils.biomeHasDust(biome);
        if (precipHeight.getY() <= playerY + RANGE && precipHeight.getY() >= playerY - RANGE && (hasDust || (BiomeRegistry.hasPrecipitation(biome) && biome.getFloatTemperature(precipHeight) >= 0.15F))) {
            final Block block = worldclient.getBlockState(precipHeight.down()).getBlock();
            final double posX = locX + RANDOM.nextFloat();
            final double posY = precipHeight.getY() + 0.1F - block.getBlockBoundsMinY();
            final double posZ = locZ + RANDOM.nextFloat();
            final EntityFX particle = getBlockParticleFX(block, hasDust, worldclient, posX, posY, posZ);
            if (particle != null)
                theThis.mc.effectRenderer.addEffect(particle);
            if (RANDOM.nextInt(++particlesSpawned) == 0) {
                spawnX = posX;
                spawnY = posY;
                spawnZ = posZ;
            }
        }
    }
    if (particlesSpawned > 0 && RANDOM.nextInt(PARTICLE_SOUND_CHANCE) < theThis.rainSoundCounter++) {
        theThis.rainSoundCounter = 0;
        playSplashSound(theThis, worldclient, entity, spawnX, spawnY, spawnZ);
    }
}
Also used : Entity(net.minecraft.entity.Entity) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.BlockPos) EntityFX(net.minecraft.client.particle.EntityFX) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) WorldClient(net.minecraft.client.multiplayer.WorldClient)

Example 57 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project BetterRain by OreCruncher.

the class PlayerUtils method getPlayerBiome.

public static BiomeGenBase getPlayerBiome(final EntityPlayer player, final boolean getTrue) {
    final int theX = MathHelper.floor_double(player.posX);
    final int theY = MathHelper.floor_double(player.posY);
    final int theZ = MathHelper.floor_double(player.posZ);
    BiomeGenBase biome = player.worldObj.getBiomeGenForCoords(new BlockPos(theX, 0, theZ));
    if (!getTrue) {
        if (isUnderWater(player)) {
            if (REGEX_DEEP_OCEAN.matcher(biome.biomeName).matches())
                biome = BiomeRegistry.UNDERDEEPOCEAN;
            else if (REGEX_OCEAN.matcher(biome.biomeName).matches())
                biome = BiomeRegistry.UNDEROCEAN;
            else if (REGEX_RIVER.matcher(biome.biomeName).matches())
                biome = BiomeRegistry.UNDERRIVER;
            else
                biome = BiomeRegistry.UNDERWATER;
        } else if (isUnderGround(player, INSIDE_Y_ADJUST))
            biome = BiomeRegistry.UNDERGROUND;
        else if (theY >= DimensionRegistry.getSpaceHeight(player.worldObj))
            biome = BiomeRegistry.OUTERSPACE;
        else if (theY >= DimensionRegistry.getCloudHeight(player.worldObj))
            biome = BiomeRegistry.CLOUDS;
    }
    return biome;
}
Also used : BlockPos(net.minecraft.util.BlockPos) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Example 58 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project MineFactoryReloaded by powercrystals.

the class MineFactoryReloadedWorldGen method generate.

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
    if (_blacklistedDimensions == null) {
        _blacklistedDimensions = buildBlacklistedDimensions();
    }
    if (_blacklistedDimensions.contains(world.provider.dimensionId)) {
        return;
    }
    int x = chunkX * 16 + random.nextInt(16);
    int z = chunkZ * 16 + random.nextInt(16);
    BiomeGenBase b = world.getBiomeGenForCoords(x, z);
    if (MFRConfig.rubberTreeWorldGen.getBoolean(true)) {
        if (MFRRegistry.getRubberTreeBiomes().contains(b.biomeName)) {
            if (random.nextInt(100) < 40) {
                new WorldGenRubberTree().generate(world, random, x, random.nextInt(3) + 4, z);
            }
        }
    }
    if (MFRConfig.mfrLakeWorldGen.getBoolean(true) && world.provider.canRespawnHere()) {
        if (random.nextInt(MFRConfig.mfrLakeSludgeRarity.getInt()) == 0) {
            int lakeX = x - 8 + random.nextInt(16);
            int lakeY = random.nextInt(128);
            int lakeZ = z - 8 + random.nextInt(16);
            new WorldGenLakesMeta(MineFactoryReloadedCore.sludgeLiquid.blockID, 7).generate(world, random, lakeX, lakeY, lakeZ);
        }
        if (random.nextInt(MFRConfig.mfrLakeSewageRarity.getInt()) == 0) {
            int lakeX = x - 8 + random.nextInt(16);
            int lakeY = random.nextInt(128);
            int lakeZ = z - 8 + random.nextInt(16);
            if (b.biomeName.toLowerCase().contains("mushroom")) {
                new WorldGenLakesMeta(MineFactoryReloadedCore.mushroomSoupLiquid.blockID, 7).generate(world, random, lakeX, lakeY, lakeZ);
            } else {
                new WorldGenLakesMeta(MineFactoryReloadedCore.sewageLiquid.blockID, 7).generate(world, random, lakeX, lakeY, lakeZ);
            }
        }
    }
}
Also used : BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Example 59 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project ForestryMC by ForestryMC.

the class TileBeehouse method updateBiome.

public void updateBiome() {
    if (worldObj != null) {
        BiomeGenBase biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
        if (biome != null) {
            this.biome = biome;
            setErrorState(EnumErrorCode.OK);
        }
    }
}
Also used : BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Example 60 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project ForestryMC by ForestryMC.

the class ItemHabitatLocator method onUpdate.

@Override
public void onUpdate(ItemStack p_77663_1_, World world, Entity player, int p_77663_4_, boolean p_77663_5_) {
    if (!Proxies.common.isSimulating(world)) {
        return;
    }
    if (this.searchCenter == null) {
        this.searchCenter = new Vect((int) player.posX, (int) player.posY, (int) player.posZ);
        BiomeGenBase currentBiome = world.getBiomeGenForCoords(searchCenter.x, searchCenter.z);
        removeInvalidBiomes(currentBiome, biomesToSearch);
    }
    if (biomesToSearch.isEmpty()) {
        return;
    }
    // once we've found the biome, slow down to conserve cpu and network data
    if (biomeFound && world.getTotalWorldTime() % 20 != 0) {
        return;
    }
    ChunkCoordinates target = findNearestBiome(player, biomesToSearch);
    // send an update if we find the biome
    if (target != null) {
        Proxies.common.setHabitatLocatorCoordinates(player, target);
        biomeFound = true;
    }
}
Also used : Vect(forestry.core.vect.Vect) ChunkCoordinates(net.minecraft.util.ChunkCoordinates) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Aggregations

BiomeGenBase (net.minecraft.world.biome.BiomeGenBase)63 BlockPos (net.minecraft.util.BlockPos)10 Block (net.minecraft.block.Block)8 World (net.minecraft.world.World)5 Type (net.minecraftforge.common.BiomeDictionary.Type)5 ArrayList (java.util.ArrayList)4 EnumHumidity (forestry.api.core.EnumHumidity)3 IBlockState (net.minecraft.block.state.IBlockState)3 ChunkCoordIntPair (net.minecraft.world.ChunkCoordIntPair)3 BiomeDictionary (net.minecraftforge.common.BiomeDictionary)3 IBeeGenome (forestry.api.apiculture.IBeeGenome)2 EnumTemperature (forestry.api.core.EnumTemperature)2 File (java.io.File)2 HashSet (java.util.HashSet)2 Random (java.util.Random)2 Material (net.minecraft.block.material.Material)2 Entity (net.minecraft.entity.Entity)2 ChunkCoordinates (net.minecraft.util.ChunkCoordinates)2 EventHandler (net.minecraftforge.fml.common.Mod.EventHandler)2 Color (org.blockartistry.mod.DynSurround.util.Color)2