Search in sources :

Example 1 with Color

use of org.blockartistry.mod.DynSurround.util.Color in project BetterRain by OreCruncher.

the class BiomeRegistry method process.

private static void process(final BiomeConfig config) {
    for (final BiomeConfig.Entry entry : config.entries) {
        for (final Entry biomeEntry : registry.valueCollection()) {
            if (isBiomeMatch(entry, resolveName(biomeEntry.biome))) {
                if (entry.hasPrecipitation != null)
                    biomeEntry.hasPrecipitation = entry.hasPrecipitation.booleanValue();
                if (entry.hasAurora != null)
                    biomeEntry.hasAurora = entry.hasAurora.booleanValue();
                if (entry.hasDust != null)
                    biomeEntry.hasDust = entry.hasDust.booleanValue();
                if (entry.hasFog != null)
                    biomeEntry.hasFog = entry.hasFog.booleanValue();
                if (entry.fogDensity != null)
                    biomeEntry.fogDensity = entry.fogDensity.floatValue();
                if (entry.fogColor != null) {
                    final int[] rgb = MyUtils.splitToInts(entry.fogColor, ',');
                    if (rgb.length == 3)
                        biomeEntry.fogColor = new Color(rgb[0], rgb[1], rgb[2]);
                }
                if (entry.dustColor != null) {
                    final int[] rgb = MyUtils.splitToInts(entry.dustColor, ',');
                    if (rgb.length == 3)
                        biomeEntry.dustColor = new Color(rgb[0], rgb[1], rgb[2]);
                }
                if (entry.soundReset != null && entry.soundReset.booleanValue()) {
                    biomeEntry.sounds = new ArrayList<SoundEffect>();
                    biomeEntry.spotSounds = new ArrayList<SoundEffect>();
                }
                if (entry.spotSoundChance != null)
                    biomeEntry.spotSoundChance = entry.spotSoundChance.intValue();
                for (final SoundConfig sr : entry.sounds) {
                    if (SoundRegistry.isSoundBlocked(sr.sound))
                        continue;
                    final SoundEffect s = new SoundEffect(sr);
                    if (s.type == SoundType.SPOT)
                        biomeEntry.spotSounds.add(s);
                    else
                        biomeEntry.sounds.add(s);
                }
            }
        }
    }
}
Also used : SoundEffect(org.blockartistry.mod.DynSurround.client.sound.SoundEffect) Color(org.blockartistry.mod.DynSurround.util.Color) SoundConfig(org.blockartistry.mod.DynSurround.data.config.SoundConfig) BiomeConfig(org.blockartistry.mod.DynSurround.data.config.BiomeConfig)

Example 2 with Color

use of org.blockartistry.mod.DynSurround.util.Color 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 3 with Color

use of org.blockartistry.mod.DynSurround.util.Color 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 4 with Color

use of org.blockartistry.mod.DynSurround.util.Color in project BetterRain by OreCruncher.

the class WorldProviderShim method drawClouds.

@SideOnly(Side.CLIENT)
public Vec3 drawClouds(float partialTicks) {
    final Color color = new Color(this.provider.drawClouds(partialTicks));
    final float stormIntensity = this.worldObj.getRainStrength(1.0F);
    if (stormIntensity > 0.0F) {
        // Need to darken the clouds based on intensity
        color.scale((1.0F - stormIntensity) * 0.5F + 0.5F);
    }
    return color.toVec3();
}
Also used : Color(org.blockartistry.mod.DynSurround.util.Color) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with Color

use of org.blockartistry.mod.DynSurround.util.Color in project BetterRain by OreCruncher.

the class AuroraRenderer method renderAurora.

