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 want to be able to draw the typical block outline that you get when you mouse over a block in first person on any block given I already have its BlockPos.

I've found the specifics of how to draw an outline here (I know this is 1.16, I can deal with the class remappings later, assuming the logic has not significantly changed in 1.17):

https://github.com/TheGreyGhost/MinecraftByExample/blob/master/src/main/java/minecraftbyexample/usefultools/debugging/DebugBlockVoxelShapeHighlighter.java

However, this code does the drawing logic inside the DrawHighlightEvent.HighlightBlock event, and so is a bit redundant since this event is usually fired when a block looked at is being highlighted anyway (I want to outline blocks in events that don't involve the player looking at things). While I get that the point of the code is to demonstrate the inner workings of the event, it does automatically get access to important data that other events wouldn't, namely renderTypeBuffers and matrixStack (which I'm guessing are specific to the block to be outlined).

If I wanted to run this code inside, for example, GuiScreenEvent.DrawScreenEvent, how could I get access to or recreate these two variables for the BlockPos that I have?

  • Author

I've managed to convert the example over to 1.17.1 and get the two variables I needed, but now the issue is that as soon as the vertex building code is executed (vertexConsumer.vertex()) my game immediately crashes and throws an exception: java.lang.IllegalStateException: Not filled all elements of the vertex

Crash logs: https://pastebin.com/Bibb7MBM

My 1.17.1 code: https://pastebin.com/qZLdpTA5

Note that I did still just run this in the HighlightBlock event for the time being just to rule out that the crash didn't happen because I ran it in an unusual event.

I tested this code in 1.16.5 and it ran fine, even when forcing the blockpos to a constant with testBlockPos.

  • 2 months later...
On 12/27/2021 at 10:31 PM, SoLegendary said:

I want to be able to draw the typical block outline that you get when you mouse over a block in first person on any block given I already have its BlockPos.

I've found the specifics of how to draw an outline here (I know this is 1.16, I can deal with the class remappings later, assuming the logic has not significantly changed in 1.17):

https://github.com/TheGreyGhost/MinecraftByExample/blob/master/src/main/java/minecraftbyexample/usefultools/debugging/DebugBlockVoxelShapeHighlighter.java

However, this code does the drawing logic inside the DrawHighlightEvent.HighlightBlock event, and so is a bit redundant since this event is usually fired when a block looked at is being highlighted anyway (I want to outline blocks in events that don't involve the player looking at things). While I get that the point of the code is to demonstrate the inner workings of the event, it does automatically get access to important data that other events wouldn't, namely renderTypeBuffers and matrixStack (which I'm guessing are specific to the block to be outlined).

If I wanted to run this code inside, for example, GuiScreenEvent.DrawScreenEvent, how could I get access to or recreate these two variables for the BlockPos that I have?

Hey, I found the solution. Instead of using the VertexConsumer to make the wireframe, use LevelRenerer#renderVoxelShape instead. Here's an example in my code.

Edited by NindyBun

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.