Search in sources :

Example 1 with BiomeGenBase

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

the class StormRenderer method render.

/**
 * Render rain and snow
 */
public void render(final EntityRenderer renderer, final float partialTicks) {
    StormProperties.setTextures();
    final World world = renderer.mc.theWorld;
    IRenderHandler r = world.provider.getWeatherRenderer();
    if (r != null) {
        r.render(partialTicks, (WorldClient) world, renderer.mc);
        return;
    }
    if (!DimensionRegistry.hasWeather(world))
        return;
    final float rainStrength = world.getRainStrength(partialTicks);
    if (rainStrength <= 0.0F)
        return;
    final float alphaRatio;
    if (StormProperties.getIntensityLevel() > 0.0F)
        alphaRatio = world.rainingStrength / StormProperties.getIntensityLevel();
    else
        alphaRatio = rainStrength;
    renderer.enableLightmap();
    final Entity entity = renderer.mc.getRenderViewEntity();
    final int playerX = MathHelper.floor_double(entity.posX);
    final int playerY = MathHelper.floor_double(entity.posY);
    final int playerZ = MathHelper.floor_double(entity.posZ);
    final Tessellator tess = Tessellator.getInstance();
    final WorldRenderer worldrenderer = tess.getWorldRenderer();
    GlStateManager.disableCull();
    GL11.glNormal3f(0.0F, 1.0F, 0.0F);
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    GlStateManager.alphaFunc(516, 0.1F);
    final double spawnX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
    final double spawnY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
    final double spawnZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;
    final int locY = MathHelper.floor_double(spawnY);
    final int range = renderer.mc.gameSettings.fancyGraphics ? 10 : 5;
    int j1 = -1;
    float f1 = (float) renderer.rendererUpdateCount + partialTicks;
    worldrenderer.setTranslation(-spawnX, -spawnY, -spawnZ);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos();
    for (int gridZ = playerZ - range; gridZ <= playerZ + range; ++gridZ) {
        for (int gridX = playerX - range; gridX <= playerX + range; ++gridX) {
            final int idx = (gridZ - playerZ + 16) * 32 + gridX - playerX + 16;
            final double rainX = (double) RAIN_X_COORDS[idx] * 0.5D;
            final double rainY = (double) RAIN_Y_COORDS[idx] * 0.5D;
            mutable.set(gridX, 0, gridZ);
            final BiomeGenBase biome = world.getBiomeGenForCoords(mutable);
            final boolean hasDust = WeatherUtils.biomeHasDust(biome);
            if (hasDust || BiomeRegistry.hasPrecipitation(biome)) {
                final int precipHeight = getPrecipitationHeight(world, mutable).getY();
                int k2 = playerY - range;
                int l2 = playerY + range;
                if (k2 < precipHeight) {
                    k2 = precipHeight;
                }
                if (l2 < precipHeight) {
                    l2 = precipHeight;
                }
                int i3 = precipHeight;
                if (precipHeight < locY) {
                    i3 = locY;
                }
                if (k2 != l2) {
                    random.setSeed((long) (gridX * gridX * 3121 + gridX * 45238971 ^ gridZ * gridZ * 418711 + gridZ * 13761));
                    mutable.set(gridX, k2, gridZ);
                    final float biomeTemp = biome.getFloatTemperature(mutable);
                    final float heightTemp = world.getWorldChunkManager().getTemperatureAtHeight(biomeTemp, precipHeight);
                    if (!hasDust && heightTemp >= 0.15F) {
                        if (j1 != 0) {
                            if (j1 >= 0) {
                                tess.draw();
                            }
                            j1 = 0;
                            renderer.mc.getTextureManager().bindTexture(locationRainPng);
                            worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
                        }
                        double d5 = ((double) (renderer.rendererUpdateCount + gridX * gridX * 3121 + gridX * 45238971 + gridZ * gridZ * 418711 + gridZ * 13761 & 31) + (double) partialTicks) / 32.0D * (3.0D + random.nextDouble());
                        double d6 = (double) ((float) gridX + 0.5F) - entity.posX;
                        double d7 = (double) ((float) gridZ + 0.5F) - entity.posZ;
                        float f3 = MathHelper.sqrt_double(d6 * d6 + d7 * d7) / (float) range;
                        float f4 = ((1.0F - f3 * f3) * 0.5F + 0.5F) * alphaRatio;
                        mutable.set(gridX, i3, gridZ);
                        int j3 = world.getCombinedLight(mutable, 0);
                        int k3 = j3 >> 16 & 65535;
                        int l3 = j3 & 65535;
                        worldrenderer.pos((double) gridX - rainX + 0.5D, (double) k2, (double) gridZ - rainY + 0.5D).tex(0.0D, (double) k2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, f4).lightmap(k3, l3).endVertex();
                        worldrenderer.pos((double) gridX + rainX + 0.5D, (double) k2, (double) gridZ + rainY + 0.5D).tex(1.0D, (double) k2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, f4).lightmap(k3, l3).endVertex();
                        worldrenderer.pos((double) gridX + rainX + 0.5D, (double) l2, (double) gridZ + rainY + 0.5D).tex(1.0D, (double) l2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, f4).lightmap(k3, l3).endVertex();
                        worldrenderer.pos((double) gridX - rainX + 0.5D, (double) l2, (double) gridZ - rainY + 0.5D).tex(0.0D, (double) l2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, f4).lightmap(k3, l3).endVertex();
                    } else {
                        if (j1 != 1) {
                            if (j1 >= 0) {
                                tess.draw();
                            }
                            // If cold enough the dust texture will be
                            // snow that blows sideways
                            ResourceLocation texture = locationSnowPng;
                            if (hasDust && heightTemp >= 0.15F)
                                texture = locationDustPng;
                            j1 = 1;
                            renderer.mc.getTextureManager().bindTexture(texture);
                            // GL_QUADS == 7
                            worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
                        }
                        Color color = new Color(1.0F, 1.0F, 1.0F);
                        if (world.provider.getDimensionId() == -1) {
                            final Color c = BiomeRegistry.getDustColor(biome);
                            if (color != null)
                                color.mix(c);
                        }
                        double d8 = (double) (((float) (renderer.rendererUpdateCount & 511) + partialTicks) / 512.0F);
                        // The 0.2F factor was originally 0.01F. It
                        // affects the horizontal
                        // movement of particles, which works well for
                        // dust.
                        final float factor = hasDust ? 0.2F : 0.01F;
                        double d9 = random.nextDouble() + (double) f1 * factor * (double) ((float) random.nextGaussian());
                        double d10 = random.nextDouble() + (double) (f1 * (float) random.nextGaussian()) * 0.001D;
                        double d11 = (double) ((float) gridX + 0.5F) - entity.posX;
                        double d12 = (double) ((float) gridZ + 0.5F) - entity.posZ;
                        float f6 = MathHelper.sqrt_double(d11 * d11 + d12 * d12) / (float) range;
                        float f5 = ((1.0F - f6 * f6) * 0.3F + 0.5F) * alphaRatio;
                        mutable.set(gridX, i3, gridZ);
                        int i4 = (world.getCombinedLight(mutable, 0) * 3 + 15728880) / 4;
                        int j4 = i4 >> 16 & 65535;
                        int k4 = i4 & 65535;
                        worldrenderer.pos((double) gridX - rainX + 0.5D, (double) k2, (double) gridZ - rainY + 0.5D).tex(0.0D + d9, (double) k2 * 0.25D + d8 + d10).color(color.red, color.green, color.blue, f5).lightmap(j4, k4).endVertex();
                        worldrenderer.pos((double) gridX + rainX + 0.5D, (double) k2, (double) gridZ + rainY + 0.5D).tex(1.0D + d9, (double) k2 * 0.25D + d8 + d10).color(color.red, color.green, color.blue, f5).lightmap(j4, k4).endVertex();
                        worldrenderer.pos((double) gridX + rainX + 0.5D, (double) l2, (double) gridZ + rainY + 0.5D).tex(1.0D + d9, (double) l2 * 0.25D + d8 + d10).color(color.red, color.green, color.blue, f5).lightmap(j4, k4).endVertex();
                        worldrenderer.pos((double) gridX - rainX + 0.5D, (double) l2, (double) gridZ - rainY + 0.5D).tex(0.0D + d9, (double) l2 * 0.25D + d8 + d10).color(color.red, color.green, color.blue, f5).lightmap(j4, k4).endVertex();
                    }
                }
            }
        }
    }
    if (j1 >= 0) {
        tess.draw();
    }
    worldrenderer.setTranslation(0.0D, 0.0D, 0.0D);
    GlStateManager.enableCull();
    GlStateManager.disableBlend();
    GlStateManager.alphaFunc(516, 0.1F);
    renderer.disableLightmap();
}
Also used : IRenderHandler(net.minecraftforge.client.IRenderHandler) Entity(net.minecraft.entity.Entity) Tessellator(net.minecraft.client.renderer.Tessellator) Color(org.blockartistry.mod.DynSurround.util.Color) World(net.minecraft.world.World) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) WorldRenderer(net.minecraft.client.renderer.WorldRenderer) ResourceLocation(net.minecraft.util.ResourceLocation) BlockPos(net.minecraft.util.BlockPos)

