Search in sources :

Example 56 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class BiomeDimletType method findBiomeDimlet.

private static DimletKey findBiomeDimlet(NBTTagCompound essenceCompound) {
    String biome = essenceCompound.getString("biome");
    DimletKey key = new DimletKey(DimletType.DIMLET_BIOME, biome);
    Settings settings = KnownDimletConfiguration.getSettings(key);
    if (settings == null || !settings.isDimlet()) {
        return null;
    }
    return key;
}
Also used : DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) Settings(mcjty.rftoolsdim.config.Settings)

Example 57 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class DimensionDescriptor method calculateBonus.

private int calculateBonus(List<Pair<DimletKey, List<DimletKey>>> dimlets) {
    int rfGain = 0;
    for (Pair<DimletKey, List<DimletKey>> dimletWithModifier : dimlets) {
        DimletKey key = dimletWithModifier.getLeft();
        DimletType type = key.getType();
        int c = getMaintenanceCost(type, key);
        if (c < 0) {
            // This dimlet gives a bonus in cost. This value is a percentage.
            rfGain -= c;
        }
    }
    return rfGain;
}
Also used : DimletType(mcjty.rftoolsdim.dimensions.dimlets.types.DimletType) ArrayList(java.util.ArrayList) List(java.util.List) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 58 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class DimensionDescriptor method calculateTickCost.

private int calculateTickCost(List<Pair<DimletKey, List<DimletKey>>> dimlets) {
    int ticks = DimletCosts.baseDimensionTickCost;
    for (Pair<DimletKey, List<DimletKey>> dimletWithModifier : dimlets) {
        DimletKey key = dimletWithModifier.getLeft();
        DimletType type = key.getType();
        List<DimletKey> list = dimletWithModifier.getRight();
        if (list != null) {
            for (DimletKey modifier : list) {
                float mult = type.dimletType.getModifierTickCostFactor(modifier.getType(), key);
                ticks += (int) (getTickCost(modifier.getType(), modifier) * mult);
            }
        }
        ticks += getTickCost(type, key);
    }
    return ticks;
}
Also used : DimletType(mcjty.rftoolsdim.dimensions.dimlets.types.DimletType) ArrayList(java.util.ArrayList) List(java.util.List) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 59 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class DimensionDescriptor method getDimletsWithModifiers.

public List<Pair<DimletKey, List<DimletKey>>> getDimletsWithModifiers() {
    List<Pair<DimletKey, List<DimletKey>>> result = new ArrayList<Pair<DimletKey, List<DimletKey>>>();
    String ds = descriptionString;
    if (ds.startsWith("@")) {
        ds = ds.substring(1);
    }
    if (!ds.isEmpty()) {
        List<DimletKey> modifiers = new ArrayList<DimletKey>();
        String[] opcodes = StringUtils.split(ds, ",");
        for (String oc : opcodes) {
            DimletKey key;
            if (oc.startsWith("#")) {
                // First comes '#', then the type of the actual dimlet.
                key = DimletKey.parseKey(oc.substring(1));
                modifiers.add(key);
            } else if (oc.startsWith("?")) {
            } else {
                key = DimletKey.parseKey(oc);
                result.add(Pair.of(key, modifiers));
                modifiers = new ArrayList<DimletKey>();
            }
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) Pair(org.apache.commons.lang3.tuple.Pair)

Example 60 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class DimensionDescriptor method constructDescriptionStringNew.

private void constructDescriptionStringNew(StringBuilder s, List<Pair<DimletKey, List<DimletKey>>> dimlets, List<DimletKey> currentModifiers) {
    s.append('@');
    boolean first = true;
    for (Pair<DimletKey, List<DimletKey>> dimletWithModifiers : dimlets) {
        DimletKey key = dimletWithModifiers.getLeft();
        List<DimletKey> mods = dimletWithModifiers.getRight();
        if (mods != null) {
            for (DimletKey modifier : mods) {
                if (!first) {
                    s.append(',');
                }
                first = false;
                s.append('#').append(modifier);
            }
        }
        if (!first) {
            s.append(',');
        }
        first = false;
        s.append(key);
    }
    // Now add all unused modifiers to the end.
    for (DimletKey modifier : currentModifiers) {
        if (s.length() > 0) {
            s.append(',');
        }
        s.append('?').append(modifier);
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) 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