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

i'm trying to make a custom rendered block but when i place the block it shows up invisible and i have no idea whats wrong with the code so please help

 

the block class

 
package com.electric.craft.block;

import com.electric.craft.MainMod;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class BlockBatteryPack extends BlockContainer {

public BlockBatteryPack(Material material) {
	super(material);
}
public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) {
        return false;
}
public boolean isOpaqueCube() {
        return false;
}
        public int getRenderType() {
                return -1;
        }
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
	return new EntityBatteryPack();
}
}

 

the tile entity class

package com.electric.craft.block;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.Packet;
import net.minecraft.tileentity.TileEntity;

public class EntityBatteryPack extends TileEntity {

public EntityBatteryPack() {

}
}

 

the render class

package com.electric.craft.block;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;

import com.electric.craft.MainMod;

public class RenderBatteryPack extends TileEntitySpecialRenderer {

    private ModelBatteryPack model;
    public static final ResourceLocation texture = new ResourceLocation(MainMod.modId, "textures/models/batteryPack.png");
    
    public RenderBatteryPack() {
            this.model = new ModelBatteryPack();
    }
    public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float scale) {
    	GL11.glPushMatrix();
    	GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
    	GL11.glRotatef(180, 0, 0, 1);
    	this.bindTexture(texture);
    	this.model.renderModel(0.0625F);
    	GL11.glPopMatrix();
    }
}

 

the model class

package com.electric.craft.block;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelBatteryPack extends ModelBase {

ModelRenderer base;
    ModelRenderer side1;
    ModelRenderer side2;
    ModelRenderer side3;
    ModelRenderer side4;
    ModelRenderer contact1;
    ModelRenderer contact2;
    ModelRenderer contact3;
    ModelRenderer contact4;
  
    public ModelBatteryPack() {
    	textureWidth = 64;
    	textureHeight = 32;
    
    	base = new ModelRenderer(this, 0, 0);
    	base.addBox(0F, 0F, 0F, 6, 1, 14);
      	base.setRotationPoint(-3F, 23F, -7F);
      	base.setTextureSize(64, 32);
      	base.mirror = true;
      	setRotation(base, 0F, 0F, 0F);
      	side1 = new ModelRenderer(this, 4, 15);
      	side1.addBox(0F, 0F, 0F, 6, 3, 1);
      	side1.setRotationPoint(-3F, 20F, -7F);
      	side1.setTextureSize(64, 32);
      	side1.mirror = true;
      	setRotation(side1, 0F, 0F, 0F);
      	side2 = new ModelRenderer(this, 4, 15);
      	side2.addBox(0F, 0F, 0F, 6, 3, 1);
      	side2.setRotationPoint(-3F, 20F, 6F);
      	side2.setTextureSize(64, 32);
      	side2.mirror = true;
      	setRotation(side2, 0F, 0F, 0F);
      	side3 = new ModelRenderer(this, 0, 0);
      	side3.addBox(0F, 0F, 0F, 1, 3, 12);
      	side3.setRotationPoint(-3F, 20F, -6F);
      	side3.setTextureSize(64, 32);
      	side3.mirror = true;
      	setRotation(side3, 0F, 0F, 0F);
      	side4 = new ModelRenderer(this, 0, 0);
      	side4.addBox(0F, 0F, 0F, 1, 3, 12);
      	side4.setRotationPoint(2F, 20F, -6F);
      	side4.setTextureSize(64, 32);
      	side4.mirror = true;
      	setRotation(side4, 0F, 0F, 0F);
      	contact1.mirror = true;
      	contact1 = new ModelRenderer(this, 0, 15);
      	contact1.addBox(0F, 0F, 0F, 1, 2, 1);
      	contact1.setRotationPoint(0.48F, 22F, 6.5F);
      	contact1.setTextureSize(64, 32);
      	contact1.mirror = true;
      	setRotation(contact1, 0F, 0F, 0F);
      	contact1.mirror = false;
      	contact2.mirror = true;
      	contact2 = new ModelRenderer(this, 0, 15);
      	contact2.addBox(0F, 0F, 0F, 1, 2, 1);
      	contact2.setRotationPoint(-1.5F, 22F, 6.5F);
      	contact2.setTextureSize(64, 32);
      	contact2.mirror = true;
      	setRotation(contact2, 0F, 0F, 0F);
      	contact2.mirror = false;
      	contact3.mirror = true;
      	contact3 = new ModelRenderer(this, 0, 15);
      	contact3.addBox(0F, 0F, 0F, 1, 2, 1);
      	contact3.setRotationPoint(0.5F, 22F, -7.5F);
      	contact3.setTextureSize(64, 32);
      	contact3.mirror = true;
      	setRotation(contact3, 0F, 0F, 0F);
      	contact3.mirror = false;
      	contact4.mirror = true;
      	contact4 = new ModelRenderer(this, 0, 15);
      	contact4.addBox(0F, 0F, 0F, 1, 2, 1);
      	contact4.setRotationPoint(-1.5F, 22F, -7.5F);
      	contact4.setTextureSize(64, 32);
      	contact4.mirror = true;
      	setRotation(contact4, 0F, 0F, 0F);
      	contact4.mirror = false;
    }
    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);
   		base.render(f5);
    	side1.render(f5);
    	side2.render(f5);
    	side3.render(f5);
    	side4.render(f5);
    	contact1.render(f5);
    	contact2.render(f5);
    	contact3.render(f5);
    	contact4.render(f5);
  	}
  	public void renderModel(float f) {
  		
  	}
  	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);
  	}
}

