Search in sources :

Example 1 with PlacementData

use of com.builtbroken.mc.lib.world.edit.PlacementData in project Engine by VoltzEngine-Project.

the class HeatedBlockRegistry method init.

public static void init(Configuration config) {
    config.setCategoryComment("Block_Heat_Conversions", "Conversion of one block into another when a lot of heat is added. \'Air\' as an entry means the block turned into dust");
    //Vanilla block handling
    //---------------------------------------------------------------------
    //Heating values
    addNewHeatingConversion(Blocks.ice, Blocks.water, (int) TemperatureUnit.Fahrenheit.conversion.toKelvin(32));
    addNewHeatingConversion(Blocks.obsidian, Blocks.lava, 1293);
    //Made up conversion
    addNewHeatingConversion(Blocks.grass, Blocks.dirt, 600);
    //Cooling values
    addNewCoolingConversion(Blocks.water, Blocks.ice, 273);
    //made up value
    addNewCoolingConversion(Blocks.lava, Blocks.obsidian, 1200);
    //Everything else not registered, init with default data to make life simple
    if (Block.blockRegistry instanceof FMLControlledNamespacedRegistry) {
        FMLControlledNamespacedRegistry reg = ((FMLControlledNamespacedRegistry) Block.blockRegistry);
        for (Object obj : reg.typeSafeIterable()) {
            if (obj instanceof Block) {
                String name = reg.getNameForObject(obj);
                Material mat = ((Block) obj).getMaterial();
                Block blockToConvertTo = Blocks.air;
                int temp = 0;
                if (mat.getCanBurn()) {
                    temp = 600;
                } else if (mat == Material.rock) {
                    temp = 1293;
                    blockToConvertTo = Blocks.lava;
                }
                if (temp > 0) {
                    String conversion = config.getString(name, "Heat_Conversions", reg.getNameForObject(blockToConvertTo), "");
                    if (reg.getObject(conversion) != null) {
                        Object c_obj = reg.getObject(conversion);
                        if (c_obj instanceof Block) {
                            if (!warm_up_conversion.containsKey(obj)) {
                                if (blockToConvertTo == Blocks.lava) {
                                    addNewHeatingConversion((Block) obj, new PlacementData(Blocks.cobblestone, 0), temp);
                                } else {
                                    addNewHeatingConversion((Block) obj, (Block) c_obj, temp);
                                }
                            }
                        } else {
                            Engine.instance.logger().error("Error c_obj is not an instance of a block");
                        }
                    } else {
                        Engine.instance.logger().error("Config entry for heat conversion " + name + " has an invalid conversion of " + conversion);
                    }
                }
            }
        }
    }
}
Also used : PlacementData(com.builtbroken.mc.lib.world.edit.PlacementData) FMLControlledNamespacedRegistry(cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry) Block(net.minecraft.block.Block) Material(net.minecraft.block.material.Material)

Example 2 with PlacementData

use of com.builtbroken.mc.lib.world.edit.PlacementData in project Engine by VoltzEngine-Project.

the class Engine method init.

