本篇教程由作者设定未经允许禁止转载。

本教程为玩家处于史诗战斗状态下,检测自身条件进行对应的武器渲染,并且该方法不会改变原本物品的特性,仅为视觉效果。

史诗战斗版本:18.5+

演示使用模型:炎葬、蓝火炎葬(注:蓝火炎葬模型为自制模型,暂未公开,仅供教程演示使用,此外,演示视频的发光效果参考本人编写的geck模型发光教程即可)。

实现方式:IDEA手写模组,需联动史诗战斗以及对应的渲染武器所在的模组。

案例:玩家开启史诗战斗-奇迹武器的狂暴状态时,将手上的炎葬渲染为蓝火炎葬灾变作者不做咱只能自己搓了

史诗战斗:切换模型渲染教程-第1张图片

演示视频:https://www.bilibili.com/video/BV1Hb421n7iY/?spm_id_from=333.999.0.0&vd_source=b1d5fa4eff82f6ee4ac851d098fd86d7


首先,在你的模组工作区新建文件夹event/engine,并新建图示两个java文件,模组名modid按个人情况设置即可:史诗战斗:切换模型渲染教程-第2张图片

首先编辑~renderengine:

史诗战斗:切换模型渲染教程-第3张图片

event.add~内填写你想要渲染的武器以及对应事件的名字。

package com.hanz0.stellarisdlc.event.engine;

import L_Ender.cataclysm.init.ModItems;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import yesman.epicfight.api.client.forgeevent.PatchedRenderersEvent;

@EventBusSubscriber(
        modid = "stellarisdlc",
        bus = Bus.MOD,
        value = {Dist.CLIENT}
)
public class StellarisdlcRenderEngine {
    public StellarisdlcRenderEngine() {
    }

    @SubscribeEvent
    public static void registerRenderer(PatchedRenderersEvent.Add event) {

        event.addItemRenderer(ModItems.THE_INCINERATOR.get(), new RenderIncinerator());

    }
}

然后在RenderIncinerator内,按如下编写:史诗战斗:切换模型渲染教程-第4张图片

史诗战斗:切换模型渲染教程-第5张图片

package com.hanz0.stellarisdlc.event.engine;
import L_Ender.cataclysm.init.ModItems;
import com.hanz0.stellarisdlc.StellarisdlcMod;
import com.hanz0.stellarisdlc.init.StellarisdlcModItems;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fml.common.Mod;
import top.theillusivec4.curios.api.CuriosApi;
import yesman.epicfight.api.utils.math.OpenMatrix4f;
import yesman.epicfight.client.renderer.patched.item.RenderItemBase;
import yesman.epicfight.model.armature.HumanoidArmature;
import yesman.epicfight.skill.SkillSlots;
import yesman.epicfight.world.capabilities.entitypatch.LivingEntityPatch;
import yesman.epicfight.world.capabilities.entitypatch.player.PlayerPatch;

@Mod.EventBusSubscriber(modid= StellarisdlcMod.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
public class RenderIncinerator extends RenderItemBase {

    public void renderItemInHand(ItemStack stack, LivingEntityPatch<?> entitypatch, InteractionHand hand, HumanoidArmature armature, OpenMatrix4f[] poses, MultiBufferSource buffer, PoseStack poseStack, int packedLight) {
        OpenMatrix4f modelMatrix = new OpenMatrix4f(this.mainhandcorrectionMatrix);
        modelMatrix.mulFront(poses[armature.toolR.getId()]);
        ItemStack modelItemStack = stack;
        if (entitypatch instanceof PlayerPatch<?> player) {
            if(CuriosApi.getCuriosHelper().findEquippedCurio(StellarisdlcModItems.IGNISHEART.get(), player.getOriginal()).isPresent())
            {
                if(player.getOriginal().getItemBySlot(EquipmentSlot.FEET).getItem() == ModItems.IGNITIUM_BOOTS.get()
                        && player.getOriginal().getItemBySlot(EquipmentSlot.HEAD).getItem() == ModItems.IGNITIUM_HELMET.get()
                        && (player.getOriginal().getItemBySlot(EquipmentSlot.CHEST).getItem() == ModItems.IGNITIUM_CHESTPLATE.get() || (player.getOriginal().getItemBySlot(EquipmentSlot.CHEST).getItem() == ModItems.IGNITIUM_ELYTRA_CHESTPLATE.get()))
                        && player.getOriginal().getItemBySlot(EquipmentSlot.LEGS).getItem() == ModItems.IGNITIUM_LEGGINGS.get())
                {
                    if(player.getSkill(SkillSlots.WEAPON_INNATE).getRemainDuration() > 0)
                    {
                        modelItemStack = new ItemStack(StellarisdlcModItems.TRUEINCINERATOR.get());

                    }
                    else
                        modelItemStack = new ItemStack(StellarisdlcModItems.ORIGINALINCINERATOR.get());
                }
            }
        }
        poseStack.pushPose();
        this.mulPoseStack(poseStack, modelMatrix);
        Minecraft.getInstance().getItemRenderer().renderStatic(modelItemStack, ItemTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, packedLight, OverlayTexture.NO_OVERLAY, poseStack, buffer, 0);
        poseStack.popPose();

    }
}

最后,正常导出模组jar文件并放入mods文件。当然不要忘了写炎葬适配史诗战斗奇迹武器巨斧的数据包