have you registered it in your proxy?

 

        ClientRegistry.bindTileEntitySpecialRenderer(TileEntityYOURTILEENTITY.class, new TileEntityYOURTILEENTITYRender());

Hi

 

  -1 means "don't render anything"

 

RenderBlocks::

  /**

    * Renders the block at the given coordinates using the block's rendering type

    */

    public boolean renderBlockByRenderType(Block par1Block, int par2, int par3, int par4)

    {

        int l = par1Block.getRenderType();

 

        if (l == -1)

        {

            return false;

        }

 

That's fine because you want your TileEntitySpecialRenderer to do the rendering, not the block.

 

You're probably not registering the TileEntity or the Special Renderer properly.

 

I would suggest you put a few breakpoints in your code (or System.out.println) to see which bits are being called properly, and which bits aren't - eg the constructor, the calls to ClientRegistry, the renderer, etc.  That will help you narrow it down.

 

-TGG

 

 

 

  • Author

okay i found out the methods that register the tile entity and bind the tile entity to the render were not being called and now i fixed that but the block is still invisable

Hi

 

If you put a breakpoint in this method:

    public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float scale) {

does it ever get called?

 

If not; you could try

(1) creating a flat world

(2) putting your TileEntity into it, then

(3) putting breakpoints into the vanilla code

TileEntityRendererDispatcher:

    /**

    * Render this TileEntity at a given set of coordinates

    */

    public void renderTileEntityAt(TileEntity p_147549_1_, double p_147549_2_, double p_147549_4_, double p_147549_6_, float p_147549_8_)

    {

        TileEntitySpecialRenderer tileentityspecialrenderer = this.getSpecialRenderer(p_147549_1_);

 

and

    /**

    * Render this TileEntity at its current position from the player

    */

    public void renderTileEntity(TileEntity p_147544_1_, float p_147544_2_)

    {

        if (p_147544_1_.getDistanceFrom(this.field_147560_j, this.field_147561_k, this.field_147558_l) < p_147544_1_.getMaxRenderDistanceSquared())

 

and

RenderGlobal::renderEntities

 

            this.theWorld.theProfiler.endStartSection("blockentities");

            RenderHelper.enableStandardItemLighting();

 

            for (i = 0; i < this.tileEntities.size(); ++i)

            {

                TileEntity tile = (TileEntity)this.tileEntities.get(i);

                if (tile.shouldRenderInPass(pass) && p_147589_2_.isBoundingBoxInFrustum(tile.getRenderBoundingBox()))

                {

                    TileEntityRendererDispatcher.instance.renderTileEntity(tile, p_147589_3_);

                }

            }

 

This should help you narrow down whether

(1) your TileEntity is never being created, or

(2) your TileEntity exists, but the renderer is incorrectly registered, or

(3) your model rendering is being called but is invisible.

 

-TGG

 

  • 9 months later...

You're calling a method model.renderModel(float) but in your definition of that method, you have no rendering code. That's why your model isn't rendering in-game.

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.