Avaritia:Reforged

Avaritia:Reforged

45.5k Downloads

[Enhancement/功能请求] 关于渲染的部分...

NOBTG opened this issue · 23 comments

commented

Checks/检查

  • I confirm that I have searched for existing issues / pull requests before reporting to avoid duplicate reporting./我确认在报告之前我已经搜索了现有的问题或者拉取请求,以避免重复报告。
  • I confirm that I noted that if I don't follow the instructions, the issue may be closed directly./我确认我已经检查,如果我不按照说明进行操作,该问题可能会被直接关闭。

Description/描述

由于Avaritia 1.18.2暂时没有Source Code,我自己反编译与修改了一部分代码,使其优化,此版本还是需要CodeChickenLib awa,但是也许可以做参考,无尽弓与锭还有剑都有做。

Link : https://github.com/NOBTG/1.18.2-Avaritia-Cosmic_and_Halo-Renderer

你需要在Mod主类加上:

        DataGenerators.init()
ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
        DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> ClientInit::init);
    private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, "avaritia");
    public static final RegistryObject<InfinitySwordItem> INFINITY_SWORD = ITEMS.register("infinity_sword", () -> new InfinitySwordItem(new Item.Properties()));
    public static final RegistryObject<InfinityBowItem> INFINITY_BOW = ITEMS.register("infinity_bow", () -> new InfinityBowItem(new Item.Properties()));
    public static final RegistryObject<Item> INFINITY_INGOT = ITEMS.register("infinity_ingot", () -> new Item(new Item.Properties()));

请注意! 此代码仅供惨考与学习之用,下载后请于24小时内删除,其衍生出的任何法律作者一率不承担。

commented

感谢提供,帮大忙了 😍

commented

不客气! (其实我也在做1.20的无尽渲染qwq)

commented

如果之后有新进展会通过这个板块说的,保证开源!

commented

Check Avaritia Universal for 1.17.1, there is a cosmic render there

commented

azzzz,谢谢哈!

commented
commented

对了,也许之后我可以帮你搞Rainbow Eyes Renderer and Cosmic Armor Renderer,还有珍珠的圆形model

commented

Entity这边我还挺可以的

commented

假设以后你做好了Cosmic Renderer,我可以拿来用吗(在我的mod)?

commented

随意啦

commented

比较粗暴的实现:
`import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.renderer.entity.layers.RenderLayer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.NotNull;

@onlyin(Dist.CLIENT)
public class ArmorInfinityLayer extends RenderLayer<LivingEntity, HumanoidModel> {
public static float tick = 0.0F;
public static ResourceLocation eyeTex = new ResourceLocation(MOD_ID, "infinity_armor_eyes.png");

public ArmorInfinityLayer(RenderLayerParent<LivingEntity, HumanoidModel<LivingEntity>> pRenderer) {
    super(pRenderer);
}

{
    new Thread(() -> {
        while (Minecraft.getInstance().isRunning()) {
            ArmorInfinityLayer.tick += 1.6f;
            ArmorInfinityLayer.tick = ArmorInfinityLayer.tick >= 720.0f ? 0.0F : ArmorInfinityLayer.tick;
            synchronized (this) {
                try {
                    this.wait(50);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }).start();
}

public void render(@NotNull PoseStack poseStack, @NotNull MultiBufferSource multiBufferSource, int i, @NotNull LivingEntity livingEntity, float v, float v1, float v2, float v3, float v4, float v5) {
    VertexConsumer vertex2 = multiBufferSource.getBuffer(RenderType.entityCutout(eyeTex));
    if (true) {
        poseStack.pushPose();
        getParentModel().hat.render(poseStack, vertex2, i, OverlayTexture.NO_OVERLAY, getCurrentRainbowColor()[0], getCurrentRainbowColor()[1], getCurrentRainbowColor()[2], 1.0F);
        poseStack.popPose();
    }
}

private static float[] getCurrentRainbowColor() {
    float val = ArmorInfinityLayer.tick % 720.0f;
    int color = HsvToRgb((val >= 360.0f ? 720.0f - val : val) / 100.0F, 0.8f, 0.8f);
    return new float[]{color >> 16 & 255, color >> 8 & 255, color & 255};
}

}
`
还是建议放在Tick Update

commented
commented

Avaritia Render :
ITextureAtlasSpriteLoader

commented

And RegisterTextureAtlasSpriteLoadersEvent

commented

And RegisterTextureAtlasSpriteLoadersEvent

已完成部分渲染

commented

emm,稍微看了一下,简单来说,不好說 (除了你写的)
因为CCLib需要很多功能,所以会添加很多Class,那很多方法是你用不到,也不需要的。
加载如此多的Class只会放慢游戏加载速度罢了,所以我替你大概整理了一下几个需要用的,(我只弄了Cosmic)。
螢幕擷取畫面 2024-06-28 181704
这边处理的方法是把未使用的方法先删除一遍,然后删除未使用的Class,循环,直到无法再删(所有方法跟Class都有被调用),但是注意循环调用(TransformList那个),那个要判断完再删除。
加油!
我只有写无尽剑 :)

(做完再删可能比较好,因为老实说我不确定有没有东西是你会用到的)

commented

@NOBTG 末影珍珠爆炸渲染用的是obj,有些不能删的

commented

还有,并不是渲染完全还原了,我不知道哪里出了问题,导致飞行时翅膀的渲染是一个块状平面!

commented

so cool

commented

@NOBTG 末影珍珠爆炸渲染用的是obj,有些不能删的

OK,那可以做完再刪,我去試試看啥翅膀的

commented

看了,是cosmic的問題
去除前:
image
去除後:
image

可以看到,去除後是沒有的
image
有空我再修修看。。。

另外,這個東西的作用是0,因為沒有關聯 (雖然設置了,但fsh、json沒有寫進去)
image
實際上:
CCShaderInstance.create(...)->new CCShaderInstance(...)->ShaderInstance.super()->
讀ResourceLocation,打開json,

ResourceLocation resourcelocation = new ResourceLocation(shaderLocation.getNamespace(), "shaders/core/" + shaderLocation.getPath() + ".json");
Reader reader = p_173336_.openAsReader(resourcelocation);
JsonObject jsonobject = GsonHelper.parse(reader);

讀uniforms,

                JsonArray jsonarray2 = GsonHelper.getAsJsonArray(jsonobject, "uniforms", (JsonArray)null);
                int l;
                if (jsonarray2 != null) {
                    l = 0;

                    for(Iterator var31 = jsonarray2.iterator(); var31.hasNext(); ++l) {
                        JsonElement jsonelement2 = (JsonElement)var31.next();

                        try {
                        this.parseUniformNode(jsonelement2);
                        } catch (Exception var18) {
                            ChainedJsonException chainedjsonexception3 = ChainedJsonException.forException(var18);
                            chainedjsonexception3.prependJsonKey("uniforms[" + l + "]");
                            throw chainedjsonexception3;
                        }
                    }
                }

調用回CCShaderInstance.parseUniformNode(...),產生CCUniform

        CCUniform uniform = CCUniform.makeUniform(name, type, count, this);
        uniforms.add(uniform);

而json:
image
和fsh:
image
都沒寫,所以這只是嘗試?

commented

這個是由於maskTexture沒有正確套用的緣故。

commented

這個是由於maskTexture沒有正確套用的緣故。

确实是,modelloader传入的时候并没有找到mask材质,已经修复,渲染完成!