Nova-Committee / Re-Avaritia

MIT License
10 stars 7 forks source link

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

Open NOBTG opened 9 months ago

NOBTG commented 9 months ago

Checks/检查

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小时内删除,其衍生出的任何法律作者一率不承担。

cnlimiter commented 9 months ago

感谢提供,帮大忙了 😍

NOBTG commented 9 months ago

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

NOBTG commented 9 months ago

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

Alex-cmyk120 commented 9 months ago

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

NOBTG commented 9 months ago

第二版本!优化更多更整齐! 懒得git[doge] https://drive.google.com/file/d/1DCOxCjhoDH3OiGXYsMhDVbsJs5Fi3XVT/view?usp=sharing

NOBTG commented 9 months ago

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

NOBTG commented 9 months ago

Entity这边我还挺可以的

NOBTG commented 9 months ago

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

cnlimiter commented 9 months ago

随意啦

NOBTG commented 9 months ago

azzzz,谢谢哈!

NOBTG commented 9 months ago

比较粗暴的实现: `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

NOBTG commented 8 months ago

年轻人,你是不是想手填混淆映射表?https://www.bilibili.com/video/BV17P411C75k/?vd_source=e3005b7ff8ae98f62ccdafc0877af721

NOBTG commented 8 months ago

Avaritia Render : ITextureAtlasSpriteLoader

NOBTG commented 8 months ago

And RegisterTextureAtlasSpriteLoadersEvent

cnlimiter commented 4 weeks ago

And RegisterTextureAtlasSpriteLoadersEvent

已完成部分渲染

NOBTG commented 2 weeks ago

so cool

NOBTG commented 1 week ago

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

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

cnlimiter commented 1 week ago

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

cnlimiter commented 1 week ago

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

NOBTG commented 1 week ago

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

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

NOBTG commented 3 days ago

看了,是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 都沒寫,所以這只是嘗試?