本文整理汇总了Java中net.minecraftforge.fml.common.registry.ForgeRegistries.BLOCKS属性的典型用法代码示例。如果您正苦于以下问题:Java ForgeRegistries.BLOCKS属性的具体用法?Java ForgeRegistries.BLOCKS怎么用?Java ForgeRegistries.BLOCKS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.minecraftforge.fml.common.registry.ForgeRegistries
的用法示例。
在下文中一共展示了ForgeRegistries.BLOCKS属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAllowedValues
private static List<IBlockState> createAllowedValues(boolean allowSubBlocks,
Predicate<IBlockState> allowBlockStatePredicate) {
List<IBlockState> blocks = Lists.newArrayList();
for (Block block : ForgeRegistries.BLOCKS) {
if (allowSubBlocks) {
List<IBlockState> variantStates = getAllVariantStates(block,
BlockPropertyRegistry.getVariantProperties(block));
for (IBlockState variantState : variantStates) {
if (allowBlockStatePredicate.apply(variantState)) {
blocks.add(variantState);
}
}
} else {
IBlockState defaultState = block.getDefaultState();
if (allowBlockStatePredicate.apply(defaultState)) {
blocks.add(defaultState);
}
}
}
return blocks;
}
示例2: postInit
@EventHandler
public void postInit(FMLPostInitializationEvent event)
{
for ( Block block : ForgeRegistries.BLOCKS ) {
NonNullList<ItemStack> subBlocks = NonNullList.create();
block.getSubBlocks( block.getCreativeTabToDisplayOn(), subBlocks );
for( ItemStack subBlock : subBlocks ) {
if (subBlock.isEmpty())
continue;
Block tmpBlock = Block.getBlockFromItem( subBlock.getItem() );
blockList.add( new HelperBlock( subBlock.getDisplayName(), tmpBlock, subBlock, subBlock.getItem(), subBlock.getItem().getRegistryName() ));
}
}
}