Search in sources :

Example 1 with ForestryItem

use of forestry.core.config.ForestryItem in project ForestryMC by ForestryMC.

the class Forestry method missingMapping.

@EventHandler
public void missingMapping(FMLMissingMappingsEvent event) {
    for (MissingMapping mapping : event.get()) {
        if (mapping.type == Type.BLOCK) {
            Block block = GameRegistry.findBlock(Defaults.MOD, StringUtil.cleanTags(mapping.name));
            if (block != null) {
                mapping.remap(block);
                Proxies.log.warning("Remapping block " + mapping.name + " to " + StringUtil.cleanBlockName(block));
            }
        } else {
            Block block = GameRegistry.findBlock(Defaults.MOD, StringUtil.cleanTags(mapping.name));
            if (block != null) {
                mapping.remap(Item.getItemFromBlock(block));
                Proxies.log.warning("Remapping item " + mapping.name + " to " + StringUtil.cleanBlockName(block));
            } else {
                ForestryItem mappedItem = mappedItems.get(mapping.name);
                if (mappedItem != null) {
                    mapping.remap(mappedItem.item());
                    Proxies.log.warning("Remapping item " + mapping.name + " to " + mappedItem.name());
                }
            }
        }
    }
}
Also used : ForestryItem(forestry.core.config.ForestryItem) MissingMapping(cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping) Block(net.minecraft.block.Block) EventHandler(cpw.mods.fml.common.Mod.EventHandler)

Example 2 with ForestryItem

use of forestry.core.config.ForestryItem in project ForestryMC by ForestryMC.

the class ShapedRecipeCustom method createShapedRecipe.

public static ShapedRecipeCustom createShapedRecipe(ItemStack product, Object... materials) {
    String s = "";
    int index = 0;
    int columns = 0;
    int rows = 0;
    if (materials[index] instanceof String[]) {
        String[] as = (String[]) materials[index++];
        for (String pattern : as) {
            rows++;
            columns = pattern.length();
            s = (new StringBuilder()).append(s).append(pattern).toString();
        }
    } else {
        while (materials[index] instanceof String) {
            String pattern = (String) materials[index++];
            rows++;
            columns = pattern.length();
            s = (new StringBuilder()).append(s).append(pattern).toString();
        }
    }
    HashMap<Character, Object> hashmap = new HashMap<Character, Object>();
    for (; index < materials.length; index += 2) {
        Character character = (Character) materials[index];
        // Item
        if (materials[index + 1] instanceof Item) {
            hashmap.put(character, new ItemStack((Item) materials[index + 1]));
        } else if (materials[index + 1] instanceof ForestryItem) {
            hashmap.put(character, ((ForestryItem) materials[index + 1]).getItemStack());
        } else if (materials[index + 1] instanceof ForestryBlock) {
            hashmap.put(character, ((ForestryBlock) materials[index + 1]).getItemStack());
        } else if (materials[index + 1] instanceof Block) {
            hashmap.put(character, new ItemStack((Block) materials[index + 1], 1, Defaults.WILDCARD));
        } else if (materials[index + 1] instanceof ItemStack) {
            hashmap.put(character, materials[index + 1]);
        } else if (materials[index + 1] instanceof String) {
            hashmap.put(character, OreDictionary.getOres((String) materials[index + 1]));
        } else {
            throw new RuntimeException("Invalid Recipe Defined!");
        }
    }
    Object[] ingredients = new Object[columns * rows];
    for (int l = 0; l < columns * rows; l++) {
        char c = s.charAt(l);
        if (hashmap.containsKey(Character.valueOf(c))) {
            ingredients[l] = hashmap.get(Character.valueOf(c));
        } else {
            ingredients[l] = null;
        }
    }
    return new ShapedRecipeCustom(columns, rows, ingredients, product);
}
Also used : HashMap(java.util.HashMap) ForestryItem(forestry.core.config.ForestryItem) ForestryBlock(forestry.core.config.ForestryBlock) Item(net.minecraft.item.Item) ForestryItem(forestry.core.config.ForestryItem) Block(net.minecraft.block.Block) ForestryBlock(forestry.core.config.ForestryBlock) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ForestryItem

use of forestry.core.config.ForestryItem in project ForestryMC by ForestryMC.

the class PluginFluids method doInit.

@Override
public void doInit() {
    for (Fluids fluidType : Fluids.values()) {
        if (fluidType.getFluid() == null) {
            continue;
        }
        for (EnumContainerType type : EnumContainerType.values()) {
            ForestryItem container = fluidType.getContainerForType(type);
            if (container == null) {
                continue;
            }
            LiquidHelper.injectLiquidContainer(fluidType, container.getItemStack());
        }
        for (ItemStack filledContainer : fluidType.getOtherContainers()) {
            LiquidHelper.injectLiquidContainer(fluidType, filledContainer);
        }
    }
}
Also used : Fluids(forestry.core.fluids.Fluids) EnumContainerType(forestry.core.items.ItemLiquidContainer.EnumContainerType) ForestryItem(forestry.core.config.ForestryItem) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ForestryItem

use of forestry.core.config.ForestryItem in project ForestryMC by ForestryMC.

the class PluginFluids method registerItems.

@Override
public void registerItems() {
    for (EnumContainerType type : EnumContainerType.values()) {
        Item emptyContainer = new ItemLiquidContainer(type, Blocks.air, null);
        switch(type) {
            case CAN:
                ForestryItem.canEmpty.registerItem(emptyContainer, "canEmpty");
                break;
            case CAPSULE:
                ForestryItem.waxCapsule.registerItem(emptyContainer, "waxCapsule");
                break;
            case REFRACTORY:
                ForestryItem.refractoryEmpty.registerItem(emptyContainer, "refractoryEmpty");
                break;
        }
        for (Fluids fluidType : Fluids.values()) {
            ForestryItem container = fluidType.getContainerForType(type);
            if (container == null) {
                continue;
            }
            ItemLiquidContainer liquidContainer = new ItemLiquidContainer(type, fluidType.getBlock(), fluidType.getColor());
            fluidType.setProperties(liquidContainer);
            container.registerItem(liquidContainer, container.toString());
        }
    }
}
Also used : Item(net.minecraft.item.Item) ForestryItem(forestry.core.config.ForestryItem) ItemLiquidContainer(forestry.core.items.ItemLiquidContainer) EnumContainerType(forestry.core.items.ItemLiquidContainer.EnumContainerType) Fluids(forestry.core.fluids.Fluids) ForestryItem(forestry.core.config.ForestryItem)

Aggregations

ForestryItem (forestry.core.config.ForestryItem)4 Fluids (forestry.core.fluids.Fluids)2 EnumContainerType (forestry.core.items.ItemLiquidContainer.EnumContainerType)2 Block (net.minecraft.block.Block)2 Item (net.minecraft.item.Item)2 ItemStack (net.minecraft.item.ItemStack)2 EventHandler (cpw.mods.fml.common.Mod.EventHandler)1 MissingMapping (cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping)1 ForestryBlock (forestry.core.config.ForestryBlock)1 ItemLiquidContainer (forestry.core.items.ItemLiquidContainer)1 HashMap (java.util.HashMap)1