Search in sources :

Example 11 with DimletKey

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));
}
Also used : FeatureType(mcjty.rftools.dimension.world.types.FeatureType) TerrainType(mcjty.rftools.dimension.world.types.TerrainType) DimletKey(mcjty.rftools.items.dimlets.DimletKey)

Example 12 with DimletKey

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 };
}
Also used : Block(net.minecraft.block.Block) DimletKey(mcjty.rftools.items.dimlets.DimletKey) BlockMeta(mcjty.lib.varia.BlockMeta)

Example 13 with DimletKey

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);
}
Also used : List(java.util.List) DimletKey(mcjty.rftools.items.dimlets.DimletKey)

Example 14 with DimletKey

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

Example 15 with DimletKey

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);
        }
    }
}
Also used : List(java.util.List) SpecialType(mcjty.rftools.dimension.world.types.SpecialType) DimletKey(mcjty.rftools.items.dimlets.DimletKey)

Aggregations

DimletKey (mcjty.rftools.items.dimlets.DimletKey)37 ItemStack (net.minecraft.item.ItemStack)9 List (java.util.List)7 ArrayList (java.util.ArrayList)6 DimletEntry (mcjty.rftools.items.dimlets.DimletEntry)5 Block (net.minecraft.block.Block)4 BlockMeta (mcjty.lib.varia.BlockMeta)3 TerrainType (mcjty.rftools.dimension.world.types.TerrainType)3 Slot (net.minecraft.inventory.Slot)3 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 Map (java.util.Map)2 MobDescriptor (mcjty.rftools.dimension.description.MobDescriptor)2 ControllerType (mcjty.rftools.dimension.world.types.ControllerType)2 FeatureType (mcjty.rftools.dimension.world.types.FeatureType)2 DimletType (mcjty.rftools.items.dimlets.DimletType)2 MerchantRecipe (net.minecraft.village.MerchantRecipe)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Counter (mcjty.lib.varia.Counter)1