Search in sources :

Example 1 with BOPBiome

use of biomesoplenty.common.biome.BOPBiome in project BiomesOPlenty by Glitchfiend.

the class BlockBOPBiomeBlock method getBiomesWithEssence.

// generate the list of biomes which have an associated essence
public List<Biome> getBiomesWithEssence() {
    if (biomesWithEssence != null) {
        return biomesWithEssence;
    }
    biomesWithEssence = new ArrayList<Biome>();
    List<Biome> vanillaBiomesToExclude = Arrays.asList(Biomes.DEFAULT, Biomes.SKY, Biomes.HELL, Biomes.BEACH, Biomes.COLD_BEACH, Biomes.STONE_BEACH, Biomes.OCEAN, Biomes.FROZEN_OCEAN, Biomes.DEEP_OCEAN, Biomes.RIVER, Biomes.FROZEN_RIVER, Biomes.VOID, Biomes.MUSHROOM_ISLAND_SHORE, Biomes.DESERT_HILLS, Biomes.BIRCH_FOREST_HILLS, Biomes.COLD_TAIGA_HILLS, Biomes.EXTREME_HILLS_EDGE, Biomes.EXTREME_HILLS_WITH_TREES, Biomes.FOREST_HILLS, Biomes.ICE_MOUNTAINS, Biomes.JUNGLE_EDGE, Biomes.JUNGLE_HILLS, Biomes.MESA_CLEAR_ROCK, Biomes.MESA_ROCK, Biomes.MUTATED_BIRCH_FOREST, Biomes.MUTATED_BIRCH_FOREST_HILLS, Biomes.MUTATED_DESERT, Biomes.MUTATED_EXTREME_HILLS, Biomes.MUTATED_EXTREME_HILLS_WITH_TREES, Biomes.MUTATED_FOREST, Biomes.MUTATED_ICE_FLATS, Biomes.MUTATED_JUNGLE, Biomes.MUTATED_JUNGLE_EDGE, Biomes.MUTATED_MESA, Biomes.MUTATED_MESA_CLEAR_ROCK, Biomes.MUTATED_MESA_ROCK, Biomes.MUTATED_PLAINS, Biomes.MUTATED_REDWOOD_TAIGA, Biomes.MUTATED_REDWOOD_TAIGA_HILLS, Biomes.MUTATED_ROOFED_FOREST, Biomes.MUTATED_SAVANNA, Biomes.MUTATED_SAVANNA_ROCK, Biomes.MUTATED_SWAMPLAND, Biomes.MUTATED_TAIGA, Biomes.MUTATED_TAIGA_COLD, Biomes.REDWOOD_TAIGA_HILLS, Biomes.SAVANNA_PLATEAU, Biomes.TAIGA_HILLS);
    for (Biome biome : BiomeUtils.getRegisteredBiomes()) {
        if (biome == null) {
            continue;
        }
        if (biome instanceof BOPBiome) {
            if (((BOPBiome) biome).hasBiomeEssence()) {
                biomesWithEssence.add(biome);
            }
        } else {
            if (!vanillaBiomesToExclude.contains(biome)) {
                biomesWithEssence.add(biome);
            }
        }
    }
    return biomesWithEssence;
}
Also used : BOPBiome(biomesoplenty.common.biome.BOPBiome) Biome(net.minecraft.world.biome.Biome) BOPBiome(biomesoplenty.common.biome.BOPBiome)

Example 2 with BOPBiome

use of biomesoplenty.common.biome.BOPBiome in project BiomesOPlenty by Glitchfiend.

the class FogEventHandler method onRenderFog.

