Posted May 10, 20232 yr package net.testname.testmod.entity.client; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.ArrowRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.testname.testmod.TestMod; import net.testname.testmod.world.entity.projectile.CoolArrow; //import these import net.minecraft.client.renderer.RenderType; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Matrix3f; import com.mojang.math.Matrix4f; import com.mojang.math.Vector3f; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.util.Mth; @OnlyIn(Dist.CLIENT) public class CoolArrowRenderer extends ArrowRenderer<CoolArrow> { public CoolArrowRenderer(EntityRendererProvider.Context context) { super(context); } public static final ResourceLocation TEXTURE = new ResourceLocation(TestMod.MOD_ID, "textures/entity/projectiles/cool_arrow_model.png"); private static final RenderType RENDER_TYPE = RenderType.entityCutoutNoCull(TEXTURE); @Override public ResourceLocation getTextureLocation(CoolArrow p_114482_) { return TEXTURE; } public void render(CoolArrow pEntity, float pEntityYaw, float pPartialTicks, PoseStack pMatrixStack, MultiBufferSource pBuffer, int pPackedLight) { pMatrixStack.pushPose(); pMatrixStack.mulPose(Vector3f.YP.rotationDegrees(Mth.lerp(pPartialTicks, pEntity.yRotO, pEntity.getYRot()) - 90.0F)); pMatrixStack.mulPose(Vector3f.ZP.rotationDegrees(Mth.lerp(pPartialTicks, pEntity.xRotO, pEntity.getXRot()))); int i = 0; float f = 0.0F; float f1 = 0.5F; float f2 = 0.0F; float f3 = 0.15625F; float f4 = 0.0F; float f5 = 0.15625F; float f6 = 0.15625F; float f7 = 0.3125F; float f8 = 0.05625F; float f9 = (float)pEntity.shakeTime - pPartialTicks; if (f9 > 0.0F) { float f10 = -Mth.sin(f9 * 3.0F) * f9; pMatrixStack.mulPose(Vector3f.ZP.rotationDegrees(f10)); } pMatrixStack.mulPose(Vector3f.XP.rotationDegrees(45.0F)); pMatrixStack.scale(0.05625F, 0.05625F, 0.05625F); pMatrixStack.translate(-4.0D, 0.0D, 0.0D); VertexConsumer vertexconsumer = pBuffer.getBuffer(RENDER_TYPE); //Buffer wants a RenderType, hence the private static field above! PoseStack.Pose posestack$pose = pMatrixStack.last(); Matrix4f matrix4f = posestack$pose.pose(); Matrix3f matrix3f = posestack$pose.normal(); this.vertex(matrix4f, matrix3f, vertexconsumer, -7, -2, -2, 0.0F, 0.15625F, -1, 0, 0, pPackedLight); this.vertex(matrix4f, matrix3f, vertexconsumer, -7, -2, 2, 0.15625F, 0.15625F, -1, 0, 0, pPackedLight); this.vertex(matrix4f, matrix3f, vertexconsumer, -7, 2, 2, 0.15625F, 0.3125F, -1, 0, 0, pPackedLight); this.vertex(matrix4f, matrix3f, vertexconsumer, -7, 2, -2, 0.0F, 0.3125F, -1, 0, 0, pPackedLight); this.vertex(matrix4f, matrix3f, vertexconsumer, -7, 2, -2, 0.0F, 0.15625F, 1, 0, 0, pPackedLight); this.vertex(matrix4f, matrix3f, vertexconsumer, -7, 2, 2, 0.15625F, 0.15625F, 1, 0, 0, pPackedLight); this.vertex(matrix4f, matrix3f, vertexconsumer, -7, -2, 2, 0.15625F, 0.3125F, 1, 0, 0, pPackedLight); this.vertex(matrix4f, matrix3f, vertexconsumer, -7, -2, -2, 0.0F, 0.3125F, 1, 0, 0, pPackedLight); for(int j = 0; j < 4; ++j) { pMatrixStack.mulPose(Vector3f.XP.rotationDegrees(90.0F)); this.vertex(matrix4f, matrix3f, vertexconsumer, -8, -2, 0, 0.0F, 0.0F, 0, 1, 0, pPackedLight); this.vertex(matrix4f, matrix3f, vertexconsumer, 8, -2, 0, 0.5F, 0.0F, 0, 1, 0, pPackedLight); this.vertex(matrix4f, matrix3f, vertexconsumer, 8, 2, 0, 0.5F, 0.15625F, 0, 1, 0, pPackedLight); this.vertex(matrix4f, matrix3f, vertexconsumer, -8, 2, 0, 0.0F, 0.15625F, 0, 1, 0, pPackedLight); } pMatrixStack.popPose(); super.render(pEntity, pEntityYaw, pPartialTicks, pMatrixStack, pBuffer, pPackedLight); } public void vertex(Matrix4f pMatrix, Matrix3f pNormals, VertexConsumer pVertexBuilder, int pOffsetX, int pOffsetY, int pOffsetZ, float pTextureX, float pTextureY, int pNormalX, int p_113835_, int p_113836_, int pPackedLight) { pVertexBuilder.vertex(pMatrix, (float)pOffsetX, (float)pOffsetY, (float)pOffsetZ).color(255, 255, 255, 255).uv(pTextureX, pTextureY).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(pPackedLight).normal(pNormals, (float)pNormalX, (float)p_113836_, (float)p_113835_).endVertex(); } } when I run the code everything runs fine but I don't know how to change the render to use my own json model
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.