use of mcjty.rftoolsdim.dimensions.dimlets.types.DimletType in project RFToolsDimensions by McJty.
the class DimensionDescriptor method calculateCreationRfCost.
private int calculateCreationRfCost(List<Pair<DimletKey, List<DimletKey>>> dimlets, List<DimletKey> unusedModifiers, int tickCost) {
int rf = DimletCosts.baseDimensionCreationCost;
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.getModifierCreateCostFactor(modifier.getType(), key);
rf += (int) (getCreationCost(modifier.getType(), modifier) * mult);
}
}
rf += getCreationCost(type, key);
}
for (DimletKey modifier : unusedModifiers) {
rf += getCreationCost(modifier.getType(), modifier);
}
return rf;
}
use of mcjty.rftoolsdim.dimensions.dimlets.types.DimletType in project RFToolsDimensions by McJty.
the class DimensionDescriptor method groupDimletsAndModifiers.
private void groupDimletsAndModifiers(List<DimletKey> descriptors, List<Pair<DimletKey, List<DimletKey>>> dimlets, List<DimletKey> currentModifiers) {
for (DimletKey key : descriptors) {
DimletType type = key.getType();
if (type.dimletType.isModifier()) {
// Keep the modifier here until we find a dimlet for which it fits.
currentModifiers.add(key);
} else {
List<DimletKey> modifiers = new ArrayList<DimletKey>();
if (!currentModifiers.isEmpty()) {
// Check if we collected modifiers that fit with this type.
List<DimletKey> copy = new ArrayList<DimletKey>(currentModifiers);
// Iterate over a copy so that we can delete from original list.
for (DimletKey modifier : copy) {
if (type.dimletType.isModifiedBy(modifier.getType())) {
modifiers.add(modifier);
currentModifiers.remove(modifier);
}
}
}
dimlets.add(Pair.of(key, modifiers));
}
}
}
use of mcjty.rftoolsdim.dimensions.dimlets.types.DimletType in project RFToolsDimensions by McJty.
the class CmdCreateDimlet method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length != 3) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Bad parameters!"));
return;
}
String typeString = fetchString(sender, args, 1, "material");
String name = fetchString(sender, args, 2, "");
DimletType type = DimletType.getTypeByName(typeString);
if (type == null) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Bad type!"));
return;
}
if (!(sender instanceof EntityPlayer)) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "This command only works as a player!"));
return;
}
EntityPlayer player = (EntityPlayer) sender;
ItemStack dimlet = KnownDimletConfiguration.getDimletStack(new DimletKey(type, name));
InventoryHelper.mergeItemStack(player.inventory, false, dimlet, 0, 35, null);
}
use of mcjty.rftoolsdim.dimensions.dimlets.types.DimletType in project RFToolsDimensions by McJty.
the class DimensionInformation method injectDimlet.
public void injectDimlet(DimletKey key) {
DimletType type = key.getType();
IDimletType itype = type.dimletType;
if (itype.isInjectable()) {
addToCost(key);
itype.inject(key, this);
}
}
use of mcjty.rftoolsdim.dimensions.dimlets.types.DimletType in project RFToolsDimensions by McJty.
the class CmdTestDimlet method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length != 4) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Bad parameters!"));
return;
}
String typeString = fetchString(sender, args, 1, "material");
String mod = fetchString(sender, args, 2, "minecraft");
String name = fetchString(sender, args, 3, "");
DimletType type = DimletType.getTypeByName(typeString);
if (type == null) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Bad type!"));
return;
}
Settings settings = DimletRules.getSettings(type, mod, name, Collections.emptySet(), 0, Collections.emptyMap());
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.GREEN + settings.toString()));
}
Aggregations