[Enhancement/功能请求] 关于渲染的部分...
NOBTG opened this issue · 23 comments
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小时内删除,其衍生出的任何法律作者一率不承担。
第二版本!优化更多更整齐! 懒得git[doge]
https://drive.google.com/file/d/1DCOxCjhoDH3OiGXYsMhDVbsJs5Fi3XVT/view?usp=sharing
比较粗暴的实现:
`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 末影珍珠爆炸渲染用的是obj,有些不能删的
@NOBTG 末影珍珠爆炸渲染用的是obj,有些不能删的
OK,那可以做完再刪,我去試試看啥翅膀的
另外,這個東西的作用是0,因為沒有關聯 (雖然設置了,但fsh、json沒有寫進去)
實際上:
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);