Search in sources :

Example 1 with FMLControlledNamespacedRegistry

use of cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry in project Engine by VoltzEngine-Project.

the class CommandDebugItem method handleConsoleCommand.

@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
    if (args != null && args.length > 0 && !"help".equalsIgnoreCase(args[0])) {
        if (args[0].equals("dump") || args[0].equals("dumpsubs")) {
            sender.addChatMessage(new ChatComponentText("See console for data"));
            FMLControlledNamespacedRegistry<Item> registry = (FMLControlledNamespacedRegistry<Item>) Item.itemRegistry;
            Set set = registry.getKeys();
            for (Object obj : set) {
                String name = (String) obj;
                Item item = registry.getObject(name);
                System.out.println("" + name + "  " + item);
                if (item != null) {
                    if (args[0].equals("dumpsubs")) {
                        List list = new ArrayList();
                        item.getSubItems(item, item.getCreativeTab(), list);
                        for (Object o : list) {
                            System.out.println("\t" + o);
                            if (o instanceof ItemStack) {
                                ItemStack stack = (ItemStack) o;
                                System.out.println("\t\tName: " + stack.getUnlocalizedName());
                                int[] oreIDs = OreDictionary.getOreIDs(stack);
                                if (oreIDs != null && oreIDs.length > 0) {
                                    for (int i : oreIDs) {
                                        String oreName = OreDictionary.getOreName(i);
                                        System.out.println("\t\t" + oreName);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return true;
        }
    } else {
        return handleHelp(sender, args);
    }
    return false;
}
Also used : FMLControlledNamespacedRegistry(cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry) Item(net.minecraft.item.Item) Set(java.util.Set) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 2 with FMLControlledNamespacedRegistry

use of cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry 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

FMLControlledNamespacedRegistry (cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry)2 PlacementData (com.builtbroken.mc.lib.world.edit.PlacementData)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1 Block (net.minecraft.block.Block)1 Material (net.minecraft.block.material.Material)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 ChatComponentText (net.minecraft.util.ChatComponentText)1