Jump to content

Have i properly applied the RenderManager?


ItsAMysteriousYT

Recommended Posts

I registered a custom Renderer, but it does not work properly which means, it tries to get a rendermanager, but there isn't one but i have on in the constructor. See here:

 

 

 

package itsamysterious.mods.reallifemod.core.rendering.Entities;

 

import java.util.HashMap;

import java.util.Map;

 

import org.lwjgl.opengl.GL11;

 

import itsamysterious.mods.reallifemod.client.forgeobjmodelported.AdvancedModelLoader;

import itsamysterious.mods.reallifemod.client.forgeobjmodelported.IModelCustom;

import itsamysterious.mods.reallifemod.core.vehicles.EntityVehicle;

import itsamysterious.mods.reallifemod.core.vehicles.VehicleFile;

import net.minecraft.client.Minecraft;

import net.minecraft.client.renderer.entity.Render;

import net.minecraft.client.renderer.entity.RenderItem;

import net.minecraft.client.renderer.entity.RenderManager;

import net.minecraft.entity.Entity;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.util.ResourceLocation;

 

public class RenderVehicle extends Render{

private Class<?extends EntityVehicle> entityClass;

private static Map <String,IModelCustom> models = new HashMap<String, IModelCustom>();

private static Map <String,ResourceLocation> textures = new HashMap<String, ResourceLocation>();

VehicleFile f = null;

 

public RenderVehicle() {

super(Minecraft.getMinecraft().getRenderManager());

shadowSize=1;

}

 

public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float partialTicks) {

if(entity.getClass().isInstance(EntityVehicle.class)){

renderVehicle((EntityVehicle)entity, x, y, z, p_76986_8_, partialTicks);

}

};

 

private void renderVehicle(EntityVehicle entity, double x, double y, double z, float p_76986_8_,

float partialTicks) {

if(f==null){

f=entity.file;

return;

}

if(f==null) entity.setDead();

//Minecraft.getMinecraft().renderEngine.bindTexture(getEntityTexture(entity));

GL11.glPushMatrix();

GL11.glTranslated(x, y, z);

GL11.glRotated(entity.rotationYaw, 0, 1, 0);

GL11.glRotated(entity.rotationPitch, 1, 0, 0);

GL11.glPushMatrix();

getmodel(f).renderPart(f.modelName);

GL11.glPopMatrix();

//Rearaxis

GL11.glPushMatrix();

GL11.glRotated(entity.backWheelRotation, 1, 0, 0);

GL11.glTranslated(f.wheelPosBack.x+f.wheelPosLeft.x, f.wheelPosBack.y, f.wheelPosBack.z);

getmodel(f).renderPart(f.wheelsName);

GL11.glPopMatrix();

 

//Frontwheel L

GL11.glPushMatrix();

GL11.glRotated(entity.wheelRotL, 1, 0, 0);

GL11.glTranslated(f.wheelPosLeft.x, f.wheelPosLeft.y, f.wheelPosLeft.z);

getmodel(f).renderPart(f.wheelsName);

GL11.glPopMatrix();

 

//Frontwheel R

GL11.glPushMatrix();

GL11.glRotated(entity.wheelRotL, 1, 0, 0);

GL11.glTranslated(f.wheelPosLeft.x, f.wheelPosLeft.y, f.wheelPosLeft.z);

getmodel(f).renderPart(f.wheelsName);

GL11.glPopMatrix();

 

//

GL11.glPopMatrix();

}

 

private IModelCustom getmodel(VehicleFile f) {

return models.get(f.vehicleName);

}

 

@Override

protected ResourceLocation getEntityTexture(Entity entity) {

if(entity instanceof EntityVehicle){

VehicleFile f = ((EntityVehicle)entity).file;

if(f==null){

return null;

}

return textures.get(f.vehicleName);

}else

return null;

}

 

public static void registerModel(VehicleFile f){

models.put(f.vehicleName, AdvancedModelLoader.loadModel(new ResourceLocation("reallifemod:models/vehicle/"+f.fileName+".obj")));

textures.put(f.vehicleName, new ResourceLocation("reallifemod:textures/vehicle/"+f.textureName+".png"));

}

 

@Override

    public void doRenderShadowAndFire(Entity p_76979_1_, double p_76979_2_, double p_76979_4_, double p_76979_6_, float p_76979_8_, float p_76979_9_)

    {

if(this.renderManager!=null){

        if (this.renderManager.options != null)

        {

            if (this.renderManager.options.fancyGraphics && this.shadowSize > 0.0F && !p_76979_1_.isInvisible() && this.renderManager.isRenderShadow())

            {

                double d3 = this.renderManager.getDistanceToCamera(p_76979_1_.posX, p_76979_1_.posY, p_76979_1_.posZ);

                float f2 = (float)((1.0D - d3 / 256.0D) * (double)this.shadowOpaque);

 

                if (f2 > 0.0F)

                {

                }

            }

 

            if (p_76979_1_.canRenderOnFire() && (!(p_76979_1_ instanceof EntityPlayer) || !((EntityPlayer)p_76979_1_).isSpectator()))

            {

            }

        }

}else

{

System.out.println("No rendermanager");

}

    }

 

}

 

 

 

Link to comment
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.
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.