Jump to content

Recommended Posts

Posted (edited)

I'm trying to draw a line that will go from the left block to the right. I have the code:

@SubscribeEvent
    public void onRender3D(RenderWorldLastEvent event) {
        GL11.glColor4f(1, 1, 1, 1);
        GLUtils.start2Draw(() -> {
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder bufferBuilder = tessellator.getBuilder();
            bufferBuilder.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION);
            bufferBuilder.vertex(event.getProjectionMatrix(), 10, 76, 475).endVertex();
            bufferBuilder.vertex(event.getProjectionMatrix(), 10, 76, 466).endVertex();
            tessellator.end();
        });
    }

Event is called, only the render does not work. Of course I can do as in

this thread, but I think it's a crutch.

If I add - gameRenderer.getMainCamera().getPosition() it will have an invalid effect:

image.png

Edited by ByterDance
Posted (edited)

You have completely the wrong approach to this.

 

You are also using an unsupported version https://forums.minecraftforge.net/topic/91712-supported-version-directory/

The details below apply to supported versions.

 

When you draw things in Minecraft (that are not part of the GUI) you draw them in world co-ordinates.

And you draw them using the RenderSystem by adding vertices to buffers based on the RenderType (effectively what graphics card state and shader you want to use).

You do not directly draw to the graphics card or use opengl apis. e.g. what if the user is taking a screenshot instead of renderering to the screen? Or some other mod doing some funky offscreen rendering?

By adding vertices to a buffer you allow minecraft to draw all the vertices for a rendertype in paralllel with just one graphics state switch instead of continously swapping the state and only drawing one thing at once.

Graphics cards are designed to be massively parallel, old school direct draw opengl defeats this.

The shaders automatically take into account projections, scaling, etc., e.g. the lines shader

https://github.com/misode/mcmeta/blob/14150eed9118b6b142d9b7841760ecf5a4de1bc7/assets/minecraft/shaders/core/rendertype_lines.vsh#L27

 

Normally you would be rendering a block or entity. In which case Minecraft automatically adjusts the "PoseStack" so you can draw as though your object is at 0,0,0

The PoseStack is a stack of matrix transformations (translate, rotate, scale, etc.) that allow you "push" to change how the co-ordinates are interpreted (like that pretend you are at 0,0,0 above)

and "pop" to  quickly restore the previous state so you don't have to remember what you changed.

 

If you want to draw something else then you need to know where the PoseStack is "located". This depends upon where in the rendering process you are drawing.

For example, when drawing block or entity outines, the PoseStack is actually weirdly located at the camera. So you need to translate to the block co-ordinates to make things easy.

e.g. Mekanism doing this https://github.com/mekanism/Mekanism/blob/418bd9be20ea3f688ab5b5438d075ce52785e24c/src/main/java/mekanism/client/render/RenderTickHandler.java#L423

NOTE how after it is translated it adds vertices to the RenderType.lines buffer to draw the block outlines.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
3 hours ago, warjort said:

And what am I doing wrong? I do all the same things

 

3 hours ago, warjort said:

And you draw them using the RenderSystem by adding vertices to buffers based on the RenderType (effectively what graphics card state and shader you want to use).

What??? If you are about com.mojang.blaze3d.systems.RenderSystem, then this is a utility + alternative to GlStateManager, you can't draw through it

3 hours ago, warjort said:

The shaders automatically take into account projections, scaling, etc., e.g. the lines shader

https://github.com/misode/mcmeta/blob/14150eed9118b6b142d9b7841760ecf5a4de1bc7/assets/minecraft/shaders/core/rendertype_lines.vsh#L27

But if you draw on the "monitor screen" (RenderGameOverlayEvent), then almost everything you said will not work

Posted (edited)

RenderGameOverlayEvent is for the ingame GUI not world rendering. e.g. the inventory, health bar, etc.

 

RenderSystem is not an alternative to GLStateManager.

RenderSystem uses GLStateManager as part of its implementation adding things on top you need to conform to inorder to get correct behaviour.

In particular using the buffers to render the level/world.

