Search in sources :

Example 1 with SeasonInfo

use of org.blockartistry.DynSurround.registry.season.SeasonInfo in project DynamicSurroundings by OreCruncher.

the class SeasonRegistry method getData.

@Nonnull
public SeasonInfo getData(@Nonnull final World world) {
    SeasonInfo result = this.seasonData.get(world.provider.getDimension());
    if (result == null) {
        result = factory(world);
        this.seasonData.put(world.provider.getDimension(), result);
    }
    return result;
}
Also used : SeasonInfo(org.blockartistry.DynSurround.registry.season.SeasonInfo) Nonnull(javax.annotation.Nonnull)

Example 2 with SeasonInfo

use of org.blockartistry.DynSurround.registry.season.SeasonInfo in project DynamicSurroundings by OreCruncher.

the class StormRenderer method render.

/**
 * Render rain and snow
 */
public void render(@Nonnull final EntityRenderer renderer, final float partialTicks) {
    // Don't use EnvironState - may not have been initialized when rendering
    // starts.
    final Minecraft mc = Minecraft.getMinecraft();
    final World world = mc.world;
    if (!ClientRegistry.DIMENSION.hasWeather(world))
        return;
    final float rainStrength = Weather.getIntensityLevel();
    if (rainStrength <= 0.0F)
        return;
    final float alphaRatio = rainStrength / Weather.getMaxIntensityLevel();
    renderer.enableLightmap();
    GlStateManager.disableCull();
    GlStateManager.glNormal3f(0.0F, 1.0F, 0.0F);
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    GlStateManager.alphaFunc(516, 0.1F);
    final int range = mc.gameSettings.fancyGraphics ? 10 : 5;
    final float f1 = RenderWeather.rendererUpdateCount + partialTicks;
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    final SeasonInfo season = ClientRegistry.SEASON.getData(world);
    final Weather.Properties props = Weather.getWeatherProperties();
    final Entity entity = mc.getRenderViewEntity();
    final BlockPos playerPos = EnvironState.getPlayerPosition();
    final int playerX = playerPos.getX();
    final int playerY = playerPos.getY();
    final int playerZ = playerPos.getZ();
    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 = RAIN_X_COORDS[idx];
            final double rainY = RAIN_Y_COORDS[idx];
            this.mutable.setPos(gridX, 0, gridZ);
            if (!RandomThings.shouldRain(world, this.mutable))
                continue;
            final BiomeInfo biome = ClientRegistry.BIOME.get(ClientChunkCache.INSTANCE.getBiome(this.mutable));
            if (!biome.hasWeatherEffect())
                continue;
            final int precipHeight = season.getPrecipitationHeight(world, this.mutable).getY();
            final int k2 = Math.max(playerY - range, precipHeight);
            final int l2 = Math.max(playerY + range, precipHeight);
            if (k2 == l2)
                continue;
            final int i3 = Math.max(precipHeight, locY);
            this.random.setSeed(gridX * gridX * 3121 + gridX * 45238971 ^ gridZ * gridZ * 418711 + gridZ * 13761);
            this.mutable.setPos(gridX, k2, gridZ);
            final boolean canSnow = season.canWaterFreeze(world, this.mutable);
            final double d6 = gridX + 0.5F - entity.posX;
            final double d7 = gridZ + 0.5F - entity.posZ;
            final float f3 = MathHelper.sqrt(d6 * d6 + d7 * d7) / range;
            this.mutable.setPos(gridX, i3, gridZ);
            final int combinedLight = ClientChunkCache.INSTANCE.getCombinedLight(this.mutable, 0);
            if (!biome.getHasDust() && !canSnow) {
                setupForRender(props.getRainTexture());
                // d8 makes the rain fall down. Assumes texture height of 512 pixels.
                final double d5 = ((double) (RenderWeather.rendererUpdateCount + gridX * gridX * 3121 + gridX * 45238971 + gridZ * gridZ * 418711 + gridZ * 13761 & 31) + (double) partialTicks) / 32.0D * (3.0D + this.random.nextDouble());
                final float alpha = ((1.0F - f3 * f3) * 0.5F + 0.5F) * alphaRatio;
                final int slX16 = combinedLight >> 16 & 65535;
                final int blX16 = combinedLight & 65535;
                worldrenderer.pos(gridX - rainX + 0.5D, k2, gridZ - rainY + 0.5D).tex(0.0D, k2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, alpha).lightmap(slX16, blX16).endVertex();
                worldrenderer.pos(gridX + rainX + 0.5D, k2, gridZ + rainY + 0.5D).tex(1.0D, k2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, alpha).lightmap(slX16, blX16).endVertex();
                worldrenderer.pos(gridX + rainX + 0.5D, l2, gridZ + rainY + 0.5D).tex(1.0D, l2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, alpha).lightmap(slX16, blX16).endVertex();
                worldrenderer.pos(gridX - rainX + 0.5D, l2, gridZ - rainY + 0.5D).tex(0.0D, l2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, alpha).lightmap(slX16, blX16).endVertex();
            } else {
                ResourceLocation texture = props.getSnowTexture();
                if (biome.getHasDust() && !canSnow)
                    texture = props.getDustTexture();
                setupForRender(texture);
                final Color color;
                if (biome.getHasDust())
                    color = biome.getDustColor();
                else
                    color = Color.WHITE;
                // d8 makes the snow fall down. Assumes texture height of 512 pixels.
                final double d8 = ((RenderWeather.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 = biome.getHasDust() ? 0.2F : 0.01F;
                // d9 shifts the texture left/right
                final double d9 = this.random.nextDouble() + (double) f1 * factor * ((float) this.random.nextGaussian());
                // d10 shifts the texture up/down
                final double d10 = this.random.nextDouble() + f1 * (float) this.random.nextGaussian() * 0.001D;
                final float alpha = ((1.0F - f3 * f3) * 0.3F + 0.5F) * alphaRatio;
                final int cl = (combinedLight * 3 + 15728880) / 4;
                final int slX16 = cl >> 16 & 65535;
                final int blX16 = cl & 65535;
                worldrenderer.pos(gridX - rainX + 0.5D, k2, gridZ - rainY + 0.5D).tex(0.0D + d9, k2 * 0.25D + d8 + d10).color(color.red, color.green, color.blue, alpha).lightmap(slX16, blX16).endVertex();
                worldrenderer.pos(gridX + rainX + 0.5D, k2, gridZ + rainY + 0.5D).tex(1.0D + d9, k2 * 0.25D + d8 + d10).color(color.red, color.green, color.blue, alpha).lightmap(slX16, blX16).endVertex();
                worldrenderer.pos(gridX + rainX + 0.5D, l2, gridZ + rainY + 0.5D).tex(1.0D + d9, l2 * 0.25D + d8 + d10).color(color.red, color.green, color.blue, alpha).lightmap(slX16, blX16).endVertex();
                worldrenderer.pos(gridX - rainX + 0.5D, l2, gridZ - rainY + 0.5D).tex(0.0D + d9, l2 * 0.25D + d8 + d10).color(color.red, color.green, color.blue, alpha).lightmap(slX16, blX16).endVertex();
            }
        }
    }
    closeRender();
    GlStateManager.enableCull();
    GlStateManager.disableBlend();
    GlStateManager.alphaFunc(516, 0.1F);
    renderer.disableLightmap();
}
Also used : Entity(net.minecraft.entity.Entity) Color(org.blockartistry.lib.Color) BiomeInfo(org.blockartistry.DynSurround.registry.BiomeInfo) World(net.minecraft.world.World) Minecraft(net.minecraft.client.Minecraft) ResourceLocation(net.minecraft.util.ResourceLocation) SeasonInfo(org.blockartistry.DynSurround.registry.season.SeasonInfo) BlockPos(net.minecraft.util.math.BlockPos)