Example 2 with BiomeGenBase

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

the class FogEffectHandler method process.

@Override
public void process(final World world, final EntityPlayer player) {
    currentFogColor = new Color(world.getFogColor(1.0F));
    float biomeFog = 0.0F;
    float dustFog = 0.0F;
    float heightFog = 0.0F;
    if (ModOptions.enableBiomeFog || ModOptions.allowDesertFog) {
        final float brightnessFactor = world.getSunBrightness(1.0F);
        final Color tint = new Color(0, 0, 0);
        final TObjectIntHashMap<BiomeGenBase> weights = BiomeSurveyHandler.getBiomes();
        final int area = BiomeSurveyHandler.getArea();
        for (final BiomeGenBase b : weights.keySet()) {
            final int weight = weights.get(b);
            final float scale = ((float) weight / (float) area);
            if (ModOptions.enableBiomeFog && BiomeRegistry.hasFog(b)) {
                biomeFog += BiomeRegistry.getFogDensity(b) * scale;
                tint.add(Color.scale(BiomeRegistry.getFogColor(b), brightnessFactor).scale(scale));
            } else if (ModOptions.allowDesertFog && BiomeRegistry.hasDust(b)) {
                final float str = EnvironState.getWorld().getRainStrength(1.0F);
                dustFog += StormProperties.getFogDensity() * scale * str;
                tint.add(Color.scale(BiomeRegistry.getDustColor(b), brightnessFactor).scale(scale));
            } else {
                tint.add(Color.scale(currentFogColor, scale));
            }
        }
        currentFogColor = tint;
    }
    biomeFog *= ModOptions.biomeFogFactor;
    dustFog *= ModOptions.desertFogFactor;
    if (ModOptions.enableElevationHaze && DimensionRegistry.hasHaze(world)) {
        heightFog = ModOptions.elevationHazeAsBand ? calcHazeBand(world, player) : calcHazeGradient(world, player);
    }
    // Get the max fog level between the three fog types
    currentFogLevel = Math.max(biomeFog, Math.max(dustFog, heightFog));
    insideFogOffset = PlayerUtils.ceilingCoverageRatio(player) * 15.0F;
}
Also used : Color(org.blockartistry.mod.DynSurround.util.Color) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Example 3 with BiomeGenBase

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

