Search in sources :

Example 46 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class DimensionDescriptor method calculateBonus.

private int calculateBonus(List<Pair<DimletKey, List<DimletKey>>> dimlets) {
    int rfGain = 0;
    for (Pair<DimletKey, List<DimletKey>> dimletWithModifier : dimlets) {
        DimletKey key = dimletWithModifier.getLeft();
        DimletType type = key.getType();
        int c = getMaintenanceCost(type, key);
        if (c < 0) {
            // This dimlet gives a bonus in cost. This value is a percentage.
            rfGain -= c;
        }
    }
    return rfGain;
}
Also used : DimletType(mcjty.rftoolsdim.dimensions.dimlets.types.DimletType) ArrayList(java.util.ArrayList) List(java.util.List) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 47 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class BiomeDimletType method findBiomeDimlet.

private static DimletKey findBiomeDimlet(NBTTagCompound essenceCompound) {
    String biome = essenceCompound.getString("biome");
    DimletKey key = new DimletKey(DimletType.DIMLET_BIOME, biome);
    Settings settings = KnownDimletConfiguration.getSettings(key);
    if (settings == null || !settings.isDimlet()) {
        return null;
    }
    return key;
}
Also used : DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) Settings(mcjty.rftoolsdim.config.Settings)

Example 48 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class FeatureDimletType method getRandomFluidArray.

private Block[] getRandomFluidArray(Random random, DimensionInformation dimensionInformation, Set<FeatureType> featureTypes, Map<FeatureType, List<DimletKey>> modifiersForFeature, FeatureType t, boolean allowEmpty) {
    Block[] fluidsForLakes;
    if (featureTypes.contains(t)) {
        List<IBlockState> blocks = new ArrayList<>();
        List<Block> fluids = new ArrayList<>();
        DimensionInformation.getMaterialAndFluidModifiers(modifiersForFeature.get(t), blocks, fluids);
        // If no fluids are specified we will usually have default fluid generation (water+lava). Otherwise some random selection.
        if (fluids.isEmpty()) {
            while (random.nextFloat() < WorldgenConfiguration.randomLakeFluidChance) {
                DimletKey key = DimletRandomizer.getRandomFluidBlock(random);
                if (key != null) {
                    dimensionInformation.updateCostFactor(key);
                    fluids.add(DimletObjectMapping.getFluid(key));
                }
            }
        } else if (fluids.size() == 1 && fluids.get(0) == null) {
            fluids.clear();
        }
        fluidsForLakes = fluids.toArray(new Block[fluids.size()]);
        for (int i = 0; i < fluidsForLakes.length; i++) {
            if (fluidsForLakes[i] == null) {
                fluidsForLakes[i] = Blocks.WATER;
            }
        }
    } else {
        fluidsForLakes = new Block[0];
    }
    if (allowEmpty || fluidsForLakes.length > 0) {
        return fluidsForLakes;
    }
    return new Block[] { Blocks.WATER };
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 49 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class FeatureDimletType method findFeatureDimlet.

private static DimletKey findFeatureDimlet(NBTTagCompound essenceCompound) {
    String feature = essenceCompound.getString("feature");
    DimletKey key = new DimletKey(DimletType.DIMLET_FEATURE, feature);
    Settings settings = KnownDimletConfiguration.getSettings(key);
    if (settings == null || !settings.isDimlet()) {
        return null;
    }
    return key;
}
Also used : DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) Settings(mcjty.rftoolsdim.config.Settings)

Example 50 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class FeatureDimletType method constructDimension.

