Search in sources :

Example 31 with Material

use of net.minecraft.block.material.Material 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)

Aggregations

Material (net.minecraft.block.material.Material)31 IBlockState (net.minecraft.block.state.IBlockState)11 Block (net.minecraft.block.Block)9 BlockPos (net.minecraft.util.math.BlockPos)9 BlockLiquid (net.minecraft.block.BlockLiquid)6 ItemStack (net.minecraft.item.ItemStack)6 World (net.minecraft.world.World)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 DirectionalBlockPos (blusunrize.immersiveengineering.api.DirectionalBlockPos)1 IPos3D (com.builtbroken.jlib.data.vector.IPos3D)1 Location (com.builtbroken.mc.imp.transform.vector.Location)1 Pos (com.builtbroken.mc.imp.transform.vector.Pos)1 PlacementData (com.builtbroken.mc.lib.world.edit.PlacementData)1 FMLControlledNamespacedRegistry (cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry)1 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)1 ThreadLargeExplosion (icbm.classic.content.explosive.thread.ThreadLargeExplosion)1 IThreadCallBack (icbm.classic.content.explosive.thread.ThreadLargeExplosion.IThreadCallBack)1 MaterialNegativeSpace (ivorius.reccomplex.block.materials.MaterialNegativeSpace)1