當前位置: 首頁>>代碼示例>>Java>>正文


Java GameData.getBlockRegistry方法代碼示例

本文整理匯總了Java中cpw.mods.fml.common.registry.GameData.getBlockRegistry方法的典型用法代碼示例。如果您正苦於以下問題:Java GameData.getBlockRegistry方法的具體用法?Java GameData.getBlockRegistry怎麽用?Java GameData.getBlockRegistry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cpw.mods.fml.common.registry.GameData的用法示例。


在下文中一共展示了GameData.getBlockRegistry方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: preInit

import cpw.mods.fml.common.registry.GameData; //導入方法依賴的package包/類
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();
            }
        }
}
 
開發者ID:makeoo,項目名稱:Gadomancy,代碼行數:22,代碼來源:ModSubstitutions.java

示例2: loadTilesByName

import cpw.mods.fml.common.registry.GameData; //導入方法依賴的package包/類
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;
}
 
開發者ID:wildex999,項目名稱:TickDynamic,代碼行數:38,代碼來源:EntityGroup.java

示例3: onServerStart

import cpw.mods.fml.common.registry.GameData; //導入方法依賴的package包/類
@Mod.EventHandler
public void onServerStart(FMLServerStartingEvent event) {
    if (MinecraftServer.getServer().getCommandManager() instanceof ServerCommandManager) {
        ((ServerCommandManager) MinecraftServer.getServer().getCommandManager()).registerCommand(new PokecheckmeCommand());
        ((ServerCommandManager) MinecraftServer.getServer().getCommandManager()).registerCommand(new AddToGrassCommand());
    }

    if (DEBUGMODE) {
        //Here be dragons.
        for (Block block : (Iterable<Block>) GameData.getBlockRegistry()) {
            if (GameRegistry.findUniqueIdentifierFor(block).modId.equals("minecraft"))
                continue;

            String localName = block.getLocalizedName();

            if (localName.contains("tile")) {
                System.out.println("Block " + block.getClass().getName() + " Doesn't seem to have a name set!");
                System.out.println();
            }

            if (block.getCreativeTabToDisplayOn() == null) {
                System.out.println("Block " + block.getClass().getName() + " Doesn't seem to have a creative tab set!");
                System.out.println();
            }

        }

        for (Item item : (Iterable<Item>) GameData.getItemRegistry()) {
            ItemStack itemStack = new ItemStack(item, 0, 1);

            String itemName = item.getItemStackDisplayName(itemStack);

            if (!itemName.getClass().getName().contains(MODID))
                return;

            if (itemName.contains("item.")) {
                System.out.println("Item " + itemName + " doesn't seem to have a name set");
            }

        }

    }

    //////////////////////////////////////////////////////


}
 
開發者ID:AnDwHaT5,項目名稱:PixelUtilities,代碼行數:48,代碼來源:Basemod.java

示例4: replaceBlock

import cpw.mods.fml.common.registry.GameData; //導入方法依賴的package包/類
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;
}
 
開發者ID:pau101,項目名稱:Pumpkin-Carvier,代碼行數:43,代碼來源:CommonProxy.java


注:本文中的cpw.mods.fml.common.registry.GameData.getBlockRegistry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。