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;
}
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;
}
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 };
}
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;
}
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));
}
Aggregations