Search in sources :

Example 1 with ControllerType

use of mcjty.rftoolsdim.dimensions.types.ControllerType in project RFToolsDimensions by McJty.

the class GuiEssencePainter method validateDimlets.

private void validateDimlets() {
    List<String> tooltips = new ArrayList<String>();
    TerrainType terrainType = null;
    int cntTerrain = 0;
    int cntBiomes = 0;
    int cntController = 0;
    int cntOwner = 0;
    for (int i = EssencePainterContainer.SLOT_DIMLETS; i < EssencePainterContainer.SLOT_TAB; i++) {
        Slot slot = inventorySlots.getSlot(i);
        if (slot != null && ItemStackTools.isValid(slot.getStack())) {
            ItemStack stack = slot.getStack();
            DimletKey key = KnownDimletConfiguration.getDimletKey(stack);
            if (key.getType() == DimletType.DIMLET_TERRAIN) {
                cntTerrain++;
                terrainType = DimletObjectMapping.getTerrain(key);
            } else if (key.getType() == DimletType.DIMLET_BIOME) {
                cntBiomes++;
            } else if (key.getType() == DimletType.DIMLET_CONTROLLER) {
                cntController++;
            } else if (key.getType() == DimletType.DIMLET_SPECIAL && DimletObjectMapping.getSpecial(key) == SpecialType.SPECIAL_OWNER) {
                cntOwner++;
            }
        }
    }
    if (cntOwner > 1) {
        tooltips.add("Using more then one owner dimlet is not useful!");
    }
    if (GeneralConfiguration.ownerDimletsNeeded && cntOwner != 1) {
        tooltips.add("You cannot make a dimension without an owner dimlet!");
        storeButton.setEnabled(false);
    }
    if (cntTerrain > 1) {
        tooltips.add("Using more then one TERRAIN is not useful!");
        terrainType = null;
    }
    if (cntController > 1) {
        tooltips.add("Using more then one CONTROLLER is not useful!");
    }
    List<DimletKey> modifiers = new ArrayList<DimletKey>();
    for (int i = EssencePainterContainer.SLOT_DIMLETS; i < EssencePainterContainer.SLOT_TAB; i++) {
        Slot slot = inventorySlots.getSlot(i);
        if (slot != null && ItemStackTools.isValid(slot.getStack())) {
            ItemStack stack = slot.getStack();
            DimletKey key = KnownDimletConfiguration.getDimletKey(stack);
            DimletType type = key.getType();
            if (type.dimletType.isModifier()) {
                modifiers.add(key);
            } else {
                List<DimletKey> modifiersForType = extractModifiersForType(modifiers, type);
                if (type == DimletType.DIMLET_TERRAIN) {
                    if (DimletObjectMapping.getTerrain(key) == TerrainType.TERRAIN_VOID && !modifiersForType.isEmpty()) {
                        tooltips.add("VOID terrain cannot use modifiers");
                    }
                } else if (type == DimletType.DIMLET_FEATURE) {
                    FeatureType featureType = DimletObjectMapping.getFeature(key);
                    Counter<DimletType> modifierAmountUsed = new Counter<DimletType>();
                    for (DimletKey modifier : modifiersForType) {
                        modifierAmountUsed.increment(modifier.getType());
                    }
                    for (Map.Entry<DimletType, Integer> entry : modifierAmountUsed.entrySet()) {
                        Integer amountSupported = featureType.getSupportedModifierAmount(entry.getKey());
                        if (amountSupported == null) {
                            tooltips.add(shortenName(featureType.name()) + " does not use " + shortenName(entry.getKey().name()) + " modifiers!");
                        } else if (amountSupported == 1 && entry.getValue() > 1) {
                            tooltips.add(shortenName(featureType.name()) + " only needs one " + shortenName(entry.getKey().name()) + " modifier!");
                        }
                    }
                    if (terrainType == null && !featureType.supportsAllTerrains()) {
                        tooltips.add(shortenName(featureType.name()) + " is possibly useless as it does not work on all terrains!");
                    }
                    if (terrainType != null && !featureType.isTerrainSupported(terrainType)) {
                        tooltips.add(shortenName(featureType.name()) + " does not work for terrain " + shortenName(terrainType.name()) + "!");
                    }
                } else if (type == DimletType.DIMLET_CONTROLLER) {
                    ControllerType controllerType = DimletObjectMapping.getController(key);
                    int neededBiomes = controllerType.getNeededBiomes();
                    if (neededBiomes != -1) {
                        if (cntBiomes > neededBiomes) {
                            tooltips.add("Too many biomes specified for " + shortenName(controllerType.name()) + "!");
                        } else if (cntBiomes < neededBiomes) {
                            tooltips.add("Too few biomes specified for " + shortenName(controllerType.name()) + "!");
                        }
                    }
                }
            }
        }
    }
    if (!modifiers.isEmpty()) {
        tooltips.add("There are dangling modifiers in this descriptor");
    }
    boolean error = true;
    if (tooltips.isEmpty()) {
        tooltips.add("Everything appears to be alright");
        error = false;
    }
    validateField.setTooltips(tooltips.toArray(new String[tooltips.size()]));
    validateField.setColor(error ? 0xFF0000 : 0x008800);
    validateField.setText(error ? "Warn" : "Ok");
}
Also used : FeatureType(mcjty.rftoolsdim.dimensions.types.FeatureType) ArrayList(java.util.ArrayList) TerrainType(mcjty.rftoolsdim.dimensions.types.TerrainType) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) ControllerType(mcjty.rftoolsdim.dimensions.types.ControllerType) Counter(mcjty.lib.varia.Counter) DimletType(mcjty.rftoolsdim.dimensions.dimlets.types.DimletType) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ControllerType

