use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.
the class FeatureDimletType method getRandomBlockArray.
private IBlockState[] getRandomBlockArray(Random random, Set<FeatureType> featureTypes, Map<FeatureType, List<DimletKey>> modifiersForFeature, FeatureType t, boolean allowEmpty) {
IBlockState[] blockArray;
if (featureTypes.contains(t)) {
List<IBlockState> blocks = new ArrayList<>();
List<Block> fluids = new ArrayList<Block>();
DimensionInformation.getMaterialAndFluidModifiers(modifiersForFeature.get(t), blocks, fluids);
// If no blocks are specified we will generate a few random ores.
if (blocks.isEmpty()) {
float chance = 1.1f;
while (random.nextFloat() < chance) {
DimletKey key = DimletRandomizer.getRandomMaterialBlock(random);
if (key != null) {
IBlockState bm = DimletObjectMapping.getBlock(key);
if (bm != null) {
blocks.add(bm);
chance = chance * 0.80f;
}
}
}
}
blockArray = blocks.toArray(new IBlockState[blocks.size()]);
for (int i = 0; i < blockArray.length; i++) {
if (blockArray[i] == null) {
blockArray[i] = Blocks.STONE.getDefaultState();
}
}
} else {
blockArray = new IBlockState[0];
}
if (allowEmpty || blockArray.length > 0) {
return blockArray;
}
return new IBlockState[] { Blocks.STONE.getDefaultState() };
}
use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.
the class BiomeDimletType method constructDimension.
@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
Set<DimletKey> biomeKeys = new HashSet<DimletKey>();
List<Pair<DimletKey, List<DimletKey>>> biomeDimlets = DimensionInformation.extractType(DimletType.DIMLET_BIOME, dimlets);
List<Pair<DimletKey, List<DimletKey>>> controllerDimlets = DimensionInformation.extractType(DimletType.DIMLET_CONTROLLER, dimlets);
ControllerType controllerType;
// First determine the controller to use.
if (controllerDimlets.isEmpty()) {
if (random.nextFloat() < WorldgenConfiguration.randomControllerChance) {
DimletKey key = DimletRandomizer.getRandomController(random);
if (key != null) {
controllerType = DimletObjectMapping.getController(key);
} else {
controllerType = ControllerType.CONTROLLER_DEFAULT;
}
} else {
if (biomeDimlets.isEmpty()) {
controllerType = ControllerType.CONTROLLER_DEFAULT;
} else if (biomeDimlets.size() > 1) {
controllerType = ControllerType.CONTROLLER_FILTERED;
} else {
controllerType = ControllerType.CONTROLLER_SINGLE;
}
}
} else {
DimletKey key = controllerDimlets.get(random.nextInt(controllerDimlets.size())).getLeft();
controllerType = DimletObjectMapping.getController(key);
}
dimensionInformation.setControllerType(controllerType);
// Now see if we have to add or randomize biomes.
for (Pair<DimletKey, List<DimletKey>> dimletWithModifiers : biomeDimlets) {
DimletKey key = dimletWithModifiers.getKey();
biomeKeys.add(key);
}
int neededBiomes = controllerType.getNeededBiomes();
if (neededBiomes == -1) {
// Can work with any number of biomes.
if (biomeKeys.size() >= 2) {
// We already have enough biomes
neededBiomes = biomeKeys.size();
} else {
neededBiomes = random.nextInt(10) + 3;
}
}
while (biomeKeys.size() < neededBiomes) {
DimletKey key = DimletRandomizer.getRandomBiome(random);
while (key == null || biomeKeys.contains(key)) {
key = DimletRandomizer.getRandomBiome(random);
}
biomeKeys.add(key);
}
List<Biome> biomes = dimensionInformation.getBiomes();
biomes.clear();
for (DimletKey key : biomeKeys) {
biomes.add(DimletObjectMapping.getBiome(key));
}
}
use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.
the class DimensionDescriptor method parseDescriptionString.
public static List<DimletKey> parseDescriptionString(String descriptionString) {
if (descriptionString == null || descriptionString.isEmpty()) {
return Collections.emptyList();
}
List<DimletKey> result = new ArrayList<>();
String ds = descriptionString.substring(1);
if (!ds.isEmpty()) {
String[] opcodes = StringUtils.split(ds, ",");
for (String oc : opcodes) {
DimletKey key;
if (oc.startsWith("#")) {
// First comes '#', then the type of the actual dimlet.
key = DimletKey.parseKey(oc.substring(1));
} else if (oc.startsWith("?")) {
// First comes '?', then the type of the actual dimlet
key = DimletKey.parseKey(oc.substring(1));
} else {
key = DimletKey.parseKey(oc);
}
result.add(key);
}
}
return result;
}
use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.
the class DimensionDescriptor method calculateCreationRfCost.
private int calculateCreationRfCost(List<Pair<DimletKey, List<DimletKey>>> dimlets, List<DimletKey> unusedModifiers, int tickCost) {
int rf = DimletCosts.baseDimensionCreationCost;
for (Pair<DimletKey, List<DimletKey>> dimletWithModifier : dimlets) {
DimletKey key = dimletWithModifier.getLeft();
DimletType type = key.getType();
List<DimletKey> list = dimletWithModifier.getRight();
if (list != null) {
for (DimletKey modifier : list) {
float mult = type.dimletType.getModifierCreateCostFactor(modifier.getType(), key);
rf += (int) (getCreationCost(modifier.getType(), modifier) * mult);
}
}
rf += getCreationCost(type, key);
}
for (DimletKey modifier : unusedModifiers) {
rf += getCreationCost(modifier.getType(), modifier);
}
return rf;
}
use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.
the class DigitDimletType method constructDimension.
@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
dimlets = DimensionInformation.extractType(DimletType.DIMLET_DIGIT, dimlets);
String digitString = "";
for (Pair<DimletKey, List<DimletKey>> dimletWithModifiers : dimlets) {
DimletKey key = dimletWithModifiers.getKey();
digitString += DimletObjectMapping.getDigit(key);
}
dimensionInformation.setDigitString(digitString);
}
Aggregations