Posted September 2, 20214 yr I'm currently working on rendering a BlockEntityWithoutLevelRenderer. The custom item model is in the shape of a book and I want to draw a page-specific icon on it. This icon, like particles, always points towards the camera and is directly above the book I look from anywhere. What should I do with poseStack to draw this? public class CodexItemStackRenderer extends BlockEntityWithoutLevelRenderer { public CodexItemStackRenderer() { super(Minecraft.getInstance().getBlockEntityRenderDispatcher(), Minecraft.getInstance().getEntityModels()); } @Override public void renderByItem(ItemStack itemStack, ItemTransforms.TransformType transformType, PoseStack poseStack, MultiBufferSource source, int light, int overlay) { // poseStack.pushPose(); UMUArcanum.LOGGER.info("custom model is rendered."); // Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera(); // poseStack.mulPose(Vector3f.YP.rotationDegrees(180F - camera.getYRot())); // poseStack.mulPose(Vector3f.XP.rotationDegrees(180F - camera.getXRot())); VertexConsumer consumer = source.getBuffer(RenderType.translucentNoCrumbling()); //test sprite TextureAtlasSprite sprite = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(new ResourceLocation("minecraft", "block/water_still")); Matrix4f matrix = poseStack.last().pose(); consumer.vertex(matrix, 0.0F, 1.0F, 0.0F).color(255, 255, 255, 255) .uv(sprite.getU( 0F), sprite.getV( 0F)).uv2(light).normal(0.0F, 1.0F, 0.0F).endVertex(); consumer.vertex(matrix, 0.0F, 1.0F, 1.0F).color(255, 255, 255, 255) .uv(sprite.getU(16F), sprite.getV( 0F)).uv2(light).normal(0.0F, 1.0F, 0.0F).endVertex(); consumer.vertex(matrix, 1.0F, 1.0F, 1.0F).color(255, 255, 255, 255) .uv(sprite.getU(16F), sprite.getV(16F)).uv2(light).normal(0.0F, 1.0F, 0.0F).endVertex(); consumer.vertex(matrix, 1.0F, 1.0F, 0.0F).color(255, 255, 255, 255) .uv(sprite.getU( 0F), sprite.getV(16F)).uv2(light).normal(0.0F, 1.0F, 0.0F).endVertex(); // poseStack.popPose(); // render Item model } }
September 2, 20214 yr Author It dosent work...... @Override public void renderByItem(ItemStack itemStack, ItemTransforms.TransformType transformType, PoseStack poseStack, MultiBufferSource source, int light, int overlay) { // poseStack.pushPose(); UMUArcanum.LOGGER.info("custom model is rendered."); // Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera(); // poseStack.mulPose(Vector3f.YP.rotationDegrees(180F - camera.getYRot())); // poseStack.mulPose(Vector3f.XP.rotationDegrees(180F - camera.getXRot())); VertexConsumer consumer = source.getBuffer(RenderType.translucentNoCrumbling()); //test sprite TextureAtlasSprite sprite = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(new ResourceLocation("minecraft", "block/water_still")); poseStack.mulPose(Minecraft.getInstance().getEntityRenderDispatcher().cameraOrientation()); Matrix4f matrix = poseStack.last().pose(); consumer.vertex(matrix, 0.0F, 1.0F, 0.0F).color(255, 255, 255, 255) .uv(sprite.getU( 0F), sprite.getV( 0F)).uv2(light).normal(0.0F, 1.0F, 0.0F).endVertex(); consumer.vertex(matrix, 0.0F, 1.0F, 1.0F).color(255, 255, 255, 255) .uv(sprite.getU(16F), sprite.getV( 0F)).uv2(light).normal(0.0F, 1.0F, 0.0F).endVertex(); consumer.vertex(matrix, 1.0F, 1.0F, 1.0F).color(255, 255, 255, 255) .uv(sprite.getU(16F), sprite.getV(16F)).uv2(light).normal(0.0F, 1.0F, 0.0F).endVertex(); consumer.vertex(matrix, 1.0F, 1.0F, 0.0F).color(255, 255, 255, 255) .uv(sprite.getU( 0F), sprite.getV(16F)).uv2(light).normal(0.0F, 1.0F, 0.0F).endVertex(); // poseStack.popPose(); // render Item 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.