use of mcjty.rftools.items.dimlets.DimletKey in project RFTools 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() < DimletConfiguration.randomFeatureChance) {
DimletKey key = DimletRandomizer.getRandomFeature(random, false);
FeatureType featureType = DimletObjectMapping.idToFeatureType.get(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<FeatureType, List<DimletKey>>();
for (Pair<DimletKey, List<DimletKey>> dimlet : dimlets) {
DimletKey key = dimlet.getLeft();
FeatureType featureType = DimletObjectMapping.idToFeatureType.get(key);
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.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));
}
use of mcjty.rftools.items.dimlets.DimletKey in project RFTools by McJty.
the class FeatureDimletType method getRandomBlockArray.
private BlockMeta[] getRandomBlockArray(Random random, Set<FeatureType> featureTypes, Map<FeatureType, List<DimletKey>> modifiersForFeature, FeatureType t, boolean allowEmpty) {
BlockMeta[] blockArray;
if (featureTypes.contains(t)) {
List<BlockMeta> blocks = new ArrayList<BlockMeta>();
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, true);
BlockMeta bm = DimletObjectMapping.idToBlock.get(key);
if (bm != null) {
blocks.add(bm);
chance = chance * 0.80f;
}
}
}
blockArray = blocks.toArray(new BlockMeta[blocks.size()]);
for (int i = 0; i < blockArray.length; i++) {
if (blockArray[i] == null) {
blockArray[i] = BlockMeta.STONE;
}
}
} else {
blockArray = new BlockMeta[0];
}
if (allowEmpty || blockArray.length > 0) {
return blockArray;
}
return new BlockMeta[] { BlockMeta.STONE };
}
use of mcjty.rftools.items.dimlets.DimletKey in project RFTools 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.idToDigit.get(key);
}
dimensionInformation.setDigitString(digitString);
}
use of mcjty.rftools.items.dimlets.DimletKey in project RFTools by McJty.
the class MobDimletType method attemptDimletCrafting.
@Override
public DimletKey attemptDimletCrafting(ItemStack stackController, ItemStack stackMemory, ItemStack stackEnergy, ItemStack stackEssence) {
if (!isValidMobEssence(stackEssence, stackEssence.getTagCompound())) {
return null;
}
String mob = stackEssence.getTagCompound().getString("mobName");
if (!DimletCraftingTools.matchDimletRecipe(new DimletKey(DimletType.DIMLET_MOBS, mob), stackController, stackMemory, stackEnergy)) {
return null;
}
DimletKey mobDimlet = new DimletKey(DimletType.DIMLET_MOBS, mob);
return mobDimlet;
}
use of mcjty.rftools.items.dimlets.DimletKey in project RFTools by McJty.
the class SpecialDimletType method constructDimension.
@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
dimlets = DimensionInformation.extractType(DimletType.DIMLET_SPECIAL, dimlets);
for (Pair<DimletKey, List<DimletKey>> dimlet : dimlets) {
DimletKey key = dimlet.getLeft();
SpecialType specialType = DimletObjectMapping.idToSpecialType.get(key);
if (specialType == SpecialType.SPECIAL_PEACEFUL) {
dimensionInformation.setPeaceful(true);
} else if (specialType == SpecialType.SPECIAL_NOANIMALS) {
dimensionInformation.setNoanimals(true);
} else if (specialType == SpecialType.SPECIAL_SHELTER) {
dimensionInformation.setShelter(true);
} else if (specialType == SpecialType.SPECIAL_SPAWN) {
dimensionInformation.setRespawnHere(true);
}
}
}
Aggregations