the class PlayerSoundEffectHandler method process.

@Override
public void process(final World world, final EntityPlayer player) {
    // Dead players hear no sounds
    if (player.isDead) {
        resetSounds();
        return;
    }
    final BiomeGenBase playerBiome = EnvironState.getPlayerBiome();
    final String conditions = EnvironState.getConditions();
    final List<SoundEffect> sounds = new ArrayList<SoundEffect>();
    if (doBiomeSounds())
        sounds.addAll(getBiomeSounds(conditions));
    sounds.addAll(BiomeRegistry.getSounds(BiomeRegistry.PLAYER, conditions));
    SoundManager.queueAmbientSounds(sounds);
    if (doBiomeSounds()) {
        SoundEffect sound = BiomeRegistry.getSpotSound(playerBiome, conditions, EnvironState.RANDOM);
        if (sound != null)
            SoundManager.playSoundAtPlayer(player, sound);
    }
    SoundEffect sound = BiomeRegistry.getSpotSound(BiomeRegistry.PLAYER, conditions, EnvironState.RANDOM);
    if (sound != null)
        SoundManager.playSoundAtPlayer(player, sound);
    processWaterDrops();
    SoundManager.update();
}
Also used : SoundEffect(org.blockartistry.mod.DynSurround.client.sound.SoundEffect) ArrayList(java.util.ArrayList) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Example 4 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project Galacticraft by micdoodle8.