public static void renderAurora(final float partialTick, final Aurora aurora) {
    final Minecraft mc = FMLClientHandler.instance().getClient();
    final float alpha = (aurora.getAlpha() * moonlightFactor(mc.theWorld)) / 255.0F;
    if (alpha <= 0.0F)
        return;
    final Tessellator tess = Tessellator.getInstance();
    final WorldRenderer renderer = tess.getWorldRenderer();
    final float tranY;
    if (ModOptions.auroraHeightPlayerRelative) {
        // Fix height above player
        tranY = ModOptions.playerFixedHeight;
    } else {
        // Adjust to keep aurora at the same altitude
        tranY = DimensionRegistry.getCloudHeight(mc.theWorld) + 5 - (float) (mc.thePlayer.lastTickPosY + (mc.thePlayer.posY - mc.thePlayer.lastTickPosY) * partialTick);
    }
    final double tranX = aurora.posX - (mc.thePlayer.lastTickPosX + (mc.thePlayer.posX - mc.thePlayer.lastTickPosX) * partialTick);
    final double tranZ = aurora.posZ - (mc.thePlayer.lastTickPosZ + (mc.thePlayer.posZ - mc.thePlayer.lastTickPosZ) * partialTick);
    if (ModOptions.auroraAnimate)
        aurora.translate(partialTick);
    final Color base = aurora.getBaseColor();
    final Color fade = aurora.getFadeColor();
    final double zero = 0.0D;
    GlStateManager.pushMatrix();
    GlStateManager.translate((float) tranX, tranY, (float) tranZ);
    GlStateManager.scale(0.5D, 8.0D, 0.5D);
    GlStateManager.disableTexture2D();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.disableAlpha();
    GlStateManager.disableCull();
    GlStateManager.depthMask(false);
    for (final Node[] array : aurora.getNodeList()) {
        for (int i = 0; i < array.length - 1; i++) {
            final Node node = array[i];
            final double posY = node.getModdedY();
            final double posX = node.tetX;
            final double posZ = node.tetZ;
            final double tetX = node.tetX2;
            final double tetZ = node.tetZ2;
            final double posX2;
            final double posZ2;
            final double tetX2;
            final double tetZ2;
            final double posY2;
            if (i < array.length - 2) {
                final Node nodePlus = array[i + 1];
                posX2 = nodePlus.tetX;
                posZ2 = nodePlus.tetZ;
                tetX2 = nodePlus.tetX2;
                tetZ2 = nodePlus.tetZ2;
                posY2 = nodePlus.getModdedY();
            } else {
                posX2 = tetX2 = node.posX;
                posZ2 = tetZ2 = node.getModdedZ();
                posY2 = 0.0D;
            }
            // Front
            renderer.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
            renderer.pos(posX, zero, posZ).color(base.red, base.green, base.blue, alpha).endVertex();
            renderer.pos(posX, posY, posZ).color(fade.red, fade.green, fade.blue, 0).endVertex();
            renderer.pos(posX2, posY2, posZ2).color(fade.red, fade.green, fade.blue, 0).endVertex();
            renderer.pos(posX2, zero, posZ2).color(base.red, base.green, base.blue, alpha).endVertex();
            tess.draw();
            // Bottom
            renderer.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
            renderer.pos(posX, zero, posZ).color(base.red, base.green, base.blue, alpha).endVertex();
            renderer.pos(posX2, zero, posZ2).color(base.red, base.green, base.blue, alpha).endVertex();
            renderer.pos(tetX2, zero, tetZ2).color(base.red, base.green, base.blue, alpha).endVertex();
            renderer.pos(tetX, zero, tetZ).color(base.red, base.green, base.blue, alpha).endVertex();
            tess.draw();
            // Back
            renderer.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
            renderer.pos(tetX, zero, tetZ).color(base.red, base.green, base.blue, alpha).endVertex();
            renderer.pos(tetX, posY, tetZ).color(fade.red, fade.green, fade.blue, 0).endVertex();
            renderer.pos(tetX2, posY2, tetZ2).color(fade.red, fade.green, fade.blue, 0).endVertex();
            renderer.pos(tetX2, zero, tetZ2).color(base.red, base.green, base.blue, alpha).endVertex();
            tess.draw();
        }
    }
    GlStateManager.scale(3.5D, 25.0D, 3.5D);
    GlStateManager.depthMask(true);
    GlStateManager.enableCull();
    GlStateManager.disableBlend();
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.enableTexture2D();
    GlStateManager.enableAlpha();
    GlStateManager.popMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) Color(org.blockartistry.mod.DynSurround.util.Color) Minecraft(net.minecraft.client.Minecraft) WorldRenderer(net.minecraft.client.renderer.WorldRenderer)

Aggregations

Color (org.blockartistry.mod.DynSurround.util.Color)5 Tessellator (net.minecraft.client.renderer.Tessellator)2 WorldRenderer (net.minecraft.client.renderer.WorldRenderer)2 BiomeGenBase (net.minecraft.world.biome.BiomeGenBase)2 Minecraft (net.minecraft.client.Minecraft)1 Entity (net.minecraft.entity.Entity)1 BlockPos (net.minecraft.util.BlockPos)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 World (net.minecraft.world.World)1 IRenderHandler (net.minecraftforge.client.IRenderHandler)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 SoundEffect (org.blockartistry.mod.DynSurround.client.sound.SoundEffect)1 BiomeConfig (org.blockartistry.mod.DynSurround.data.config.BiomeConfig)1 SoundConfig (org.blockartistry.mod.DynSurround.data.config.SoundConfig)1