KubeJS Curios

模组

· 作者 zhaiji

Kubejs 的 Curios 集成

0 本站下载 0 关注 更新于 1 年前

最新 kubejs_curios_neoforge_1.21.1-1.0.4.jar · 1.21.1 · NeoForge

一键开服(送7天)

Curios 与 KubeJS 的集成

使用此模组,你可以:

  1. 从 LivingEntity 获取 CuriosHelper

  2. 创建自定义饰品槽位(Custom Curios)

  3. 为物品添加饰品能力(Curios capabilities)

  4. 注册或移除饰品的渲染

  5. 添加 CuriosJS 事件

LivingEntity 饰品辅助工具

注册饰品 & 修改物品 (启动时)

StartupEvents.registry('item', event => {
    event.create('test')
        .attachCuriosCapability(
            CuriosJSCapabilityBuilder.create()
                .curioTick((slotContext, stack) => { })
                .onEquip((slotContext, oldStack, newStack) => { })
                .onUnequip((slotContext, oldStack, newStack) => { })
                .canEquip((slotContext, stack) => true)
                .canUnequip((slotContext, stack) => true)
                .modifySlotsTooltip((tooltips, stack) => tooltips)
                .addAttribute(
                    "minecraft:generic.max_health",
                    UUID,
                    20,
                    'addition'
                )
                .modifyAttribute(attributeModificationContext => {
                    let { slotContext, UUID, stack, modifiers } = attributeModificationContext
                    attributeModificationContext.modify(
                        "minecraft:generic.armor",
                        "identifier",
                        20,
                        'addition'
                    )
                })
                .canDrop((slotContext, source, lootingLevel, recentlyHit, stack) => true)
                .modifyAttributesTooltip((tooltips, stack) => tooltips)
                .modifyFortuneLevel((slotContext, lootContext, stack) => 0)
                .modifyLootingLevel((slotContext, source, target, baseLooting, stack) => 0)
                .makesPiglinsNeutral((slotContext, stack) => false)
                .canWalkOnPowderedSnow((slotContext, stack) => false)
                .isEnderMask((slotContext, enderMan, stack) => false)
        )
        .maxStackSize(1)
        .tag("curios:head")
})

ItemEvents.modification(event => { event.modify('apple', item => { item.attachCuriosCapability( CuriosJSCapabilityBuilder.create() .curioTick((slotContext, stack) => { }) .onEquip((slotContext, oldStack, newStack) => { }) .onUnequip((slotContext, oldStack, newStack) => { }) .canEquip((slotContext, stack) => true) .canUnequip((slotContext, stack) => true) .modifySlotsTooltip((tooltips, stack) => tooltips) .addAttribute( "minecraft:generic.max_health", "identifier", 20, 'addition' ) .modifyAttribute(attributeModificationContext => { let { slotContext, UUID, stack, modifiers } = attributeModificationContext attributeModificationContext.modify( "minecraft:generic.armor", UUID, 20, 'addition' ) }) .canDrop((slotContext, source, lootingLevel, recentlyHit, stack) => true) .modifyAttributesTooltip((tooltips, stack) => tooltips) .modifyFortuneLevel((slotContext, lootContext, stack) => 0) .modifyLootingLevel((slotContext, source, target, baseLooting, stack) => 0) .makesPiglinsNeutral((slotContext, stack) => false) .canWalkOnPowderedSnow((slotContext, stack) => false) .isEnderMask((slotContext, enderMan, stack) => false) ) }) })

渲染 (客户端)

CuriosJSEvents.registerRenderer(event => {
    // 移除饰品渲染
    event.remove('test')
// 注册饰品渲染
event.register(
    'apple',
    context => {
        let {
            stack,
            slotContext,
            matrixStack,
            renderLayerParent,
            renderTypeBuffer,
            light,
            limbSwing,
            limbSwingAmount,
            partialTicks,
            ageInTicks,
            netHeadYaw,
            headPitch
        } = context
        let { modelManager } = Client
        let entity = slotContext.entity()
        let model = modelManager.getModel(new ModelResourceLocation(stack.id, 'inventory'))
        matrixStack.pushPose()
        CuriosRenderer.translateIfSneaking(matrixStack, entity)
        matrixStack.mulPose(new Quaternionf().rotateZ(JavaMath.toRadians(180)))
        matrixStack.mulPose(RotationAxis.YP.deg(-netHeadYaw))
        matrixStack.mulPose(RotationAxis.XP.deg(-headPitch))
        Client.itemRenderer.render(
            stack,
            'head',
            false,
            matrixStack,
            renderTypeBuffer,
            light,
            OverlayTexture.NO_OVERLAY,
            model
        )
        matrixStack.popPose()
    }
)

})

你是这个资源的作者?登录后可认领此资源。

评论 0

0.0
暂无评分
5 星
0
4 星
0
3 星
0
2 星
0
1 星
0
我的评分

登录后参与评分

还没有评论,来抢沙发吧

评论配图

相似资源