the class WorldChunkManagerVenus method findBiomePosition.

@Override
public BlockPos findBiomePosition(int x, int z, int range, List<BiomeGenBase> biomes, Random random) {
    int i = x - range >> 2;
    int j = z - range >> 2;
    int k = x + range >> 2;
    int l = z + range >> 2;
    int diffX = (k - i) + 1;
    int diffZ = (l - j) + 1;
    int[] unzoomed = this.unzoomedBiomes.getInts(i, j, diffX, diffZ);
    BlockPos blockPos = null;
    int count = 0;
    for (int a = 0; a < unzoomed.length; ++a) {
        int x0 = i + a % diffX << 2;
        int z0 = j + a / diffX << 2;
        BiomeGenBase biome = BiomeGenBase.getBiome(unzoomed[a]);
        if (biomes.contains(biome) && (blockPos == null || random.nextInt(count + 1) == 0)) {
            blockPos = new BlockPos(x0, 0, z0);
            count++;
        }
    }
    return blockPos;
}
Also used : BlockPos(net.minecraft.util.BlockPos) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Example 5 with BiomeGenBase

use of net.minecraft.world.biome.BiomeGenBase in project Galacticraft by micdoodle8.

the class ChunkProviderVenus method replaceBlocksForBiome.

private void replaceBlocksForBiome(int p_180517_1_, int p_180517_2_, ChunkPrimer p_180517_3_, BiomeGenBase[] p_180517_4_) {
    double d0 = 0.03125D;
    this.stoneNoise = this.noiseGen4.func_151599_a(this.stoneNoise, (double) (p_180517_1_ * 16), (double) (p_180517_2_ * 16), 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D);
    for (int i = 0; i < 16; ++i) {
        for (int j = 0; j < 16; ++j) {
            BiomeGenBase biomegenbase = p_180517_4_[j + i * 16];
            biomegenbase.genTerrainBlocks(this.worldObj, this.rand, p_180517_3_, p_180517_1_ * 16 + i, p_180517_2_ * 16 + j, this.stoneNoise[j + i * 16]);
        }
    }
}
Also used : BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Aggregations

BiomeGenBase (net.minecraft.world.biome.BiomeGenBase)50 BlockPos (net.minecraft.util.BlockPos)10 Block (net.minecraft.block.Block)8 Type (net.minecraftforge.common.BiomeDictionary.Type)5 ArrayList (java.util.ArrayList)3 IBlockState (net.minecraft.block.state.IBlockState)3 ChunkCoordIntPair (net.minecraft.world.ChunkCoordIntPair)3 World (net.minecraft.world.World)3 File (java.io.File)2 Random (java.util.Random)2 Material (net.minecraft.block.material.Material)2 Entity (net.minecraft.entity.Entity)2 BlockPos (net.minecraft.util.math.BlockPos)2 Chunk (net.minecraft.world.chunk.Chunk)2 EventHandler (net.minecraftforge.fml.common.Mod.EventHandler)2 Color (org.blockartistry.mod.DynSurround.util.Color)2 Affinity (am2.api.spell.enums.Affinity)1 ItemPanelDumper (codechicken.nei.config.ItemPanelDumper)1 IModFix (com.dreammaster.modfixes.IModFix)1 OilGeneratorFix (com.dreammaster.modfixes.oilgen.OilGeneratorFix)1