Jump to content

REALLY weird out of memory crash


redstonedude

Recommended Posts

I'm working on a mod where we have custom rendering for tile entities, IDK why but when i first started i put all the tileentity models in one class and had a switch statement in the render method to decide which parts to render, i've recently tried to overhaul the mod a bit on the rendering side and so i went through the long painful process of seperating the model into different classes, i then made all the classes extend EndoEnergyModelBase which in turn extends ModelBase (this allows me to call .render (read the rest of this paragraph)), i moved the switch statement to the TileEntityRenderer class i had made and into it's RenderBlockWire method, the code is as follows for the renderer:

 

public class TileEntityWireRenderer extends TileEntitySpecialRenderer{

   

EndoEnergyModelBase model;

 

public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float f) {

        GL11.glPushMatrix();

        GL11.glTranslatef((float)d, (float)d1, (float)d2);

        TileEntityWire tileEntityWire = (TileEntityWire) tileEntity; //might not work

        renderBlockWire(tileEntityWire, tileEntity.worldObj, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, EndoEnergy.BlockLowWire);

        GL11.glPopMatrix();

    }

   

    public void renderBlockWire(TileEntityWire tl, World world, int i, int j, int k, Block block) {

    Tessellator tessellator = Tessellator.instance;

        float f = block.getBlockBrightness(world, i, j, k);

        int l = world.getLightBrightnessForSkyBlocks(i, j, k, 0);

        int l1 = l % 65536;

        int l2 = l / 65536;

        tessellator.setColorOpaque_F(f, f, f);

        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)l1, (float)l2);

 

        int dir = world.getBlockMetadata(i, j, k);

       

        GL11.glPushMatrix();

        GL11.glTranslatef(0.5F, 0, 0.5F);

        //This line actually rotates the renderer.

        GL11.glRotatef(dir * (-90F), 0F, 1F, 0F);

        GL11.glTranslatef(-0.5F, 0, -0.5F);

       

        switch (tl.type){

        case 1:

        model = new ModelEnergyWire();

        bindTexture(new ResourceLocation("endoenergy", "textures/tileEntities/TileEntityWire.png"));

            this.model.render(tl, (Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

        break;

        case 2:

        break;

        case 3:

        break;

        case 4:

        model = new ModelSolarPanel();

        bindTexture(new ResourceLocation("endoenergy", "textures/tileEntities/TileEntitySolarPanel.png"));

            this.model.render(tl, (Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

        break;

        case 5:

        model = new ModelBatteryRack();

        bindTexture(new ResourceLocation("endoenergy", "textures/tileEntities/TileEntityBatteryRack.png"));

            this.model.render(tl, (Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

            break;

        case 6:

        model = new ModelGrinder();

        bindTexture(new ResourceLocation("endoenergy", "textures/tileEntities/TileEntityGrinder.png"));

            this.model.render(tl, (Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

            break;

        case 7:

        //model = new ModelWaterWheel();

        //bindTexture(new ResourceLocation("endoenergy", "textures/tileEntities/TileEntityWaterWheel.png"));

            //this.model.render(tl, (Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

            //break;

       

        }

        //bindTexture(new ResourceLocation("endoenergy", "textures/tileEntities/TileEntityTechnical.png"));

        //this.model.render(tl, (Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

 

        GL11.glPopMatrix();

    }

}

 

 

However when i try to run my game after a while (about a minute) i get an out of memory crash

Link to comment
Share on other sites

public void renderBlockWire(TileEntityWire tl, World world, int i, int j, int k, Block block) {
model = new ModelEnergyWire();

 

That's why.  You're not bothering to save the model between frames.  You're making a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a new one, a ne--error: post too long.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Found it just after i posted but thanks anyway :) Fixed by created instances at the beginning of the class and then referencing them as model1, model2 etc

 

Bingo.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.