Search in sources :

Example 51 with DimletKey

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);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ArrayList(java.util.ArrayList) Block(net.minecraft.block.Block) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) TerrainType(mcjty.rftoolsdim.dimensions.types.TerrainType)

Example 52 with DimletKey

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());
}
Also used : SkyDescriptor(mcjty.rftoolsdim.dimensions.description.SkyDescriptor) List(java.util.List) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 53 with DimletKey

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());
}
Also used : List(java.util.List) WeatherDescriptor(mcjty.rftoolsdim.dimensions.description.WeatherDescriptor) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 54 with DimletKey

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;
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) Settings(mcjty.rftoolsdim.config.Settings)

Example 55 with DimletKey

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;
}
Also used : DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Aggregations

DimletKey (mcjty.rftoolsdim.dimensions.dimlets.DimletKey)61 ArrayList (java.util.ArrayList)19 List (java.util.List)15 Settings (mcjty.rftoolsdim.config.Settings)14 ItemStack (net.minecraft.item.ItemStack)14 DimletType (mcjty.rftoolsdim.dimensions.dimlets.types.DimletType)13 Block (net.minecraft.block.Block)10 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)7 IBlockState (net.minecraft.block.state.IBlockState)6 TerrainType (mcjty.rftoolsdim.dimensions.types.TerrainType)5 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)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 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 Pair (org.apache.commons.lang3.tuple.Pair)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Argument (mcjty.lib.network.Argument)2