Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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
	}
}

 

  • 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
	}

2021-09-02_22_21_59.png.5c88ab0e57d114864783b7b768619a24.png

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.