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

Hello all,

 

I've been having trouble rendering an entity in forge, and I'm not quite sure what the problem is.

I have it rendering 2 faces of a cube, but whenever i look at a certain angle the cube disappears. It seems that it is only visible from the orientation 102(west) through -152(north)

2l111l.pngartlk.jpg

 

here is the code inside of my "Render" file

 


package over.extrashapes;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;


import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;

public class ShapeRender extends Render {

ResourceLocation texture = null;
public ShapeRender ()
{

}
@Override
public void doRender(Entity entity, double par2, double par4, double par6,float f, float f1) {
	 GL11.glDisable(GL11.GL_TEXTURE_2D);
	 GL11.glDisable(GL11.GL_LIGHTING);
	 //GL11.glEnable(GL11.GL_BLEND);
	// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
	 //GL11.glEnable(GL12.GL_RESCALE_NORMAL);

	GL11.glPushMatrix();
	   GL11.glTranslatef((float)par2, (float)par4, (float)par6);


           Tessellator tessellator = Tessellator.instance;
           tessellator.startDrawing(GL11.GL_QUADS);
           tessellator.setColorRGBA(0, 0, 0, 128);
	   tessellator.setNormal(0, 0, 0);
           
	   //front
           tessellator.addVertex(0, 0, 0);
           tessellator.addVertex(0, 1, 0);
           tessellator.addVertex(1, 1, 0);
           tessellator.addVertex(1, 0, 0);
           
           
           //back
           tessellator.addVertex(1, 0, 1);
           tessellator.addVertex(1, 1, 1);
           tessellator.addVertex(0, 1, 1);
           tessellator.addVertex(0, 0, 1);
         

         
           tessellator.draw();
           
	   GL11.glPopMatrix();
	   
	  // GL11.glDisable(GL11.GL_BLEND);
	   GL11.glEnable(GL11.GL_LIGHTING);
	   GL11.glEnable(GL11.GL_TEXTURE_2D);

}

@Override
protected ResourceLocation getEntityTexture(Entity entity) {
	// TODO Auto-generated method stub
	return null;
}

}

 

any suggestions or solutions would be awesome, this has been haunting me for a couple days

 

Thanks

Hi

 

So I gather your entity is that big black shape on the left?

 

When the entity disappears, do you know for certain that the renderer has drawn it?  I.e. perhaps it is being culled by the frustrum code and it never gets to the renderer?  (I suggest adding some println to check)

 

I can't see anything wrong with the render code but then I'm no expert.  I've previously had rather strange bugs where my render varied depending on what else had previously been rendered in the same scene, because I wasn't setting all the necessary settings. 

 

Fresh out of other ideas, sorry...

 

-TGG

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.