• 论坛

导航

  • 主页
  • 样式指南
  • 入门
    • 概述
    • Mod的结构
    • Forge更新检查器
    • 依赖管理
    • 调试分析器
  • 概念
    • Sides
    • 资源
    • 注册表
    • Jar签名
    • 国际化和本地化
  • 方块
    • 概述
    • 介绍方块状态
    • 方块互动
  • 动画 API
    • 概述
    • 骨骼
    • 动画状态机
    • 使用API
  • TileEntity
    • 概述
    • 特殊渲染器
  • 物品
    • 主页
    • 战利品表
  • 模型
    • 模型概述
    • 模型文件
    • 方块状态
      • 方块状态JSON概述
      • Forge方块状态JSON
    • 绑定模型到方块和物品
    • 彩色纹理
    • 物品属性概述
    • 高级模型(未翻译)
      • 高级模型介绍
      • IModel
      • IModelState and IModelPart
      • IBakedModel
      • Extended Blockstates
      • Perspective
      • ItemOverrideList
      • ICustomModelLoader
        • accepts
        • loadModel
        • onResourceManagerReload
  • 渲染
    • TileEntityItemStackRenderer
  • 事件
    • 基本用法
  • 网络
    • 主页
    • 概述
    • SimpleImpl
    • 实体
  • 数据储存
    • 能力系统
    • World Saved Data
    • 拓展实体属性
    • Config注解
  • 工具
    • 合成
    • 矿物词典
    • 权限API
  • 效果
    • 音效
  • 惯例
    • 版本命名
    • 文件位置
    • 加载阶段
  • 参与Forge开发
    • 入门
    • PR指南

ICustomModelLoader

Recall that when a model is requested for a ModelResourceLocation, every ICustomModelLoader is queried to find the one that volunteers to load the model from the ModelResourceLocation. In order to actually use a custom implementation of IModel, whether it be a full blown model format like OBJ models or a completely in-code model generator like ModelDynBucket, it must be done through an ICustomModelLoader. Even though it has “loader” in the name, there is no need for it to actually load anything; for in-code models like ModelDynBucket, the ICustomModelLoader will normally be a dummy that just instantiates the IModel without touching any files.

If multiple ICustomModelLoaders attempt to load the same ResourceLocation, the game will crash with a LoaderException. Therefore, care must be taken to keep the namespace of an ICustomModelLoader safe from being infringed upon. The Forge OBJ and B3D loaders do so by requiring that the namespace of a ResourceLocation be registered to them beforehand, and they only match ResourceLocations with the appropriate file extension.

In order for an ICustomModelLoader to actually be used, it must be registered with ModelLoaderRegistry.registerLoader.

accepts

Tests whether this ICustomModelLoader is willing to load the given ResourceLocation. Preferably, this should be based on the ResourceLocation alone and not on the file contents. If two ICustomModelLoaders accept the same ResourceLocation, a LoaderException is thrown. Therefore, care should be taken to make sure that the namespace of the ICustomModelLoader is unique enough to avoid collisions.

loadModel

Get the model for the given ResourceLocation. Note that it doesn’t need to “load” anything. For example, completely in-code models will simply instantiate the IModel class and totally ignore the file.

onResourceManagerReload

Called whenever the resource packs are (re)loaded. In this method, any caches the ICustomModelLoader keeps should be dumped. Following this, loadModel will be called again to reload all the IModels, so if the IModels kept some caches in themselves, they do not need to be cleared.

基于 MkDocs 使用自定义主题构建. 托管于 Read the Docs.
启用夜间模式