Java 类cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry 实例源码

项目:Gadomancy    文件:ModSubstitutions.java   
public static void preInit() {
        if(ModConfig.enableAdditionalNodeTypes) {
            try {
                ItemBlock item = (ItemBlock) Item.getItemFromBlock(ConfigBlocks.blockAiry);

                item.field_150939_a = RegisteredBlocks.blockNode;

                //Hacky way
                FMLControlledNamespacedRegistry<Block> registry = GameData.getBlockRegistry();
                registry.underlyingIntegerMap.field_148749_a.put(RegisteredBlocks.blockNode, Block.getIdFromBlock(ConfigBlocks.blockAiry));
                registry.underlyingIntegerMap.field_148748_b.set(Block.getIdFromBlock(ConfigBlocks.blockAiry), RegisteredBlocks.blockNode);
                ((BiMap)registry.field_148758_b).forcePut(RegisteredBlocks.blockNode, registry.field_148758_b.get(ConfigBlocks.blockAiry));

                registry.underlyingIntegerMap.field_148749_a.remove(ConfigBlocks.blockAiry);

                ConfigBlocks.blockAiry = RegisteredBlocks.blockNode;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
}
项目:TickDynamic    文件:EntityGroup.java   
private List<Class> loadTilesByName(String name) {
    FMLControlledNamespacedRegistry<Block> blockRegistry = GameData.getBlockRegistry();
    Block block = blockRegistry.getRaw(name);
    if(block == null)
        return null;

    //Get TileEntities for every metadata
    TileEntity currentTile;
    Class prevTile = null;
    List<Class> tileClassList = new ArrayList<Class>(16);
    for(byte b = 0; b < 16; b++)
    {
        if(block.hasTileEntity(b))
        {
            //Might throw an exception while creating TileEntity, especially at initial load of global groups
            try {
                currentTile = block.createTileEntity(world, b);
            } catch(Exception e)
            {
                if(mod.debug)
                    System.out.println("Exception while loading Tile for " + name + ":\n" + e.getMessage());
                currentTile = null;
            }

            Class cls = currentTile.getClass();
            if(currentTile != null && cls != prevTile)
            {

                if(!tileClassList.contains(cls))
                    tileClassList.add(currentTile.getClass());
            }
            prevTile = cls;
        }
    }

    return tileClassList;
}
项目:ArmorA    文件:BotaniaModule.java   
@Override
public void registerModule() {
    final FMLControlledNamespacedRegistry<Item> itemRegistry = GameData.getItemRegistry();
    Iterator<Item> itemIterator = itemRegistry.iterator();
    while (itemIterator.hasNext()) {
        Item item = itemIterator.next();
        if (item != null) {
            String itemName = itemRegistry.getNameForObject(item);
            if (item instanceof IAncientWillContainer)
                ArmorAAPI.charmRegistry.blackListCharmFromItem(itemName, CharmIDs.SIGHT);
            if (item instanceof IPhantomInkable)
                ArmorAAPI.charmRegistry.blackListCharmFromItem(itemName, CharmIDs.GLASS);
        }
    }
}
项目:OpenTechnology    文件:Utils.java   
public static String getForgeName(Item item){
    FMLControlledNamespacedRegistry<Item> items = GameData.getItemRegistry();
    return items.getNameForObject(item);
}
项目:SchematicMetaBlocks    文件:SchematicLoader.java   
public UnknownBlockEvent(String name, FMLControlledNamespacedRegistry<Block> blockRegistry)
{
    this.name = name;

    this.blockRegistry = blockRegistry;
}
项目:Pumpkin-Carvier    文件:CommonProxy.java   
public static boolean replaceBlock(Block block, Block newBlock, ItemBlock newItemBlock, boolean replaceField) {
    try {
        FMLControlledNamespacedRegistry<Block> registry = GameData.getBlockRegistry();
        String registryName = registry.getNameForObject(block);
        int id = Block.getIdFromBlock(block);
        ItemBlock itemBlock = (ItemBlock) Item.getItemFromBlock(block);

        Reflection.invoke(Constants.METHOD_REGISTRY_ADDOBJECTRAW, registry, new Object[] { id, registryName, newBlock });

        if (newItemBlock != null) {
            replaceItem(itemBlock, newItemBlock, false);
        } else if (itemBlock != null) {
            Reflection.setField(Constants.FIELD_ItemBlock_block, itemBlock, newBlock);
        }

        if (replaceField) {
            for (Field field : Blocks.class.getDeclaredFields()) {
                if (!Block.class.isAssignableFrom(field.getType())) {
                    continue;
                }

                Block block1 = (Block) field.get(null);
                if (block1 != block) {
                    continue;
                }

                Reflection.setModifier(field, Modifier.FINAL, false);
                field.set(null, newBlock);
            }
        }

        boolean flag = true;
        if (registry.getObject(registryName) != newBlock) {
            flag = false;
        }

        return true;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}