use of mcjty.rftoolsdim.dimensions.types.ControllerType in project RFToolsDimensions by McJty.

the class GuiDimensionEnscriber method validateDimlets.

private void validateDimlets() {
    List<String> tooltips = new ArrayList<String>();
    TerrainType terrainType = null;
    int cntTerrain = 0;
    int cntBiomes = 0;
    int cntController = 0;
    int cntOwner = 0;
    for (int i = DimensionEnscriberContainer.SLOT_DIMLETS; i < DimensionEnscriberContainer.SLOT_TAB; i++) {
        Slot slot = inventorySlots.getSlot(i);
        if (slot != null && ItemStackTools.isValid(slot.getStack())) {
            ItemStack stack = slot.getStack();
            DimletKey key = KnownDimletConfiguration.getDimletKey(stack);
            if (key.getType() == DimletType.DIMLET_TERRAIN) {
                cntTerrain++;
                terrainType = DimletObjectMapping.getTerrain(key);
            } else if (key.getType() == DimletType.DIMLET_BIOME) {
                cntBiomes++;
            } else if (key.getType() == DimletType.DIMLET_CONTROLLER) {
                cntController++;
            } else if (key.getType() == DimletType.DIMLET_SPECIAL && DimletObjectMapping.getSpecial(key) == SpecialType.SPECIAL_OWNER) {
                cntOwner++;
            }
        }
    }
    if (cntOwner > 1) {
        tooltips.add("Using more then one owner dimlet is not useful!");
    }
    if (GeneralConfiguration.ownerDimletsNeeded && cntOwner != 1) {
        tooltips.add("You cannot make a dimension without an owner dimlet!");
        storeButton.setEnabled(false);
    }
    if (cntTerrain > 1) {
        tooltips.add("Using more then one TERRAIN is not useful!");
        terrainType = null;
    }
    if (cntController > 1) {
        tooltips.add("Using more then one CONTROLLER is not useful!");
    }
    List<DimletKey> modifiers = new ArrayList<DimletKey>();
    for (int i = DimensionEnscriberContainer.SLOT_DIMLETS; i < DimensionEnscriberContainer.SLOT_TAB; i++) {
        Slot slot = inventorySlots.getSlot(i);
        if (slot != null && ItemStackTools.isValid(slot.getStack())) {
            ItemStack stack = slot.getStack();
            DimletKey key = KnownDimletConfiguration.getDimletKey(stack);
            DimletType type = key.getType();
            if (type.dimletType.isModifier()) {
                modifiers.add(key);
            } else {
                List<DimletKey> modifiersForType = extractModifiersForType(modifiers, type);
                if (type == DimletType.DIMLET_TERRAIN) {
                    if (DimletObjectMapping.getTerrain(key) == TerrainType.TERRAIN_VOID && !modifiersForType.isEmpty()) {
                        tooltips.add("VOID terrain cannot use modifiers");
                    }
                } else if (type == DimletType.DIMLET_FEATURE) {
                    FeatureType featureType = DimletObjectMapping.getFeature(key);
                    Counter<DimletType> modifierAmountUsed = new Counter<DimletType>();
                    for (DimletKey modifier : modifiersForType) {
                        modifierAmountUsed.increment(modifier.getType());
                    }
                    for (Map.Entry<DimletType, Integer> entry : modifierAmountUsed.entrySet()) {
                        Integer amountSupported = featureType.getSupportedModifierAmount(entry.getKey());
                        if (amountSupported == null) {
                            tooltips.add(shortenName(featureType.name()) + " does not use " + shortenName(entry.getKey().name()) + " modifiers!");
                        } else if (amountSupported == 1 && entry.getValue() > 1) {
                            tooltips.add(shortenName(featureType.name()) + " only needs one " + shortenName(entry.getKey().name()) + " modifier!");
                        }
                    }
                    if (terrainType == null && !featureType.supportsAllTerrains()) {
                        tooltips.add(shortenName(featureType.name()) + " is possibly useless as it does not work on all terrains!");
                    }
                    if (terrainType != null && !featureType.isTerrainSupported(terrainType)) {
                        tooltips.add(shortenName(featureType.name()) + " does not work for terrain " + shortenName(terrainType.name()) + "!");
                    }
                } else if (type == DimletType.DIMLET_CONTROLLER) {
                    ControllerType controllerType = DimletObjectMapping.getController(key);
                    int neededBiomes = controllerType.getNeededBiomes();
                    if (neededBiomes != -1) {
                        if (cntBiomes > neededBiomes) {
                            tooltips.add("Too many biomes specified for " + shortenName(controllerType.name()) + "!");
                        } else if (cntBiomes < neededBiomes) {
                            tooltips.add("Too few biomes specified for " + shortenName(controllerType.name()) + "!");
                        }
                    }
                }
            }
        }
    }
    if (!modifiers.isEmpty()) {
        tooltips.add("There are dangling modifiers in this descriptor");
    }
    boolean error = true;
    if (tooltips.isEmpty()) {
        tooltips.add("Everything appears to be alright");
        error = false;
    }
    validateField.setTooltips(tooltips.toArray(new String[tooltips.size()]));
    validateField.setColor(error ? 0xFF0000 : 0x008800);
    validateField.setText(error ? "Warn" : "Ok");
}
Also used : FeatureType(mcjty.rftoolsdim.dimensions.types.FeatureType) ArrayList(java.util.ArrayList) TerrainType(mcjty.rftoolsdim.dimensions.types.TerrainType) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) ControllerType(mcjty.rftoolsdim.dimensions.types.ControllerType) Counter(mcjty.lib.varia.Counter) DimletType(mcjty.rftoolsdim.dimensions.dimlets.types.DimletType) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ControllerType

