Search in sources :

Example 6 with DimletType

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;
}
Also used : DimletType(mcjty.rftoolsdim.dimensions.dimlets.types.DimletType) ArrayList(java.util.ArrayList) List(java.util.List) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 7 with DimletType

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));
        }
    }
}
Also used : DimletType(mcjty.rftoolsdim.dimensions.dimlets.types.DimletType) ArrayList(java.util.ArrayList) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 8 with DimletType

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);
}
Also used : DimletType(mcjty.rftoolsdim.dimensions.dimlets.types.DimletType) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString) ItemStack(net.minecraft.item.ItemStack) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 9 with DimletType

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);
    }
}
Also used : DimletType(mcjty.rftoolsdim.dimensions.dimlets.types.DimletType) IDimletType(mcjty.rftoolsdim.dimensions.dimlets.types.IDimletType) IDimletType(mcjty.rftoolsdim.dimensions.dimlets.types.IDimletType)

Example 10 with DimletType

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()));
}
Also used : DimletType(mcjty.rftoolsdim.dimensions.dimlets.types.DimletType) TextComponentString(net.minecraft.util.text.TextComponentString) Settings(mcjty.rftoolsdim.config.Settings) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

DimletType (mcjty.rftoolsdim.dimensions.dimlets.types.DimletType)19 DimletKey (mcjty.rftoolsdim.dimensions.dimlets.DimletKey)13 ArrayList (java.util.ArrayList)9 ItemStack (net.minecraft.item.ItemStack)8 List (java.util.List)5 IDimletType (mcjty.rftoolsdim.dimensions.dimlets.types.IDimletType)4 HashMap (java.util.HashMap)3 Counter (mcjty.lib.varia.Counter)2 Settings (mcjty.rftoolsdim.config.Settings)2 ControllerType (mcjty.rftoolsdim.dimensions.types.ControllerType)2 FeatureType (mcjty.rftoolsdim.dimensions.types.FeatureType)2 TerrainType (mcjty.rftoolsdim.dimensions.types.TerrainType)2 ItemMeshDefinition (net.minecraft.client.renderer.ItemMeshDefinition)2 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)2 Slot (net.minecraft.inventory.Slot)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 Map (java.util.Map)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1