Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.1] [SOLVED] Help to Draw line
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
JdiJack

[1.12.1] [SOLVED] Help to Draw line

By JdiJack, September 15, 2017 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

JdiJack    2

JdiJack

JdiJack    2

  • Tree Puncher
  • JdiJack
  • Members
  • 2
  • 30 posts
Posted September 15, 2017 (edited)

Hi, I'm a new form of forge, I'm having trouble drawing a vertical line in the world, in the ItemSpada1.java class I have 2 methods to draw a line from the click block. The line is never drawn, what am I doing wrong?

Source code:

 

https://github.com/JdiJack/TutorialMod/blob/master/src/main/java/it/petitogennaro/tutorial_mod/items/ItemSpada1.java

 

the final effect must be similar to this:

 

635889646297079402.png

 

[SOLUTION]

at the bottom of the topic

Edited September 28, 2017 by JdiJack
  • Quote

Share this post


Link to post
Share on other sites

Busti    72

Busti

Busti    72

  • Dragon Slayer
  • Busti
  • Forge Modder
  • 72
  • 588 posts
Posted September 15, 2017

You can't just go ahead and try to draw stuff in a method like that.

You have to do that when the game is being rendered.

Games like Minecraft commonly have a separate render and game loop.

One is for executing game logic the other one is for drawing graphics.
 

I could now go ahead and list all the different ways there are in minecraftforge to render specific kinds of graphical elements from Blocks over Entities to GUIs and using specific events.
But it would be better to know what you are trying to accomplish in the long run.

  • Like 1
  • Quote

Share this post


Link to post
Share on other sites

JdiJack    2

JdiJack

JdiJack    2

  • Tree Puncher
  • JdiJack
  • Members
  • 2
  • 30 posts
Posted September 15, 2017
1 hour ago, Busti said:

You can't just go ahead and try to draw stuff in a method like that.

You have to do that when the game is being rendered.

Games like Minecraft commonly have a separate render and game loop.

One is for executing game logic the other one is for drawing graphics.
 

I could now go ahead and list all the different ways there are in minecraftforge to render specific kinds of graphical elements from Blocks over Entities to GUIs and using specific events.
But it would be better to know what you are trying to accomplish in the long run.

I thank you for the clarification. I want to draw more contour lines of a block going to the sky. Now, however, I have no idea where to place my drawlines ();

  • Quote

Share this post


Link to post
Share on other sites

JdiJack    2

JdiJack

JdiJack    2

  • Tree Puncher
  • JdiJack
  • Members
  • 2
  • 30 posts
Posted September 15, 2017

Thanks to your advice I changed the structure of my project now in the "ItemSpada1.java" class, I only care to store the coordinates. I thought I would use "RenderGameOverlayEvent.Post" but I still do not see any line. What am I doing wrong?

 

Source code:

https://github.com/JdiJack/TutorialMod/blob/master/src/main/java/it/petitogennaro/tutorial_mod/MyEventHandler.java

  • Quote

Share this post


Link to post
Share on other sites

Busti    72

Busti

Busti    72

  • Dragon Slayer
  • Busti
  • Forge Modder
  • 72
  • 588 posts
Posted September 15, 2017

You can't just draw things to coordinates and expect them to work.
As the name implies RenderGameOverlayEvent is for drawing overlays, e.g. a minimap and whatnot.

When drawing the player becomes the origin of the rendering coordinate system.
 

You probably want to have a look at TileEntitySpecialRenderers to get a better concept of how minecrafts rendering works.
 

Is the effect you want to achieve similar to a beacon beam?

  • Like 1
  • Quote

Share this post


Link to post
Share on other sites

JdiJack    2

JdiJack

JdiJack    2

  • Tree Puncher
  • JdiJack
  • Members
  • 2
  • 30 posts
Posted September 15, 2017 (edited)
16 minutes ago, Busti said:

You can't just draw things to coordinates and expect them to work.
As the name implies RenderGameOverlayEvent is for drawing overlays, e.g. a minimap and whatnot.

When drawing the player becomes the origin of the rendering coordinate system.
 

You probably want to have a look at TileEntitySpecialRenderers to get a better concept of how minecrafts rendering works.
 

Is the effect you want to achieve similar to a beacon beam?

the final effect must be similar to this:

 

635889646297079402.png

Edited September 15, 2017 by JdiJack
  • Like 1
  • Quote

Share this post


Link to post
Share on other sites

Busti    72

Busti

Busti    72

  • Dragon Slayer
  • Busti
  • Forge Modder
  • 72
  • 588 posts
Posted September 15, 2017

You probably want to hook into EntityViewRenderEvent.

  • Like 1
  • Quote

Share this post


Link to post
Share on other sites

JdiJack    2

JdiJack

JdiJack    2

  • Tree Puncher
  • JdiJack
  • Members
  • 2
  • 30 posts
Posted September 15, 2017
44 minutes ago, Busti said:

You probably want to hook into EntityViewRenderEvent.