@EventHandler
public void init(FMLInitializationEvent evt) {
    Engine.metadata.modId = References.NAME;
    Engine.metadata.name = References.NAME;
    Engine.metadata.description = References.NAME + " is a content creation toolkit";
    Engine.metadata.url = "http://www.builtbroken.com";
    Engine.metadata.version = References.VERSION;
    Engine.metadata.authorList = Arrays.asList("DarkCow");
    Engine.metadata.autogenerated = false;
    //Late registration of content
    if ((getConfig().hasKey("Content", "LoadOres") || metallicOresRequested) && getConfig().getBoolean("LoadOres", "Content", metallicOresRequested, "Loads up ore blocks and generators. Ore Generation can be disable separate if you want to keep the block for legacy purposes.")) {
        ore = contentRegistry.newBlock("veStoneOre", new BlockOre("stone"), ItemBlockOre.class);
        MetallicOres.registerSet(ore, getConfig());
    }
    if ((getConfig().hasKey("Content", "LoadGemOres") || gemOresRequested) && getConfig().getBoolean("LoadGemOres", "Content", gemOresRequested, "Loads up Gem Ores.")) {
        gemOre = contentRegistry.newBlock("veGemOre", new BlockGemOre("stone"), ItemBlockGemOre.class);
        GemOres.registerSet(gemOre, getConfig());
        for (GemTypes types : GemTypes.values()) {
            if (types.isRequested()) {
                types.item = new ItemGem(types);
                contentRegistry.newItem("Gem" + LanguageUtility.capitalizeFirst(types.name) + "Item", types.item);
                for (Gems gem : Gems.values()) {
                    if (gem != Gems.UNKNOWN) {
                        OreDictionary.registerOre(types.oreDict + gem.getOreName(), types.stack(gem));
                    }
                }
            }
        }
    }
    if (multiBlockRequested) {
        multiBlock = new BlockMultiblock();
        GameRegistry.registerBlock(multiBlock, ItemBlockMulti.class, "veMultiBlock");
        NEIProxy.hideItem(multiBlock);
        EnumMultiblock.register();
    }
    boolean forceLoadSheetMetal = (sheetMetalRequested || getConfig().hasKey("SheetMetalContent", "ForceLoad")) && getConfig().getBoolean("ForceLoad", "SheetMetalContent", true, "Forces the sheet metal items to load even if not requests. Content can still loaded if false as long as another mod requests the content for crafting. This config is designed to prevent items from vanishing in saves.");
    boolean forceLoadSimpleTools = (simpleToolsRequested || getConfig().hasKey("SimpleToolsContent", "ForceLoad")) && getConfig().getBoolean("ForceLoad", "SimpleToolsContent", true, "Forces the simple tools items to load even if not requests. Content can still loaded if false as long as another mod requests the content for crafting. This config is designed to prevent items from vanishing in saves.");
    boolean forceLoadCircuits = (circuitsRequested || getConfig().hasKey("Content", "LoadCircuits")) && getConfig().getBoolean("LoadCircuits", "Content", true, "Forces the circuit items to load even if not requests. Content can still loaded if false as long as another mod requests the content for crafting. This config is designed to prevent items from vanishing in saves.");
    boolean forceLoadCraftingParts = (craftingPartsRequested || getConfig().hasKey("Content", "LoadCraftingParts")) && getConfig().getBoolean("LoadCraftingParts", "Content", true, "Forces the crafting items(Motors, coils, simple electrical parts) to load even if not requests. Content can still loaded if false as long as another mod requests the content for crafting. This config is designed to prevent items from vanishing in saves.");
    if (sheetMetalRequested || forceLoadSheetMetal) {
        itemSheetMetalTools = getManager().newItem("veSheetMetalTools", ItemSheetMetalTools.class);
        itemSheetMetal = getManager().newItem("veSheetMetal", ItemSheetMetal.class);
    }
    if (circuitsRequested || forceLoadCircuits) {
        itemCircuits = getManager().newItem("veCircuits", ItemCircuits.class);
    }
    if (craftingPartsRequested || forceLoadCraftingParts) {
        itemCraftingParts = getManager().newItem("veCraftingParts", ItemCraftingParts.class);
    }
    if (simpleToolsRequested || forceLoadSimpleTools) {
        itemSimpleCraftingTools = getManager().newItem("veSimpleTools", ItemSimpleCraftingTool.class);
    }
    if (getConfig().getBoolean("LoadHeatedRocks", "Content", heatedRockRequested, "Loads up heated rocks which are used to give explosions an extra short term effect on stone.")) {
        heatedStone = contentRegistry.newBlock("VEHeatedRock", BlockHeatedStone.class, ItemBlockMetadata.class);
        NEIProxy.hideItem(heatedStone);
        if (enabledHeatMap) {
            HeatedBlockRegistry.addNewHeatingConversion(Blocks.stone, new PlacementDataExtended(heatedStone, 15, Block.getIdFromBlock(Blocks.stone)), 600);
            HeatedBlockRegistry.addNewHeatingConversion(Blocks.cobblestone, new PlacementDataExtended(heatedStone, 15, Block.getIdFromBlock(Blocks.cobblestone)), 600);
        }
    } else {
        HeatedBlockRegistry.addNewHeatingConversion(Blocks.stone, new PlacementData(Blocks.cobblestone, 1), 600);
    }
    logger.info("Starting resource generator");
    long start = System.nanoTime();
    for (DefinedGenItems genItem : DefinedGenItems.values()) {
        if ((getConfig().hasKey("ForceLoadContent", genItem.name) || genItem.isRequested()) && getConfig().getBoolean(genItem.name, "ForceLoadContent", genItem.isRequested(), "Forces the items to load even if not requests. Content can still loaded if false as long as another mod requests the content for crafting. This config is designed to prevent items from vanishing in saves.") || genItem.isRequested()) {
            logger.info("\tGenerating " + genItem.name);
            genItem.item = getManager().newItem("ve" + LanguageUtility.capitalizeFirst(genItem.name), new ItemGenMaterial(genItem));
            for (GenMaterial mat : GenMaterial.values()) {
                if (mat == GenMaterial.UNKNOWN || genItem.ignoreMaterials.contains(mat)) {
                    NEIProxy.hideItem(new ItemStack(genItem.item, 1, mat.ordinal()));
                } else {
                    OreDictionary.registerOre(genItem.oreDict + LanguageUtility.capitalizeFirst(mat.name().toLowerCase()), genItem.stack(mat));
                }
            }
            if (genItem == DefinedGenItems.INGOT && getConfig().getBoolean("EnableCheapSteelRecipe", "Content", true, "Enables iron ingot to steel ingot smelting recipe. Only disable if another recipe for steel exists or most items will be uncraftable.")) {
                //TODO check to make sure doesn't conflict
                GameRegistry.addSmelting(Items.iron_ingot, genItem.stack(GenMaterial.STEEL), 0f);
            }
        }
    }
    if (metallicOresRequested) {
        //Register alt ore names
        OreDictionary.registerOre("oreBauxite", MetallicOres.BAUXITE.stack());
        OreDictionary.registerOre("oreMagnesite", MetallicOres.MAGNESITE.stack());
    }
    logger.info("Done... Took " + StringHelpers.formatTimeDifference(start, System.nanoTime()));
    loader.init();
    getManager().fireInit();
}
Also used : ItemSheetMetal(com.builtbroken.mc.core.content.resources.items.ItemSheetMetal) ItemGenMaterial(com.builtbroken.mc.core.content.resources.items.ItemGenMaterial) ItemSimpleCraftingTool(com.builtbroken.mc.core.content.tool.ItemSimpleCraftingTool) BlockOre(com.builtbroken.mc.core.content.resources.ore.BlockOre) ItemBlockOre(com.builtbroken.mc.core.content.resources.ore.ItemBlockOre) ItemCircuits(com.builtbroken.mc.core.content.parts.ItemCircuits) ItemBlockOre(com.builtbroken.mc.core.content.resources.ore.ItemBlockOre) GenMaterial(com.builtbroken.mc.core.content.resources.GenMaterial) ItemGenMaterial(com.builtbroken.mc.core.content.resources.items.ItemGenMaterial) BlockHeatedStone(com.builtbroken.mc.core.content.blocks.BlockHeatedStone) PlacementDataExtended(com.builtbroken.mc.lib.world.edit.PlacementDataExtended) PlacementData(com.builtbroken.mc.lib.world.edit.PlacementData) BlockMultiblock(com.builtbroken.mc.framework.multiblock.BlockMultiblock) ItemSheetMetalTools(com.builtbroken.mc.core.content.tool.ItemSheetMetalTools) DefinedGenItems(com.builtbroken.mc.core.content.resources.DefinedGenItems) ItemCraftingParts(com.builtbroken.mc.core.content.parts.ItemCraftingParts) MRHandlerItemStack(com.builtbroken.mc.lib.recipe.item.MRHandlerItemStack) ItemStack(net.minecraft.item.ItemStack) ItemBlockMetadata(com.builtbroken.mc.prefab.tile.item.ItemBlockMetadata) EventHandler(cpw.mods.fml.common.Mod.EventHandler)

