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. I have a big problem. I'made a tile entity block with special renderer, and if i place even one (sic!) block and do absolutely nothing, it start devouring more and more memory until the game crashes with "Out of memory" notification.

Is there any solution of this problem?

My code:

 

TESR

package net.row.src.client.renderer.tileentity;

import net.minecraft.block.Block;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.row.src.RoW;
import net.row.src.client.model.rail.ModelRailRight;
import net.row.src.client.model.rail.ModelRailX01;
import net.row.src.client.model.rail.ModelRailX05;
import net.row.src.client.model.rail.ModelRailX10;
import net.row.src.tileentity.TileEntityWideRail;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class TileEntityWideRailRenderer extends TileEntitySpecialRenderer {
    
protected ModelBase model;

    public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f){
        GL11.glPushMatrix();
        GL11.glTranslatef((float)d, (float)d1, (float)d2);
        TileEntityWideRail tile = (TileEntityWideRail)tileentity;
        if(tile != null){
        	renderBlockRail(tile, tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord, RoW.rails);
        }
        GL11.glPopMatrix();
    } 
    public void renderBlockRail(TileEntityWideRail tileEntity, 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);
        if(tileEntity != null){
        	switch (tileEntity.mId){
        		default: bindTextureByName("/mods/RoW/textures/rails/rails_1.png");
        		model = new ModelRailX01();	break;
        		case 1:  bindTextureByName("/mods/RoW/textures/rails/rails_5.png");
        		model = new ModelRailX05();	break;
        		case 2:  bindTextureByName("/mods/RoW/textures/rails/rails_10.png");
        		model = new ModelRailX10();break;
        		case 3:  bindTextureByName("/mods/RoW/textures/rails/rails_right.png");
        		model = new ModelRailRight();break;
        		case 4:  bindTextureByName("/mods/RoW/textures/rails/rails_left.png");
        		model = new ModelRailRight();break;
        	}
        	GL11.glPushMatrix();
        		GL11.glTranslatef(0.5F, 0F, 0.5F);
        		GL11.glRotatef(dir * (-90F), 0F, 1F, 0F);
        		GL11.glTranslatef(0.0F, 0F, -0.5F);
        		GL11.glScalef(-1.0F, -1.0F, 1.0F);
        		model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        	GL11.glPopMatrix();
        }
    }

}

One of my models

package net.row.src.client.model.rail;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

@SideOnly(Side.CLIENT)
public class ModelRailX01 extends ModelBase
{
    ModelRenderer Sleeper1;
    ModelRenderer Sleeper2;
    ModelRenderer Foot1;
    ModelRenderer Foot2;
    ModelRenderer Web1;
    ModelRenderer Web2;
    ModelRenderer Head1;
    ModelRenderer Head2;
  
  public ModelRailX01()
  {
    textureWidth = 128;
    textureHeight = 32;
    
      Sleeper1 = new ModelRenderer(this, 0, 0);
      Sleeper1.addBox(-20F, -1F, 2F, 40, 2, 4);
      Sleeper1.setRotationPoint(0F, -1F, 0F);
      Sleeper1.setTextureSize(128, 32);
      Sleeper1.mirror = true;
      setRotation(Sleeper1, 0F, 0F, 0F);
      Sleeper2 = new ModelRenderer(this, 0, 6);
      Sleeper2.addBox(-20F, -1F, 10F, 40, 2, 4);
      Sleeper2.setRotationPoint(0F, -1F, 0F);
      Sleeper2.setTextureSize(128, 32);
      Sleeper2.mirror = true;
      setRotation(Sleeper2, 0F, 0F, 0F);
      Foot1 = new ModelRenderer(this, 0, 12);
      Foot1.addBox(0F, 0F, -3F, 16, 1, 6);
      Foot1.setRotationPoint(-13F, -3F, 0F);
      Foot1.setTextureSize(128, 32);
      Foot1.mirror = true;
      setRotation(Foot1, 0F, -1.570796F, 0F);
      Foot2 = new ModelRenderer(this, 0, 19);
      Foot2.addBox(0F, 0F, -3F, 16, 1, 6);
      Foot2.setRotationPoint(13F, -3F, 0F);
      Foot2.setTextureSize(128, 32);
      Foot2.mirror = true;
      setRotation(Foot2, 0F, -1.570796F, 0F);
      Web1 = new ModelRenderer(this, 44, 18);
      Web1.addBox(0F, -1F, -0.5F, 16, 2, 1);
      Web1.setRotationPoint(-13F, -4F, 0F);
      Web1.setTextureSize(128, 32);
      Web1.mirror = true;
      setRotation(Web1, 0F, -1.570796F, 0F);
      Web2 = new ModelRenderer(this, 44, 21);
      Web2.addBox(0F, -1F, -0.5F, 16, 2, 1);
      Web2.setRotationPoint(13F, -4F, 0F);
      Web2.setTextureSize(128, 32);
      Web2.mirror = true;
      setRotation(Web2, 0F, -1.570796F, 0F);
      Head1 = new ModelRenderer(this, 44, 12);
      Head1.addBox(0F, 0F, -1F, 16, 1, 2);
      Head1.setRotationPoint(-13F, -6F, 0F);
      Head1.setTextureSize(128, 32);
      Head1.mirror = true;
      setRotation(Head1, 0F, -1.570796F, 0F);
      Head2 = new ModelRenderer(this, 44, 15);
      Head2.addBox(0F, 0F, -1F, 16, 1, 2);
      Head2.setRotationPoint(13F, -6F, 0F);
      Head2.setTextureSize(128, 32);
      Head2.mirror = true;
      setRotation(Head2, 0F, -1.570796F, 0F);
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    Sleeper1.render(f5);
    Sleeper2.render(f5);
    Foot1.render(f5);
    Foot2.render(f5);
    Web1.render(f5);
    Web2.render(f5);
    Head1.render(f5);
    Head2.render(f5);
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
  }

}

 

Help please?

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

You're creating a new model every frame and never releasing them.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • Author

Thanks!

 

AaGwHCL.gif

 

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

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.