Blocks.java 文件源码

java
阅读 19 收藏 0 点赞 0 评论 0

项目:PowerAdvantageAPI 作者:
/**
 * Adds fluid block models to the game and applies them to the fluid blocks
 */
@SideOnly(Side.CLIENT)
public static void bakeModels(){
    String modID = PowerAdvantage.MODID;
    for(Map.Entry<String,Block> e : allBlocks.entrySet()){
        Block b = e.getValue();
        String name = e.getKey();
        if(b instanceof BlockFluidBase){
            BlockFluidBase block = (BlockFluidBase)b;
            Fluid fluid = block.getFluid();
            Item item = Item.getItemFromBlock(block);
            final ModelResourceLocation fluidModelLocation = new ModelResourceLocation(
                    modID.toLowerCase() + ":" + name, "fluid");
            ModelBakery.registerItemVariants(item);
            ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition()
            {
                public ModelResourceLocation getModelLocation(ItemStack stack)
                {
                    return fluidModelLocation;
                }
            });
            ModelLoader.setCustomStateMapper(block, new StateMapperBase()
            {
                protected ModelResourceLocation getModelResourceLocation(IBlockState state)
                {
                    return fluidModelLocation;
                }
            });
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号