本文整理匯總了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();
}
}
}
示例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;
}
示例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");
}
}
}
//////////////////////////////////////////////////////
}
示例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;
}