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;
}
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;
}
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;
}
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;
}
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);
}
}
Aggregations