If you go poking around in implementation details in unprincipled ways (e.g. not telling Minecraft's abstraction what you are doing), don't be suprised when things don't work correctly.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
6 minutes ago, warjort said:

RenderGameOverlayEvent is for the ingame GUI not world rendering. e.g. the inventory, health bar, etc.

Yes, in this

thread he's projects 3d coordinate from world to 2d screen coordinates, but I want to render it in RenderWorldLastEvent without projecting

8 minutes ago, warjort said:

RenderSystem is not an alternative to GLStateManager.

RenderSystem uses GLStateManager as part of its implementation adding things on top you need to conform to inorder to get correct behaviour.

But you can't draw through it anyway. Rendering takes place through Tessellator and BufferBuilder or directly through OpenGL, but not through RenderSystem

Posted

I have no wish to continue this pointless argument.

I am using "RenderSystem" as a generic term for Minecraft's rendering system, not specifically the class of that name.

 

This forum is a minecraft/forge modding forum. To get support you need to be using minecraft/forge apis and supported versions at that.

If you want to use opengl apis, try a forum that provides support for those.

But you will also need to find somebody who understands how Minecraft's RenderSystem works to explain to you what extra contortions you need to make so your code plays nicely with everybody else's.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
35 minutes ago, warjort said:

I am using "RenderSystem" as a generic term for Minecraft's rendering system, not specifically the class of that name.

 

1 hour ago, ByterDance said:

If you are about com.mojang.blaze3d.systems.RenderSystem, then this is a utility + alternative to GlStateManager, you can't draw through it

facepalm

35 minutes ago, warjort said:

But you will also need to find somebody who understands how Minecraft's RenderSystem works to explain to you what extra contortions you need to make so your code plays nicely with everybody else's.

So I wrote here

Posted

I already explained what you need to do in my first post.

If you want help with that, try to implement it and if you can't get it to work, post a build on github that reproduces your problem (and is for a supported version of minecraft).

 

If you don't want to follow my advice, that is fine.

But don't continue your pointless argument repeating assertions I have already tried to explain are wrong, you will be talking to yourself.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted (edited)
16 minutes ago, warjort said:

I already explained what you need to do in my first post.

If you want help with that, try to implement it and if you can't get it to work, post a build on github that reproduces your problem (and is for a supported version of minecraft).

 

If you don't want to follow my advice, that is fine.

But don't continue your pointless argument repeating assertions I have already tried to explain are wrong, you will be talking to yourself.

one more point, can you please understand it correctly, everything works perfectly in MCP 1.16.5 (ModCoderPack), but for some reason everything works differently on forge.

P.S. Please understand and forgive me, I asked a friend for Tracers from his cheat on minecraft (these are lines from the bottom of the screen to the player), but everything works completely differently on Forge

Tracers code if you need:

Vector3d centerScreen = mc.player.getLookVec();


        for (PlayerEntity entity : mc.world.getPlayers()) {


            double x = entity.getPosX() - mc.getRenderManager().info.getProjectedView().x;
            double y = entity.getPosY() - mc.getRenderManager().info.getProjectedView().y;
            double z = entity.getPosZ() - mc.getRenderManager().info.getProjectedView().z;
            bufferBuilder.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR);

            bufferBuilder.pos(centerScreen.getX(), centerScreen.getY(), centerScreen.getZ()).color(red, green, blue, alpha).endVertex();
            bufferBuilder.pos(x, y, z).color(red, green, blue, alpha).endVertex();
            Tessellator.getInstance().draw();
        }

This code works well on MCP, but works wrong on Forge

Edited by ByterDance
Posted
19 minutes ago, ByterDance said:

Don't ignore me if you see the word "cheat", it's crazy

Neither Minecraft 1.16, MCP or cheats are supported in this forum.

I am only a volunteer, not a moderator.

I am sure someone will eventually close this thread if you contine ignore the forum rules.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
6 hours ago, warjort said:

Neither Minecraft 1.16, MCP or cheats are supported in this forum.

I am only a volunteer, not a moderator.

I am sure someone will eventually close this thread if you contine ignore the forum rules.

Do you have an iq hopefully greater than 0? You are a volunteer, which means you have no reason not to help me because I gave the "cheat" as an example. If you simply can't answer what I said (what works on MCP, but not on forge), then I don't see the point in shitting something on the forum. If you are a stupid macaque who writes supposedly "important things" on the forum, but cannot give what the author needs, then you are doing something wrong. My friend always understands me and tries to help, but you are busy filling in the subject of unnecessary messages.

By topic: either forge is broken, or I don't understand why the same RenderWorldLastEvent call code in the same place works differently.

By you: couldn't give me what I need and couldn't answer the question why everything works on MCP, but not on forge. Thank you for your shit in my topic, I hope you get banned fuck

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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