Example 3 with SeasonInfo

use of org.blockartistry.DynSurround.registry.season.SeasonInfo in project DynamicSurroundings by OreCruncher.

the class RainSplashAccent method provide.

@Override
@Nonnull
public ObjectArray<IAcoustic> provide(@Nonnull final EntityLivingBase entity, @Nullable final BlockPos blockPos, @Nonnull final ObjectArray<IAcoustic> in) {
    if (ModOptions.sound.enablePuddleSound && Weather.isRaining() && EnvironState.isPlayer(entity)) {
        if (blockPos != null) {
            this.mutable.setPos(blockPos.getX(), blockPos.getY() + 1, blockPos.getZ());
        } else {
            this.mutable.setPos(entity);
        }
        final World world = entity.getEntityWorld();
        final SeasonInfo season = ClientRegistry.SEASON.getData(world);
        final int precipHeight = season.getPrecipitationHeight(world, this.mutable).getY();
        if (precipHeight == this.mutable.getY()) {
            final BiomeInfo biome = ClientRegistry.BIOME.get(ClientChunkCache.INSTANCE.getBiome(this.mutable));
            if (biome.hasWeatherEffect() && !biome.getHasDust()) {
                this.mutable.setY(precipHeight);
                if (!season.canWaterFreeze(world, this.mutable))
                    in.addAll(AcousticsManager.SPLASH);
            }
        }
    }
    return in;
}
Also used : BiomeInfo(org.blockartistry.DynSurround.registry.BiomeInfo) SeasonInfo(org.blockartistry.DynSurround.registry.season.SeasonInfo) World(net.minecraft.world.World) Nonnull(javax.annotation.Nonnull)

Aggregations

SeasonInfo (org.blockartistry.DynSurround.registry.season.SeasonInfo)3 Nonnull (javax.annotation.Nonnull)2 World (net.minecraft.world.World)2 BiomeInfo (org.blockartistry.DynSurround.registry.BiomeInfo)2 Minecraft (net.minecraft.client.Minecraft)1 Entity (net.minecraft.entity.Entity)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 BlockPos (net.minecraft.util.math.BlockPos)1 Color (org.blockartistry.lib.Color)1