use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.
the class TerrainDimletType method constructDimension.
@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
dimlets = DimensionInformation.extractType(DimletType.DIMLET_TERRAIN, dimlets);
List<DimletKey> modifiers;
TerrainType terrainType = TerrainType.TERRAIN_VOID;
if (dimlets.isEmpty()) {
// Pick a random terrain type with a seed that is generated from all the
// dimlets so we always get the same random value for these dimlets.
DimletKey key = DimletRandomizer.getRandomTerrain(random);
if (key != null) {
dimensionInformation.updateCostFactor(key);
terrainType = DimletObjectMapping.getTerrain(key);
}
modifiers = Collections.emptyList();
} else {
int index = random.nextInt(dimlets.size());
DimletKey key = dimlets.get(index).getLeft();
terrainType = DimletObjectMapping.getTerrain(key);
modifiers = dimlets.get(index).getRight();
}
List<IBlockState> blocks = new ArrayList<>();
List<Block> fluids = new ArrayList<>();
DimensionInformation.getMaterialAndFluidModifiers(modifiers, blocks, fluids);
dimensionInformation.setTerrainType(terrainType);
IBlockState baseBlockForTerrain;
if (dimensionInformation.isPatreonBitSet(Patreons.PATREON_LAYEREDMETA)) {
baseBlockForTerrain = Blocks.STONE.getDefaultState();
// baseBlockForTerrain = new BlockMeta(Blocks.WOOL, 127);
// @todo
} else {
if (!blocks.isEmpty()) {
baseBlockForTerrain = blocks.get(random.nextInt(blocks.size()));
if (baseBlockForTerrain == null) {
// This is the default in case None was specified.
baseBlockForTerrain = Blocks.STONE.getDefaultState();
}
} else {
// If the terrain type is void we always pick stone as a random material.
if (terrainType == TerrainType.TERRAIN_VOID) {
baseBlockForTerrain = Blocks.STONE.getDefaultState();
} else if (random.nextFloat() < WorldgenConfiguration.randomBaseBlockChance) {
DimletKey key = DimletRandomizer.getRandomMaterialBlock(random);
if (key != null) {
dimensionInformation.updateCostFactor(key);
baseBlockForTerrain = DimletObjectMapping.getBlock(key);
} else {
baseBlockForTerrain = Blocks.STONE.getDefaultState();
}
} else {
baseBlockForTerrain = Blocks.STONE.getDefaultState();
}
}
}
dimensionInformation.setBaseBlockForTerrain(baseBlockForTerrain);
Block fluidForTerrain;
if (!fluids.isEmpty()) {
fluidForTerrain = fluids.get(random.nextInt(fluids.size()));
if (fluidForTerrain == null) {
// This is the default.
fluidForTerrain = Blocks.WATER;
}
} else {
// If the terrain type is void we always pick water as the random liquid.
if (terrainType == TerrainType.TERRAIN_VOID) {
fluidForTerrain = Blocks.WATER;
} else if (random.nextFloat() < WorldgenConfiguration.randomOceanLiquidChance) {
DimletKey key = DimletRandomizer.getRandomFluidBlock(random);
if (key != null) {
dimensionInformation.updateCostFactor(key);
fluidForTerrain = DimletObjectMapping.getFluid(key);
} else {
fluidForTerrain = Blocks.WATER;
}
} else {
fluidForTerrain = Blocks.WATER;
}
}
dimensionInformation.setFluidForTerrain(fluidForTerrain);
}
use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.
the class SkyDimletType method constructDimension.
@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
dimlets = DimensionInformation.extractType(DimletType.DIMLET_SKY, dimlets);
if (dimlets.isEmpty()) {
if (random.nextFloat() < WorldgenConfiguration.randomSpecialSkyChance) {
// If nothing was specified then there is random chance we get random sky stuff.
for (int i = 0; i < 1 + random.nextInt(3); i++) {
DimletKey key = DimletRandomizer.getRandomSky(random);
if (key != null) {
List<DimletKey> modifiers = Collections.emptyList();
dimlets.add(Pair.of(key, modifiers));
}
}
}
if (random.nextFloat() < WorldgenConfiguration.randomSpecialSkyChance) {
for (int i = 0; i < random.nextInt(3); i++) {
DimletKey key = DimletRandomizer.getRandomSkyBody(random);
if (key != null) {
List<DimletKey> modifiers = Collections.emptyList();
dimlets.add(Pair.of(key, modifiers));
}
}
}
}
SkyDescriptor.Builder builder = new SkyDescriptor.Builder();
for (Pair<DimletKey, List<DimletKey>> dimletWithModifiers : dimlets) {
DimletKey key = dimletWithModifiers.getKey();
builder.combine(DimletObjectMapping.getSky(key));
}
if (dimensionInformation.isPatreonBitSet(Patreons.PATREON_DARKCORVUS)) {
builder.skyType(SkyType.SKY_STARS3);
}
dimensionInformation.setSkyDescriptor(builder.build());
}
use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.
the class WeatherDimletType method constructDimension.
@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
dimlets = DimensionInformation.extractType(DimletType.DIMLET_WEATHER, dimlets);
WeatherDescriptor.Builder builder = new WeatherDescriptor.Builder();
if (dimlets.isEmpty()) {
while (random.nextFloat() > WorldgenConfiguration.randomWeatherChance) {
DimletKey key = DimletRandomizer.getRandomWeather(random);
if (key != null) {
dimensionInformation.updateCostFactor(key);
builder.combine(WeatherRegistry.getWeatherDescriptor(key));
}
}
} else {
for (Pair<DimletKey, List<DimletKey>> dimlet : dimlets) {
DimletKey key = dimlet.getKey();
builder.combine(WeatherRegistry.getWeatherDescriptor(key));
}
}
dimensionInformation.setWeatherDescriptor(builder.build());
}
use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.
the class MaterialDimletType method findMaterialDimlet.
private static DimletKey findMaterialDimlet(NBTTagCompound essenceCompound) {
Block block = Block.REGISTRY.getObject(new ResourceLocation(essenceCompound.getString("block")));
int meta = essenceCompound.getInteger("meta");
DimletKey key = new DimletKey(DimletType.DIMLET_MATERIAL, block.getRegistryName() + "@" + meta);
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 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("mobId");
if (!DimletCraftingTools.matchDimletRecipe(new DimletKey(DimletType.DIMLET_MOB, mob), stackController, stackMemory, stackEnergy)) {
return null;
}
DimletKey mobDimlet = new DimletKey(DimletType.DIMLET_MOB, mob);
return mobDimlet;
}
Aggregations