@SubscribeEvent
public void onRenderFog(EntityViewRenderEvent.RenderFogEvent event) {
    Entity entity = event.getEntity();
    World world = entity.world;
    int playerX = MathHelper.floor(entity.posX);
    int playerY = MathHelper.floor(entity.posY);
    int playerZ = MathHelper.floor(entity.posZ);
    if (playerX == fogX && playerZ == fogZ && fogInit) {
        renderFog(event.getFogMode(), fogFarPlaneDistance, 0.75f);
        return;
    }
    fogInit = true;
    int distance = 20;
    float fpDistanceBiomeFog = 0F;
    float weightBiomeFog = 0;
    BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
    for (int x = -distance; x <= distance; ++x) {
        for (int z = -distance; z <= distance; ++z) {
            pos.setPos(playerX + x, 0, playerZ + z);
            Biome biome = world.getBiome(pos);
            if (biome instanceof BOPBiome) {
                float distancePart = ((BOPBiome) biome).getFogDensity(pos);
                float weightPart = 1;
                // Check if fog density is enabled for this biome
                if (x == -distance) {
                    double xDiff = 1 - (entity.posX - playerX);
                    distancePart *= xDiff;
                    weightPart *= xDiff;
                } else if (x == distance) {
                    double xDiff = (entity.posX - playerX);
                    distancePart *= xDiff;
                    weightPart *= xDiff;
                }
                if (z == -distance) {
                    double zDiff = 1 - (entity.posZ - playerZ);
                    distancePart *= zDiff;
                    weightPart *= zDiff;
                } else if (z == distance) {
                    double zDiff = (entity.posZ - playerZ);
                    distancePart *= zDiff;
                    weightPart *= zDiff;
                }
                fpDistanceBiomeFog += distancePart;
                weightBiomeFog += weightPart;
            }
        }
    }
    float weightMixed = (distance * 2) * (distance * 2);
    float weightDefault = weightMixed - weightBiomeFog;
    float fpDistanceBiomeFogAvg = (weightBiomeFog == 0) ? 0 : fpDistanceBiomeFog / weightBiomeFog;
    float farPlaneDistance = (fpDistanceBiomeFog * 240 + event.getFarPlaneDistance() * weightDefault) / weightMixed;
    float farPlaneDistanceScaleBiome = (0.1f * (1 - fpDistanceBiomeFogAvg) + 0.75f * fpDistanceBiomeFogAvg);
    float farPlaneDistanceScale = (farPlaneDistanceScaleBiome * weightBiomeFog + 0.75f * weightDefault) / weightMixed;
    fogX = entity.posX;
    fogZ = entity.posZ;
    fogFarPlaneDistance = Math.min(farPlaneDistance, event.getFarPlaneDistance());
    renderFog(event.getFogMode(), fogFarPlaneDistance, farPlaneDistanceScale);
}
Also used : Entity(net.minecraft.entity.Entity) BOPBiome(biomesoplenty.common.biome.BOPBiome) Biome(net.minecraft.world.biome.Biome) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) BOPBiome(biomesoplenty.common.biome.BOPBiome) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with BOPBiome

use of biomesoplenty.common.biome.BOPBiome in project BiomesOPlenty by Glitchfiend.

the class FogEventHandler method getFogBlendColour.