use of mcjty.rftoolsdim.dimensions.types.ControllerType 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));
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) List(java.util.List) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) ControllerType(mcjty.rftoolsdim.dimensions.types.ControllerType) HashSet(java.util.HashSet) Pair(org.apache.commons.lang3.tuple.Pair)

Example 4 with ControllerType

use of mcjty.rftoolsdim.dimensions.types.ControllerType in project RFToolsDimensions by McJty.

the class GenericBiomeProvider method getModdedBiomeGenerators.

@Override
public GenLayer[] getModdedBiomeGenerators(WorldType worldType, long seed, GenLayer[] original) {
    if (dimensionInformation == null) {
        dimensionInformation = hackyDimensionInformation;
    }
    GenLayer[] layer = super.getModdedBiomeGenerators(worldType, seed, original);
    GenLayer rflayer = null;
    ControllerType type;
    DimensionInformation di = dimensionInformation;
    if (di == null) {
        di = hackyDimensionInformation;
    }
    type = di.getControllerType();
    switch(type) {
        case CONTROLLER_DEFAULT:
        case CONTROLLER_SINGLE:
            // Cannot happen
            break;
        case CONTROLLER_CHECKERBOARD:
            rflayer = new GenLayerCheckerboard(this, seed, layer[0]);
            break;
        case CONTROLLER_COLD:
        case CONTROLLER_WARM:
        case CONTROLLER_MEDIUM:
        case CONTROLLER_DRY:
        case CONTROLLER_WET:
        case CONTROLLER_FIELDS:
        case CONTROLLER_MOUNTAINS:
        case CONTROLLER_MAGICAL:
        case CONTROLLER_FOREST:
        case CONTROLLER_FILTERED:
            rflayer = new GenLayerFiltered(this, seed, layer[0], type);
            break;
    }
    GenLayerVoronoiZoom zoomLayer = new GenLayerVoronoiZoom(10L, rflayer);
    zoomLayer.initWorldGenSeed(seed);
    return new GenLayer[] { rflayer, zoomLayer, rflayer };
}
Also used : GenLayerVoronoiZoom(net.minecraft.world.gen.layer.GenLayerVoronoiZoom) GenLayer(net.minecraft.world.gen.layer.GenLayer) ControllerType(mcjty.rftoolsdim.dimensions.types.ControllerType) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation)

Aggregations

ControllerType (mcjty.rftoolsdim.dimensions.types.ControllerType)4 DimletKey (mcjty.rftoolsdim.dimensions.dimlets.DimletKey)3 ArrayList (java.util.ArrayList)2 Counter (mcjty.lib.varia.Counter)2 DimletType (mcjty.rftoolsdim.dimensions.dimlets.types.DimletType)2 FeatureType (mcjty.rftoolsdim.dimensions.types.FeatureType)2 TerrainType (mcjty.rftoolsdim.dimensions.types.TerrainType)2 Slot (net.minecraft.inventory.Slot)2 ItemStack (net.minecraft.item.ItemStack)2 HashSet (java.util.HashSet)1 List (java.util.List)1 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)1 Biome (net.minecraft.world.biome.Biome)1 GenLayer (net.minecraft.world.gen.layer.GenLayer)1 GenLayerVoronoiZoom (net.minecraft.world.gen.layer.GenLayerVoronoiZoom)1 Pair (org.apache.commons.lang3.tuple.Pair)1