Search in sources :

Example 81 with Biome

use of net.minecraft.world.biome.Biome in project RFToolsDimensions by McJty.

the class NormalTerrainGenerator method replaceBlocksForBiome.

@Override
public void replaceBlocksForBiome(int chunkX, int chunkZ, ChunkPrimer primer, Biome[] Biomes) {
    ChunkGeneratorEvent.ReplaceBiomeBlocks event = new ChunkGeneratorEvent.ReplaceBiomeBlocks(provider, chunkX, chunkZ, primer, world);
    MinecraftForge.EVENT_BUS.post(event);
    if (event.getResult() == Event.Result.DENY) {
        return;
    }
    double d0 = 0.03125D;
    this.depthBuffer = this.surfaceNoise.getRegion(this.depthBuffer, (chunkX * 16), (chunkZ * 16), 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D);
    for (int k = 0; k < 16; ++k) {
        for (int l = 0; l < 16; ++l) {
            Biome Biome = Biomes[l + k * 16];
            Biome.genTerrainBlocks(world, provider.rand, primer, chunkX * 16 + k, chunkZ * 16 + l, this.depthBuffer[l + k * 16]);
        }
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) ChunkGeneratorEvent(net.minecraftforge.event.terraingen.ChunkGeneratorEvent)

Example 82 with Biome

use of net.minecraft.world.biome.Biome in project RFToolsDimensions by McJty.

the class UpsideDownTerrainGenerator method generateHeightmap.

private void generateHeightmap(int chunkX4, int chunkY4, int chunkZ4) {
    ChunkGeneratorSettings settings = provider.getSettings();
    this.depthRegion = this.depthNoise.generateNoiseOctaves(this.depthRegion, chunkX4, chunkZ4, 5, 5, settings.depthNoiseScaleX, settings.depthNoiseScaleZ, settings.depthNoiseScaleExponent);
    float f = settings.coordinateScale;
    float f1 = settings.heightScale;
    this.mainNoiseRegion = this.mainPerlinNoise.generateNoiseOctaves(this.mainNoiseRegion, chunkX4, chunkY4, chunkZ4, 5, 33, 5, f / settings.mainNoiseScaleX, f1 / settings.mainNoiseScaleY, f / settings.mainNoiseScaleZ);
    this.minLimitRegion = this.minLimitPerlinNoise.generateNoiseOctaves(this.minLimitRegion, chunkX4, chunkY4, chunkZ4, 5, 33, 5, f, f1, f);
    this.maxLimitRegion = this.maxLimitPerlinNoise.generateNoiseOctaves(this.maxLimitRegion, chunkX4, chunkY4, chunkZ4, 5, 33, 5, f, f1, f);
    int i = 0;
    int j = 0;
    boolean domaze = false;
    boolean elevated = false;
    boolean donearlands = provider.dimensionInformation.getTerrainType() == TerrainType.TERRAIN_NEARLANDS;
    if (donearlands) {
        elevated = true;
    }
    if (provider.dimensionInformation.hasFeatureType(FeatureType.FEATURE_MAZE)) {
        domaze = true;
        long s2 = (((chunkX4 >> 2) + provider.seed + 13) * 314) + (chunkZ4 >> 2) * 17L;
        Random rand = new Random(s2);
        // Skip one.
        rand.nextFloat();
        elevated = ((chunkX4 >> 2) & 1) == 0;
        if (rand.nextFloat() < .2f) {
            elevated = !elevated;
        }
    }
    if (donearlands) {
        int cx = chunkX4 >> 2;
        int cz = chunkZ4 >> 2;
        if (Math.abs(cx) < 5 && Math.abs(cz) < 5) {
            elevated = false;
        }
    }
    if (provider.biomesForGeneration == null) {
        Logging.log("Dimension " + world.provider.getDimension() + " has a problem! Ignoring for now.");
        return;
    }
    for (int k = 0; k < 5; ++k) {
        for (int l = 0; l < 5; ++l) {
            float f2 = 0.0F;
            float f3 = 0.0F;
            float f4 = 0.0F;
            Biome Biome = provider.biomesForGeneration[k + 2 + (l + 2) * 10];
            for (int j1 = -2; j1 <= 2; ++j1) {
                for (int k1 = -2; k1 <= 2; ++k1) {
                    Biome Biome1 = provider.biomesForGeneration[k + j1 + 2 + (l + k1 + 2) * 10];
                    float f5 = provider.getSettings().biomeDepthOffSet + Biome1.getBaseHeight() * provider.getSettings().biomeDepthWeight;
                    float f6 = provider.getSettings().biomeScaleOffset + Biome1.getHeightVariation() * provider.getSettings().biomeScaleWeight;
                    if (domaze || donearlands) {
                        if (f5 > 0.0F && elevated) {
                            if (provider.worldType == WorldType.AMPLIFIED) {
                                f5 = 2.0F + f5 * 1.5f;
                                f6 = 1.0F + f6 * 3.0f;
                            } else {
                                f5 = 2.0F + f5;
                                f6 = 0.5F + f6 * 1.5f;
                            }
                        } else {
                            if (provider.worldType == WorldType.AMPLIFIED && f5 > 0.0f) {
                                f5 = 0.5F + f5 * 1.5F;
                                f6 = 0.5F + f6 * 2.0F;
                            } else {
                                f6 = f6 * 0.5F;
                            }
                        }
                    } else {
                        if (provider.worldType == WorldType.AMPLIFIED && f5 > 0.0F) {
                            f5 = 1.0F + f5 * 2.0F;
                            f6 = 1.0F + f6 * 4.0F;
                        }
                    }
                    float f7 = biomeWeights[j1 + 2 + (k1 + 2) * 5] / (f5 + 2.0F);
                    if (Biome1.getBaseHeight() > Biome.getBaseHeight()) {
                        f7 /= 2.0F;
                    }
                    f2 += f6 * f7;
                    f3 += f5 * f7;
                    f4 += f7;
                }
            }
            f2 /= f4;
            f3 /= f4;
            f2 = f2 * 0.9F + 0.1F;
            f3 = (f3 * 4.0F - 1.0F) / 8.0F;
            double d12 = this.depthRegion[j] / 8000.0D;
            if (d12 < 0.0D) {
                d12 = -d12 * 0.3D;
            }
            d12 = d12 * 3.0D - 2.0D;
            if (d12 < 0.0D) {
                d12 /= 2.0D;
                if (d12 < -1.0D) {
                    d12 = -1.0D;
                }
                d12 /= 1.4D;
                d12 /= 2.0D;
            } else {
                if (d12 > 1.0D) {
                    d12 = 1.0D;
                }
                d12 /= 8.0D;
            }
            ++j;
            double d13 = f3;
            double d14 = f2;
            d13 += d12 * 0.2D;
            d13 = d13 * 8.5D / 8.0D;
            double d5 = 8.5D + d13 * 4.0D;
            for (int j2 = 0; j2 < 33; ++j2) {
                double d6 = (j2 - d5) * 12.0D * 128.0D / 256.0D / d14;
                if (d6 < 0.0D) {
                    d6 *= 4.0D;
                }
                double d7 = this.minLimitRegion[i] / 512.0D;
                double d8 = this.maxLimitRegion[i] / 512.0D;
                double d9 = (this.mainNoiseRegion[i] / 10.0D + 1.0D) / 2.0D;
                double d10 = (d9 < 0.0D ? d7 : (d9 > 1.0D ? d8 : d7 + (d8 - d7) * d9)) - d6;
                if (j2 > 29) {
                    double d11 = ((j2 - 29) / 3.0F);
                    d10 = d10 * (1.0D - d11) + -10.0D * d11;
                }
                this.heightMap[i] = d10;
                ++i;
            }
        }
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) Random(java.util.Random) ChunkGeneratorSettings(net.minecraft.world.gen.ChunkGeneratorSettings)

Example 83 with Biome

use of net.minecraft.world.biome.Biome in project RFToolsDimensions by McJty.

the class DimensionInformation method toBytes.

public void toBytes(ByteBuf buf) {
    NetworkTools.writeString(buf, ownerName);
    if (owner == null) {
        buf.writeBoolean(false);
    } else {
        buf.writeBoolean(true);
        buf.writeLong(owner.getMostSignificantBits());
        buf.writeLong(owner.getLeastSignificantBits());
    }
    NetworkTools.writeEnum(buf, terrainType, TerrainType.TERRAIN_VOID);
    NetworkTools.writeEnumCollection(buf, featureTypes);
    NetworkTools.writeEnumCollection(buf, structureTypes);
    NetworkTools.writeEnumCollection(buf, effectTypes);
    buf.writeInt(biomes.size());
    for (Biome entry : biomes) {
        if (entry != null) {
            int id = Biome.getIdForBiome(entry);
            buf.writeInt(id);
        } else {
            buf.writeInt(Biome.getIdForBiome(Biomes.PLAINS));
        }
    }
    NetworkTools.writeEnum(buf, controllerType, ControllerType.CONTROLLER_DEFAULT);
    NetworkTools.writeString(buf, digitString);
    buf.writeLong(forcedDimensionSeed);
    buf.writeLong(baseSeed);
    buf.writeInt(worldVersion);
    buf.writeInt(Block.REGISTRY.getIDForObject(baseBlockForTerrain.getBlock()));
    buf.writeInt(baseBlockForTerrain.getBlock().getMetaFromState(baseBlockForTerrain));
    buf.writeInt(Block.REGISTRY.getIDForObject(tendrilBlock.getBlock()));
    buf.writeInt(tendrilBlock.getBlock().getMetaFromState(tendrilBlock));
    writeBlockArrayToBuf(buf, pyramidBlocks);
    writeBlockArrayToBuf(buf, sphereBlocks);
    writeBlockArrayToBuf(buf, hugeSphereBlocks);
    writeBlockArrayToBuf(buf, scatteredSphereBlocks);
    writeBlockArrayToBuf(buf, liquidSphereBlocks);
    writeFluidArrayToBuf(buf, liquidSphereFluids);
    writeBlockArrayToBuf(buf, hugeLiquidSphereBlocks);
    writeFluidArrayToBuf(buf, hugeLiquidSphereFluids);
    buf.writeInt(Block.REGISTRY.getIDForObject(canyonBlock.getBlock()));
    buf.writeInt(canyonBlock.getBlock().getMetaFromState(canyonBlock));
    buf.writeInt(Block.REGISTRY.getIDForObject(fluidForTerrain));
    writeBlockArrayToBuf(buf, extraOregen);
    writeFluidArrayToBuf(buf, fluidsForLakes);
    buf.writeBoolean(peaceful);
    buf.writeBoolean(noanimals);
    buf.writeBoolean(shelter);
    buf.writeBoolean(respawnHere);
    buf.writeBoolean(cheater);
    NetworkTools.writeFloat(buf, celestialAngle);
    NetworkTools.writeFloat(buf, timeSpeed);
    buf.writeInt(probeCounter);
    buf.writeInt(actualRfCost);
    NetworkTools.writeString(buf, injectedDimlets);
    skyDescriptor.toBytes(buf);
    weatherDescriptor.toBytes(buf);
    buf.writeLong(patreon1);
    int mobsize = 0;
    for (MobDescriptor mob : extraMobs) {
        if (mob != null) {
            mobsize++;
        }
    }
    buf.writeInt(mobsize);
    for (MobDescriptor mob : extraMobs) {
        if (mob != null) {
            NetworkTools.writeString(buf, mob.entityClass.getName());
            buf.writeInt(mob.itemWeight);
            buf.writeInt(mob.minGroupCount);
            buf.writeInt(mob.maxGroupCount);
            buf.writeInt(mob.getMaxLoaded());
        }
    }
    buf.writeInt(dimensionTypes.length);
    for (String type : dimensionTypes) {
        NetworkTools.writeString(buf, type);
    }
}
Also used : Biome(net.minecraft.world.biome.Biome)

Example 84 with Biome

use of net.minecraft.world.biome.Biome in project RFToolsDimensions by McJty.

the class DimensionInformation method dump.

public void dump(EntityPlayer player) {
    if (!injectedDimlets.isEmpty()) {
        logDebug(player, "    Injected dimlets: " + injectedDimlets);
    }
    String digits = getDigitString();
    if (!digits.isEmpty()) {
        logDebug(player, "    Digits: " + digits);
    }
    if (forcedDimensionSeed != 0) {
        logDebug(player, "    Forced seed: " + forcedDimensionSeed);
    }
    if (baseSeed != 0) {
        logDebug(player, "    Base seed: " + baseSeed);
    }
    logDebug(player, "    World version: " + worldVersion);
    TerrainType terrainType = getTerrainType();
    logDebug(player, "    Terrain: " + terrainType.toString());
    logDebug(player, "        Base block: " + getDisplayName(baseBlockForTerrain));
    if (featureTypes.contains(FeatureType.FEATURE_TENDRILS)) {
        logDebug(player, "        Tendril block: " + getDisplayName(tendrilBlock));
    }
    if (featureTypes.contains(FeatureType.FEATURE_PYRAMIDS)) {
        for (IBlockState block : pyramidBlocks) {
            if (block != null) {
                logDebug(player, "        Pyramid blocks: " + getDisplayName(block));
            }
        }
    }
    if (featureTypes.contains(FeatureType.FEATURE_ORBS)) {
        for (IBlockState block : sphereBlocks) {
            if (block != null) {
                logDebug(player, "        Orb blocks: " + getDisplayName(block));
            }
        }
    }
    if (featureTypes.contains(FeatureType.FEATURE_HUGEORBS)) {
        for (IBlockState block : hugeSphereBlocks) {
            if (block != null) {
                logDebug(player, "        Huge Orb blocks: " + getDisplayName(block));
            }
        }
    }
    if (featureTypes.contains(FeatureType.FEATURE_SCATTEREDORBS)) {
        for (IBlockState block : scatteredSphereBlocks) {
            if (block != null) {
                logDebug(player, "        Scattered Orb blocks: " + getDisplayName(block));
            }
        }
    }
    if (featureTypes.contains(FeatureType.FEATURE_LIQUIDORBS)) {
        for (IBlockState block : liquidSphereBlocks) {
            if (block != null) {
                logDebug(player, "        Liquid Orb blocks: " + getDisplayName(block));
            }
        }
    }
    if (featureTypes.contains(FeatureType.FEATURE_HUGELIQUIDORBS)) {
        for (IBlockState block : hugeLiquidSphereBlocks) {
            if (block != null) {
                logDebug(player, "        Huge Liquid Orb blocks: " + getDisplayName(block));
            }
        }
    }
    if (featureTypes.contains(FeatureType.FEATURE_CANYONS)) {
        logDebug(player, "        Canyon block: " + getDisplayName(canyonBlock));
    }
    logDebug(player, "        Base fluid: " + getDisplayName(fluidForTerrain));
    logDebug(player, "    Biome controller: " + (controllerType == null ? "<null>" : controllerType.name()));
    for (Biome biome : getBiomes()) {
        if (biome != null) {
            logDebug(player, "    Biome: " + biome.biomeName);
        }
    }
    for (FeatureType featureType : getFeatureTypes()) {
        logDebug(player, "    Feature: " + featureType.toString());
    }
    for (IBlockState block : extraOregen) {
        if (block != null) {
            logDebug(player, "        Extra ore: " + getDisplayName(block));
        }
    }
    for (Block block : fluidsForLakes) {
        logDebug(player, "        Lake fluid: " + getDisplayName(block));
    }
    if (featureTypes.contains(FeatureType.FEATURE_LIQUIDORBS)) {
        for (Block fluid : liquidSphereFluids) {
            logDebug(player, "        Liquid orb fluids: " + getDisplayName(fluid));
        }
    }
    if (featureTypes.contains(FeatureType.FEATURE_HUGELIQUIDORBS)) {
        for (Block fluid : hugeLiquidSphereFluids) {
            logDebug(player, "        Huge Liquid orb fluids: " + getDisplayName(fluid));
        }
    }
    for (StructureType structureType : getStructureTypes()) {
        logDebug(player, "    Structure: " + structureType.toString());
    }
    // }
    for (EffectType effectType : getEffectTypes()) {
        logDebug(player, "    Effect: " + effectType.toString());
    }
    logDebug(player, "    Sun brightness: " + skyDescriptor.getSunBrightnessFactor());
    logDebug(player, "    Star brightness: " + skyDescriptor.getStarBrightnessFactor());
    float r = skyDescriptor.getSkyColorFactorR();
    float g = skyDescriptor.getSkyColorFactorG();
    float b = skyDescriptor.getSkyColorFactorB();
    logDebug(player, "    Sky color: " + r + ", " + g + ", " + b);
    r = skyDescriptor.getFogColorFactorR();
    g = skyDescriptor.getFogColorFactorG();
    b = skyDescriptor.getFogColorFactorB();
    logDebug(player, "    Fog color: " + r + ", " + g + ", " + b);
    r = skyDescriptor.getCloudColorFactorR();
    g = skyDescriptor.getCloudColorFactorG();
    b = skyDescriptor.getCloudColorFactorB();
    logDebug(player, "    Cloud color: " + r + ", " + g + ", " + b);
    SkyType skyType = skyDescriptor.getSkyType();
    if (skyType != SkyType.SKY_NORMAL) {
        logDebug(player, "    Sky type: " + skyType.toString());
    }
    for (CelestialBodyType bodyType : skyDescriptor.getCelestialBodies()) {
        logDebug(player, "    Sky body: " + bodyType.name());
    }
    if (weatherDescriptor.getRainStrength() > -0.5f) {
        logDebug(player, "    Weather rain: " + weatherDescriptor.getRainStrength());
    }
    if (weatherDescriptor.getThunderStrength() > -0.5f) {
        logDebug(player, "    Weather thunder " + weatherDescriptor.getThunderStrength());
    }
    for (MobDescriptor mob : extraMobs) {
        if (mob != null) {
            logDebug(player, "    Mob: " + mob.entityClass.getName());
        }
    }
    if (peaceful) {
        logDebug(player, "    Peaceful mode");
    }
    if (noanimals) {
        logDebug(player, "    No animals mode");
    }
    if (shelter) {
        logDebug(player, "    Safe shelter");
    }
    if (respawnHere) {
        logDebug(player, "    Respawn local");
    }
    if (cheater) {
        logDebug(player, "    CHEATER!");
    }
    if (celestialAngle != null) {
        logDebug(player, "    Celestial angle: " + celestialAngle);
    }
    if (timeSpeed != null) {
        logDebug(player, "    Time speed: " + timeSpeed);
    }
    if (probeCounter > 0) {
        logDebug(player, "    Probes: " + probeCounter);
    }
    if (patreon1 != 0) {
        logDebug(player, "    Patreon: " + patreon1);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Biome(net.minecraft.world.biome.Biome) Block(net.minecraft.block.Block)

Example 85 with Biome

use of net.minecraft.world.biome.Biome in project RFToolsDimensions by McJty.

the class DimensionInformation method setupBiomeMapping.

private void setupBiomeMapping() {
    biomeMapping.clear();
    if (controllerType == ControllerType.CONTROLLER_FILTERED) {
        final Set<Integer> ids = new HashSet<>();
        for (Biome biome : biomes) {
            if (biome != null) {
                ids.add(Biome.getIdForBiome(biome));
            } else {
                ids.add(Biome.getIdForBiome(Biomes.PLAINS));
            }
        }
        ControllerType.BiomeFilter biomeFilter = new ControllerType.BiomeFilter() {

            @Override
            public boolean match(Biome biome) {
                return ids.contains(Biome.getIdForBiome(biome));
            }

            @Override
            public double calculateBiomeDistance(Biome a, Biome b) {
                return calculateBiomeDistance(a, b, false, false, false);
            }
        };
        BiomeControllerMapping.makeFilteredBiomeMap(biomeMapping, biomeFilter);
    }
}
Also used : Biome(net.minecraft.world.biome.Biome)

Aggregations

Biome (net.minecraft.world.biome.Biome)110 BlockPos (net.minecraft.util.math.BlockPos)39 IBlockState (net.minecraft.block.state.IBlockState)16 ResourceLocation (net.minecraft.util.ResourceLocation)9 World (net.minecraft.world.World)9 Nullable (javax.annotation.Nullable)8 Random (java.util.Random)7 ChunkPos (net.minecraft.util.math.ChunkPos)7 DoubleRange (com.almuradev.toolbox.util.math.DoubleRange)6 HashMap (java.util.HashMap)6 FunctionPredicate (com.almuradev.content.component.predicate.FunctionPredicate)5 Map (java.util.Map)5 Block (net.minecraft.block.Block)5 WorldServer (net.minecraft.world.WorldServer)5 BiomeChunk (com.almuradev.almura.feature.biome.BiomeChunk)4 Overwrite (org.spongepowered.asm.mixin.Overwrite)4 Entity (net.minecraft.entity.Entity)3 IntRange (com.almuradev.toolbox.util.math.IntRange)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2