private static Vec3d getFogBlendColour(World world, EntityLivingBase playerEntity, int playerX, int playerY, int playerZ, float defR, float defG, float defB, double renderPartialTicks) {
    GameSettings settings = Minecraft.getMinecraft().gameSettings;
    int[] ranges = ForgeModContainer.blendRanges;
    int distance = 6;
    if (settings.fancyGraphics && settings.renderDistanceChunks >= 0 && settings.renderDistanceChunks < ranges.length) {
        distance = ranges[settings.renderDistanceChunks];
    }
    double rBiomeFog = 0;
    double gBiomeFog = 0;
    double bBiomeFog = 0;
    double weightBiomeFog = 0;
    BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
    for (int x = -distance; x <= distance; ++x) {
        for (int z = -distance; z <= distance; ++z) {
            pos.setPos(playerX + x, 0, playerZ + z);
            Biome biome = world.getBiome(pos);
            if (biome instanceof BOPBiome) {
                int fogColour = ((BOPBiome) biome).getFogColor(pos);
                // Ensure fog colouring is enabled for this biome
                if (fogColour >= 0) {
                    double rPart = (fogColour & 0xFF0000) >> 16;
                    double gPart = (fogColour & 0x00FF00) >> 8;
                    double bPart = fogColour & 0x0000FF;
                    float weightPart = 1;
                    if (x == -distance) {
                        double xDiff = 1 - (playerEntity.posX - playerX);
                        rPart *= xDiff;
                        gPart *= xDiff;
                        bPart *= xDiff;
                        weightPart *= xDiff;
                    } else if (x == distance) {
                        double xDiff = playerEntity.posX - playerX;
                        rPart *= xDiff;
                        gPart *= xDiff;
                        bPart *= xDiff;
                        weightPart *= xDiff;
                    }
                    if (z == -distance) {
                        double zDiff = 1 - (playerEntity.posZ - playerZ);
                        rPart *= zDiff;
                        gPart *= zDiff;
                        bPart *= zDiff;
                        weightPart *= zDiff;
                    } else if (z == distance) {
                        double zDiff = playerEntity.posZ - playerZ;
                        rPart *= zDiff;
                        gPart *= zDiff;
                        bPart *= zDiff;
                        weightPart *= zDiff;
                    }
                    rBiomeFog += rPart;
                    gBiomeFog += gPart;
                    bBiomeFog += bPart;
                    weightBiomeFog += weightPart;
                }
            }
        }
    }
    if (weightBiomeFog == 0 || distance == 0) {
        return new Vec3d(defR, defG, defB);
    }
    rBiomeFog /= 255f;
    gBiomeFog /= 255f;
    bBiomeFog /= 255f;
    // Calculate day / night / weather scale for BiomeFog component
    float celestialAngle = world.getCelestialAngle((float) renderPartialTicks);
    float baseScale = MathHelper.clamp(MathHelper.cos(celestialAngle * (float) Math.PI * 2.0F) * 2.0F + 0.5F, 0, 1);
    double rScale = baseScale * 0.94F + 0.06F;
    double gScale = baseScale * 0.94F + 0.06F;
    double bScale = baseScale * 0.91F + 0.09F;
    float rainStrength = world.getRainStrength((float) renderPartialTicks);
    if (rainStrength > 0) {
        rScale *= 1 - rainStrength * 0.5f;
        gScale *= 1 - rainStrength * 0.5f;
        bScale *= 1 - rainStrength * 0.4f;
    }
    float thunderStrength = world.getThunderStrength((float) renderPartialTicks);
    if (thunderStrength > 0) {
        rScale *= 1 - thunderStrength * 0.5f;
        gScale *= 1 - thunderStrength * 0.5f;
        bScale *= 1 - thunderStrength * 0.5f;
    }
    // Apply post-processing to BiomeFog component.  Default color was already processed by Vanilla.
    rBiomeFog *= rScale / weightBiomeFog;
    gBiomeFog *= gScale / weightBiomeFog;
    bBiomeFog *= bScale / weightBiomeFog;
    Vec3d processedColor = postProcessColor(world, playerEntity, rBiomeFog, gBiomeFog, bBiomeFog, renderPartialTicks);
    rBiomeFog = processedColor.x;
    gBiomeFog = processedColor.y;
    bBiomeFog = processedColor.z;
    // Mix default fog component with BiomeFog component
    double weightMixed = (distance * 2) * (distance * 2);
    double weightDefault = weightMixed - weightBiomeFog;
    double rFinal = (rBiomeFog * weightBiomeFog + defR * weightDefault) / weightMixed;
    double gFinal = (gBiomeFog * weightBiomeFog + defG * weightDefault) / weightMixed;
    double bFinal = (bBiomeFog * weightBiomeFog + defB * weightDefault) / weightMixed;
    return new Vec3d(rFinal, gFinal, bFinal);
}
Also used : BOPBiome(biomesoplenty.common.biome.BOPBiome) Biome(net.minecraft.world.biome.Biome) BlockPos(net.minecraft.util.math.BlockPos) GameSettings(net.minecraft.client.settings.GameSettings) BOPBiome(biomesoplenty.common.biome.BOPBiome) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

BOPBiome (biomesoplenty.common.biome.BOPBiome)3 Biome (net.minecraft.world.biome.Biome)3 BlockPos (net.minecraft.util.math.BlockPos)2 GameSettings (net.minecraft.client.settings.GameSettings)1 Entity (net.minecraft.entity.Entity)1 Vec3d (net.minecraft.util.math.Vec3d)1 World (net.minecraft.world.World)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1