-
Notifications
You must be signed in to change notification settings - Fork 3
Home
本 Mod 提供诸多与视觉效果相关的功能。
- 基岩版模型加载与渲染
一般的加载器在 BrModelLoader
中,会加载位于 assets/<modid>/bedrock_models
中的所有模型。
可以使用 BlockBench 制作基岩版模型。
可以通过 BrModelLoader#getModel
取出模型,如果要取出 assets/abc/bedrock_models/cde.json
,使用 ResourceLocation("abc", "cde")
取出即可。
用于物品/方块的模型加载器位于 BlockBrModelLoader
中,使用了 IGeometryLoader 相关机制。
使用方法与原版物品/方块模型一致,只是需要将 loader 设置为 eyelib:bedrock_model。
例如:
"parent": "block/block",
"loader": "eyelib:bedrock_model",
"textures": {
"texture": "eyelib:block/test_texture",
"particle": "ferment:block/test_texture"
}
- 基岩版动画与动画控制器
分别位于 BrAnimationLoader
和 BrAnimationControllerLoader
中,因为计划有泛化的需要,因此 BrAnimationController
与 BrAnimationEntry
都是实现了 Animation
接口的。
使用时一般只需要调用 tickAnimation
即可,因为基岩版动画使用 molang 作为脚本语言,因此需要一个类标记 molang 的作用域,MolangScope
的作用正是如此,可以使用 RenderData#getComponent
获取模组内置的渲染数据,其中就有 scope 字段。
动画与动画控制器也可以在 BlockBench 中制作。
- 基岩版模型渲染及动画应用
模型渲染的逻辑在 ModelRenderer
中,其中 TwoSideInfoMap map
可以使用 BrModelTextures#getTwoSideInfo
获取,R infos
就是动画数据。
例如:
AnimationComponent animationComponent = data.getAnimationComponent();
animationComponent.setup(FOX_TAIL_MODEL, FOX_TAIL_MODEL);
var infos = BrAnimator.tickAnimation(animationComponent,
RenderData.getComponent(pLivingEntity).getScope(), ClientTickHandler.getTick() + pPartialTick);
RenderType renderType = RenderType.entitySolid(FOX_TAIL_TEXTURE);
ModelRenderer.render(new RenderParams(
pLivingEntity,
pPoseStack.last().copy(),
pPoseStack,
renderType,
pBuffer.getBuffer(renderType),
pPackedLight,
LivingEntityRenderer.getOverlayCoords(pLivingEntity, 0)
), BrModelLoader.getModel(FOX_TAIL_MODEL), infos,
new BrModelTextures.TwoSideInfoMap(new HashMap<>()),
new ModelRenderVisitorList(List.of(BuiltInBrModelRenderVisitors.BLANK.get())));
(节选自 TheElixir)