Aggregations

PlacementData (com.builtbroken.mc.lib.world.edit.PlacementData)2 BlockHeatedStone (com.builtbroken.mc.core.content.blocks.BlockHeatedStone)1 ItemCircuits (com.builtbroken.mc.core.content.parts.ItemCircuits)1 ItemCraftingParts (com.builtbroken.mc.core.content.parts.ItemCraftingParts)1 DefinedGenItems (com.builtbroken.mc.core.content.resources.DefinedGenItems)1 GenMaterial (com.builtbroken.mc.core.content.resources.GenMaterial)1 ItemGenMaterial (com.builtbroken.mc.core.content.resources.items.ItemGenMaterial)1 ItemSheetMetal (com.builtbroken.mc.core.content.resources.items.ItemSheetMetal)1 BlockOre (com.builtbroken.mc.core.content.resources.ore.BlockOre)1 ItemBlockOre (com.builtbroken.mc.core.content.resources.ore.ItemBlockOre)1 ItemSheetMetalTools (com.builtbroken.mc.core.content.tool.ItemSheetMetalTools)1 ItemSimpleCraftingTool (com.builtbroken.mc.core.content.tool.ItemSimpleCraftingTool)1 BlockMultiblock (com.builtbroken.mc.framework.multiblock.BlockMultiblock)1 MRHandlerItemStack (com.builtbroken.mc.lib.recipe.item.MRHandlerItemStack)1 PlacementDataExtended (com.builtbroken.mc.lib.world.edit.PlacementDataExtended)1 ItemBlockMetadata (com.builtbroken.mc.prefab.tile.item.ItemBlockMetadata)1 EventHandler (cpw.mods.fml.common.Mod.EventHandler)1 FMLControlledNamespacedRegistry (cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry)1 Block (net.minecraft.block.Block)1 Material (net.minecraft.block.material.Material)1