I'm desolate but I can not go ahead, please give me the working code, I'm trying to draw in the "RenderWorldLastEvent" event and the lines are never drawn. I have created a new "drawLine5 ()" method in the "DrawHandler" class and it does not work.

 

 

  • Quote

Share this post


Link to post
Share on other sites

Busti    72

Busti

Busti    72

  • Dragon Slayer
  • Busti
  • Forge Modder
  • 72
  • 588 posts
Posted September 15, 2017

Have a look at how botania uses the event to render a ghost preview of a block:

https://github.com/Vazkii/Botania/blob/master/src/main/java/vazkii/botania/client/core/handler/AstrolabePreviewHandler.java


You'll also have to create a Proxy class to register your event:

https://github.com/Vazkii/Botania/blob/master/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java

 

Read more on events here:
https://mcforge.readthedocs.io/en/latest/events/intro/

 

Looking through other open source mods is generally a good way to get an understanding of how to approach certain things.

  • Like 1
  • Quote

Share this post


Link to post
Share on other sites

JdiJack    2

JdiJack

JdiJack    2

  • Tree Puncher
  • JdiJack
  • Members
  • 2
  • 30 posts
Posted September 16, 2017
11 hours ago, Busti said:

Date un'occhiata a come botania utilizza l'evento per rendere un'anteprima fantasma di un blocco:

https://github.com/Vazkii/Botania/blob/master/src/main/java/vazkii/botania/client/core/handler/AstrolabePreviewHandler.java


Devi anche creare una classe Proxy per registrare l'evento:

https://github.com/Vazkii/Botania/blob/master/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java

 

Per saperne di più sugli eventi qui:
https://mcforge.readthedocs.io/en/latest/events/intro/

 

Guardare attraverso altri mod open source è generalmente un buon modo per comprendere come affrontare determinate cose.

busti thank you for the time you are devoting to my project, I accept your suggestions, as indicated by you I went to study the mod botania, but can you tell me why my code does not work? I want to draw a simple line and I can not, what's wrong? I am going crazy

  • Quote

Share this post


Link to post
Share on other sites

JdiJack    2

JdiJack

JdiJack    2

  • Tree Puncher
  • JdiJack
  • Members
  • 2
  • 30 posts
Posted September 16, 2017

I followed this example perfectly well, the line is not drawn.

 

My project: https://github.com/JdiJack/TutorialMod/tree/master/src/main/java/it/petitogennaro/tutorial_mod

  • Quote

Share this post


Link to post
Share on other sites

JdiJack    2

JdiJack

JdiJack    2

  • Tree Puncher
  • JdiJack
  • Members
  • 2
  • 30 posts
Posted September 16, 2017

up

  • Quote

Share this post


Link to post
Share on other sites

Busti    72

Busti

Busti    72

  • Dragon Slayer
  • Busti
  • Forge Modder
  • 72
  • 588 posts
Posted September 16, 2017

My best guess would be that either your event handler is not called, in order to test that you should try to print something to your console in your eventhandler,

or that your line is being drawn somewhere else.

When I first rendered a custom block it was drawn at the coordinates 0, 0, 0 in the world.

  • Like 1
  • Quote

Share this post


Link to post
Share on other sites

JdiJack    2

JdiJack

JdiJack    2

  • Tree Puncher
  • JdiJack
  • Members
  • 2
  • 30 posts
Posted September 28, 2017
On 17/9/2017 at 1:31 AM, Busti said:

 

 

Finally a few days ago, I managed to draw my first line, my thanks go to "Butsi" who had the patience to put me on the right path.

Updated topic start, code Solution:

public static void drawBoundingBox(Vec3d player_pos, Vec3d posA, Vec3d posB, boolean smooth, float width) {

		GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
		GL11.glDisable(GL11.GL_CULL_FACE);
		GL11.glDisable(GL11.GL_LIGHTING);
		GL11.glDisable(GL11.GL_TEXTURE_2D);

		GL11.glEnable(GL11.GL_BLEND);
		GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
		GL11.glTranslated(-player_pos.x, -player_pos.y, -player_pos.z);

		Color c = new Color(255, 0, 0, 150);
		GL11.glColor4d(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
		GL11.glLineWidth(width);
		GL11.glDepthMask(false);
		Tessellator tessellator = Tessellator.getInstance();
		BufferBuilder bufferBuilder = tessellator.getBuffer();
		bufferBuilder.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);

		double dx = Math.abs(posA.x - posB.x);
		double dy = Math.abs(posA.y - posB.y);
		double dz = Math.abs(posA.z - posB.z);

		//AB
		bufferBuilder.pos(posA.x, posA.y, posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();          //A
		bufferBuilder.pos(posA.x, posA.y, posA.z+dz).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();       //B
		//BC
		bufferBuilder.pos(posA.x, posA.y, posA.z+dz).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();       //B
		bufferBuilder.pos(posA.x+dx, posA.y, posA.z+dz).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();    //C
		//CD
		bufferBuilder.pos(posA.x+dx, posA.y, posA.z+dz).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();    //C
		bufferBuilder.pos(posA.x+dx, posA.y, posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();       //D
		//DA
		bufferBuilder.pos(posA.x+dx, posA.y, posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();       //D
		bufferBuilder.pos(posA.x, posA.y, posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();          //A
		//EF
		bufferBuilder.pos(posA.x, posA.y+dy, posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();       //E
		bufferBuilder.pos(posA.x, posA.y+dy, posA.z+dz).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();    //F
		//FG
		bufferBuilder.pos(posA.x, posA.y+dy, posA.z+dz).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();    //F
		bufferBuilder.pos(posA.x+dx, posA.y+dy, posA.z+dz).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex(); //G
		//GH
		bufferBuilder.pos(posA.x+dx, posA.y+dy, posA.z+dz).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex(); //G
		bufferBuilder.pos(posA.x+dx, posA.y+dy, posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();    //H
		//HE
		bufferBuilder.pos(posA.x+dx, posA.y+dy, posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();    //H
		bufferBuilder.pos(posA.x, posA.y+dy, posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();       //E
		//AE
		bufferBuilder.pos(posA.x, posA.y, posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();          //A
		bufferBuilder.pos(posA.x, posA.y+dy, posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();       //E
		//BF
		bufferBuilder.pos(posA.x, posA.y, posA.z+dz).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();       //B
		bufferBuilder.pos(posA.x, posA.y+dy, posA.z+dz).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();    //F
		//CG
		bufferBuilder.pos(posA.x+dx, posA.y, posA.z+dz).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();    //C
		bufferBuilder.pos(posA.x+dx, posA.y+dy, posA.z+dz).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex(); //G
		//DH
		bufferBuilder.pos(posA.x+dx, posA.y, posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();       //D
		bufferBuilder.pos(posA.x+dx, posA.y+dy, posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();    //H

		tessellator.draw();      


		GL11.glDepthMask(true);
		GL11.glPopAttrib();
	}

 

 

702ad857-90b2-47fe-8b51-30c703be4edb.jpg

  • Like 1
  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • DaemonUmbra
      Optifine 1.14.4 U HD F4 crash froge

      By DaemonUmbra · Posted 2 minutes ago

      Please don't hijack other peoples threads. If you have an issue please make your own thread.
    • DaemonUmbra
      Forge 1.14.4 crashes.

      By DaemonUmbra · Posted 3 minutes ago

      Upload debug.log to one of the paste sites listed in my signature
    • Rick57
      Clean forge installer

      By Rick57 · Posted 6 minutes ago

      Does anyone have a clean version of the Forge for Minecraft? I tried downloading the one from the website for the 1.15 version and it's infected with a malware(win32:adwarex-gen (awd) infected file $rgysfif.exe).
    • JMAS
      pointing to MCP folder instead of MDK ???

      By JMAS · Posted 13 minutes ago

      Thank you for the input, DaemonUmbra, and DavidM.    To DaemonUmbra:  As I had shared with Diesieben07 in a different ticket, I have devoured (McJty's) Jorrit Tyberghein's "Modding Tutorial 1.14: Episode 1 (IDEA setup, basic mod and first block) after you re-routed me away from 1.7.10.  Prior to that I did the first 7 Mr. Crayfish tuts on mod building with a grain of salt as that series is for 1.7.10 but still has good fundamentals, I hope.   To DavidM:  Sounds good to me, but I am little hesitant only because of uncertainty with the complexity of fixing "all the mapping changes and other changes with your IDE. "   If you had a video/tutorial to recommend it would be appreciated.   Thanks to you both for your feedback and input. JMAS 
    • geekles
      [Forge 1.14.4] Loading saved world

      By geekles · Posted 14 minutes ago

      I'm calling the Minecraft#launchIntegratedServer() function since the CreateWorldScreen class does the same when creating a world. I'm merely trying to replicate the actions used to create/load a new or existing world.    CreateWorldScreen#createWorld()   
  • Topics

    • DarkZapato
      3
      Optifine 1.14.4 U HD F4 crash froge

      By DarkZapato
      Started Thursday at 08:09 PM

    • Darth_Cobalt
      1
      Forge 1.14.4 crashes.

      By Darth_Cobalt
      Started 9 hours ago

    • Rick57
      0
      Clean forge installer

      By Rick57
      Started 6 minutes ago

    • JMAS
      9
      pointing to MCP folder instead of MDK ???

      By JMAS
      Started Yesterday at 01:21 AM

    • geekles
      2
      [Forge 1.14.4] Loading saved world

      By geekles
      Started Yesterday at 06:37 AM

  • Who's Online (See full list)

    • geekles
    • Rick57
    • DaemonUmbra
    • PrinceRaiden
    • Oliviafrostpaw
    • AnonymousVoidF
    • bluey418
    • Edivad99
    • J0WAY
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.1] [SOLVED] Help to Draw line
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community