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

The following code just sets a small rendered plane with the texture of "polished_andesite" at the coordinates 0|60|0
But even in complete darkness, the plane still "glows". How can I get the plane to interact with the local light level?
Im using the following options:

public static final RenderType OVERLAY_PLATE = makeType("overlay_plate",
            DefaultVertexFormats.POSITION_TEX, GL11.GL_QUADS, 256,
            RenderType.State.getBuilder()
                    .layer(PROJECTION_LAYERING)
                    .transparency(TRANSLUCENT_TRANSPARENCY)
                    .texture(new TextureState(new ResourceLocation("minecraft:textures/block/polished_andesite.png"), false, false))
                    .depthTest(DEPTH_ALWAYS)
                    .cull(CULL_DISABLED)
                    .lightmap(LIGHTMAP_DISABLED)
                    .writeMask(COLOR_WRITE)
                    .build(true));

And the following code to render:

	@SubscribeEvent
    public void render(RenderWorldLastEvent event) {
		
		 IRenderTypeBuffer.Impl bufferSource = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource();
	     IVertexBuilder builder = bufferSource.getBuffer(ModRenderTypes.OVERLAY_PLATE);
		 Vec3d view = Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView();
		 
		 int x = 0;
		 int y = 60;
		 int z = 0;
		 
		 MatrixStack stack = event.getMatrixStack();
	     stack.push();
	     stack.translate(-view.x, -view.y, -view.z);
		
	     Matrix4f lastStack = stack.getLast().getMatrix();
	     
	     builder.pos(lastStack, x, y + 1.0f, z + 1.0f).tex(0, 1).endVertex();
	     builder.pos(lastStack, x + 1.0f, y + 1.0f, z + 1.0f).tex(1, 1).lightmap(0, 240).endVertex();
	     builder.pos(lastStack, x + 1.0f, y + 1.0f, z).tex(1, 0).lightmap(0, 240).endVertex();
	     builder.pos(lastStack, x, y + 1.0f, z).tex(0, 0).lightmap(0, 240).endVertex();
		 stack.pop();
	     bufferSource.finish(ModRenderTypes.OVERLAY_PLATE);
	     
	}



My idea was to copy some code out of the BlockRendererDispatcher and use it every tick with the measured light level. Is that a possible?
Any help is appreciated,

-Lukas

2021-01-19 16_48_55-Minecraft_ 1.15.2 - Singleplayer.png

Well, it might help if you enable the lightmap associated with the block. Also, why not render a block using BlockRendererDispatcher? Finally, why do you even need to render a custom version of a block?

  • Author
6 hours ago, ChampionAsh5357 said:

Well, it might help if you enable the lightmap associated with the block. Also, why not render a block using BlockRendererDispatcher? Finally, why do you even need to render a custom version of a block?

OK, thats a good idea, Ive managed to do that, now I have two problems:
1)The Lighting, the "blockRenderer.renderBlock" requires a field called "combinedLighting", Ive found the method "mc.worldRenderer.getCombinedLight()"  it requires the a "BlockPos", and a "ILightReader", how can I get the current ILightReader instance?

2) The block is "wobbling" because now I only translate with "stack.translate(0, 60, 1);" what can I do against that? Before, I was translating with:

Vec3d view = mc.gameRenderer.getActiveRenderInfo().getProjectedView();
stack.translate(-view.x, -view.y, -view.z);

 

6 hours ago, CookieLukas said:

how can I get the current ILightReader instance?

You can look at what implements the interface. You can also infer which classes might need to know the light value (for example, the world).

6 hours ago, CookieLukas said:

2) The block is "wobbling" because now I only translate with "stack.translate(0, 60, 1);" what can I do against that? Before, I was translating with:

To be able to statically project an object, you need to take the position and subtract it from the projected view.

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.