Posted December 28, 20213 yr 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?
December 29, 20213 yr 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.
March 1, 20223 yr https://github.com/NindyBun/BurnerGun_1.18.1/blob/master/src/main/java/com/nindybun/burnergun/client/renderer/BlockRenderer.java I did mine using RenderWorldLastEvent in 1.16.5 because I needed it to use raycasting and in 1.17+ it's RenderLevelLastEvent; but it gives me the same error as you.
March 3, 20223 yr 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 March 3, 20223 yr 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.