@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
    TerrainType terrainType = dimensionInformation.getTerrainType();
    Set<FeatureType> featureTypes = dimensionInformation.getFeatureTypes();
    dimlets = DimensionInformation.extractType(DimletType.DIMLET_FEATURE, dimlets);
    if (dimlets.isEmpty()) {
        while (random.nextFloat() < WorldgenConfiguration.randomFeatureChance) {
            DimletKey key = DimletRandomizer.getRandomFeature(random);
            if (key != null) {
                FeatureType featureType = DimletObjectMapping.getFeature(key);
                if (!featureTypes.contains(featureType) && featureType.isTerrainSupported(terrainType)) {
                    dimensionInformation.updateCostFactor(key);
                    featureTypes.add(featureType);
                    List<DimletKey> modifiers = Collections.emptyList();
                    // @todo randomize those?
                    dimlets.add(Pair.of(key, modifiers));
                }
            }
        }
    }
    Map<FeatureType, List<DimletKey>> modifiersForFeature = new HashMap<>();
    for (Pair<DimletKey, List<DimletKey>> dimlet : dimlets) {
        FeatureType featureType = DimletObjectMapping.getFeature(dimlet.getLeft());
        featureTypes.add(featureType);
        modifiersForFeature.put(featureType, dimlet.getRight());
    }
    dimensionInformation.setFluidsForLakes(getRandomFluidArray(random, dimensionInformation, featureTypes, modifiersForFeature, FeatureType.FEATURE_LAKES, true));
    dimensionInformation.setExtraOregen(getRandomBlockArray(random, featureTypes, modifiersForFeature, FeatureType.FEATURE_OREGEN, true));
    dimensionInformation.setTendrilBlock(dimensionInformation.getFeatureBlock(random, modifiersForFeature, FeatureType.FEATURE_TENDRILS));
    dimensionInformation.setSphereBlocks(getRandomBlockArray(random, featureTypes, modifiersForFeature, FeatureType.FEATURE_ORBS, false));
    dimensionInformation.setPyramidBlocks(getRandomBlockArray(random, featureTypes, modifiersForFeature, FeatureType.FEATURE_PYRAMIDS, false));
    dimensionInformation.setHugeSphereBlocks(getRandomBlockArray(random, featureTypes, modifiersForFeature, FeatureType.FEATURE_HUGEORBS, false));
    dimensionInformation.setScatteredSphereBlocks(getRandomBlockArray(random, featureTypes, modifiersForFeature, FeatureType.FEATURE_SCATTEREDORBS, false));
    dimensionInformation.setLiquidSphereBlocks(getRandomBlockArray(random, featureTypes, modifiersForFeature, FeatureType.FEATURE_LIQUIDORBS, false));
    dimensionInformation.setLiquidSphereFluids(getRandomFluidArray(random, dimensionInformation, featureTypes, modifiersForFeature, FeatureType.FEATURE_LIQUIDORBS, false));
    dimensionInformation.setHugeLiquidSphereBlocks(getRandomBlockArray(random, featureTypes, modifiersForFeature, FeatureType.FEATURE_HUGELIQUIDORBS, false));
    dimensionInformation.setHugeLiquidSphereFluids(getRandomFluidArray(random, dimensionInformation, featureTypes, modifiersForFeature, FeatureType.FEATURE_HUGELIQUIDORBS, false));
    dimensionInformation.setCanyonBlock(dimensionInformation.getFeatureBlock(random, modifiersForFeature, FeatureType.FEATURE_CANYONS));
}
Also used : FeatureType(mcjty.rftoolsdim.dimensions.types.FeatureType) TerrainType(mcjty.rftoolsdim.dimensions.types.TerrainType) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Aggregations

DimletKey (mcjty.rftoolsdim.dimensions.dimlets.DimletKey)66 ArrayList (java.util.ArrayList)21 Settings (mcjty.rftoolsdim.config.Settings)16 ItemStack (net.minecraft.item.ItemStack)16 List (java.util.List)15 DimletType (mcjty.rftoolsdim.dimensions.dimlets.types.DimletType)14 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)11 Block (net.minecraft.block.Block)10 IBlockState (net.minecraft.block.state.IBlockState)6 TerrainType (mcjty.rftoolsdim.dimensions.types.TerrainType)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)4 HashMap (java.util.HashMap)3 IDimletType (mcjty.rftoolsdim.dimensions.dimlets.types.IDimletType)3 ControllerType (mcjty.rftoolsdim.dimensions.types.ControllerType)3 FeatureType (mcjty.rftoolsdim.dimensions.types.FeatureType)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 Pair (org.apache.commons.lang3.tuple.Pair)3 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2