Jump to content

[Unsolved] Custom block model invisible and black/purple square when hold[1.6.2]


Recommended Posts

Posted

In my mod, I have a custom modelled block. The first problem is when I place it down in-game it's invisible. You can see the bounding-boxes, but you can't see the block itself. The second problem is when i hold it in my hand it's a black/purple squared icon, instead of my custom modelled block. I have a class that implements IItemRenderer and I registered it correctly (I think) and I have a class that extends TileEntitySpecialRenderer which (I think) registered correctly.

 

BlockStreetlight.java:

 

package larsg310.mods.bd.block;

import larsg310.mods.bd.lib.RenderIds;
import larsg310.mods.bd.lib.Strings;
import larsg310.mods.bd.tileentity.TileEntityStreetlight;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class BlockStreetlight extends BlockContainer
{

protected BlockStreetlight(int id)
{
	super(id, Material.iron);
	this.setCreativeTab(CreativeTabs.tabBlock);
	this.setUnlocalizedName(Strings.STREETLIGHT_NAME);
	this.setHardness(3F);
	this.setResistance(5F);
}
@Override
public TileEntity createNewTileEntity(World world)
{
	return new TileEntityStreetlight();
}
@Override
public boolean isOpaqueCube()
{
	return false;
}
@Override
public boolean renderAsNormalBlock()
{
	return false;
}
@Override
public int getRenderType()
{
	return RenderIds.STREETLIGHT_RENDER_ID;
}
@Override
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
    {
        super.breakBlock(par1World, par2, par3, par4, par5, par6);
        par1World.removeBlockTileEntity(par2, par3, par4);
    }

}

 

 

ClientProxy.java:

 

package larsg310.mods.bd.core.proxy;

import larsg310.mods.bd.block.BDBlocks;
import larsg310.mods.bd.lib.BlockIds;
import larsg310.mods.bd.render.item.ItemStreetlightRenderer;
import larsg310.mods.bd.render.tileentity.TileEntityStreetlightRenderer;
import larsg310.mods.bd.tileentity.TileEntityStreetlight;
import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.registry.GameRegistry;


public class ClientProxy extends CommonProxy
{
@Override
public void registerRenderThings()
{
	GameRegistry.registerTileEntity(TileEntityStreetlight.class, "tileStreetlight");

	MinecraftForgeClient.registerItemRenderer(BlockIds.STREETLIGHT, new ItemStreetlightRenderer());
	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityStreetlight.class, new TileEntityStreetlightRenderer());
}
}

 

 

I don't have anything in my CommonProxy and TileEntityStreetlight(I'll be adding stuff later on) class

 

ModelStreetlight.java (I'm using the new TechneModelLoader):

 

package larsg310.mods.bd.model;

import larsg310.mods.bd.lib.Models;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import net.minecraftforge.client.model.techne.TechneModelLoader;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class ModelStreetlight
{
private IModelCustom modelStreetlight;

public ModelStreetlight()
{
	modelStreetlight = AdvancedModelLoader.loadModel(Models.STREETLIGHT);
}
public void render()
{
	modelStreetlight.renderAll();
}
}

 

 

ItemStreetlightRenderer.java:

 

package larsg310.mods.bd.render.item;

import larsg310.mods.bd.lib.Textures;
import larsg310.mods.bd.model.ModelStreetlight;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.client.FMLClientHandler;

public class ItemStreetlightRenderer implements IItemRenderer
{
private ModelStreetlight modelStreetlight;
public ResourceLocation streetlightResourceLocation = new ResourceLocation(Textures.MODEL_STREETLIGHT);

public ItemStreetlightRenderer()
{
	modelStreetlight = new ModelStreetlight();
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type)
{
	return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) 
{
	return true;
}
 @Override
 public void renderItem(ItemRenderType type, ItemStack item, Object... data)
 {
	 switch (type)
	 {
     	case ENTITY:
     	{
        	renderStreetlight(0.5F, 0.5F, 0.5F);
            break;
        }
        case EQUIPPED:
        {
        	renderStreetlight(1.0F, 1.0F, 1.0F);
            break;
        }
        case EQUIPPED_FIRST_PERSON:
        {
        	renderStreetlight(1.0F, 1.0F, 1.0F);
        	break;
      	}
      	case INVENTORY:
      	{
      		renderStreetlight(0.0F, 0.075F, 0.0F);
        	break;
       	}
        default:
        {
        	break;
        }
    }
}
 private void renderStreetlight(float x, float y, float z)
 {
	 FMLClientHandler.instance().getClient().renderEngine.func_110577_a(streetlightResourceLocation);
	 GL11.glPushMatrix();
	 GL11.glTranslatef(x, y, z);
	 GL11.glRotatef(180, 1, 0, 0);
	 GL11.glRotatef(-90, 0, 1, 0);
	 modelStreetlight.render();
	 GL11.glPopMatrix();
    }
}

 

 

TileEntityStreetlightRenderer.java:

 

package larsg310.mods.bd.render.tileentity;

import larsg310.mods.bd.lib.Textures;
import larsg310.mods.bd.model.ModelStreetlight;
import larsg310.mods.bd.tileentity.TileEntityStreetlight;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeDirection;

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

import cpw.mods.fml.client.FMLClientHandler;

public class TileEntityStreetlightRenderer extends TileEntitySpecialRenderer
{
private ModelStreetlight modelStreetlight = new ModelStreetlight();
public ResourceLocation streetlightResourceLocation = new ResourceLocation(Textures.MODEL_STREETLIGHT);

@Override
    public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
{
        if (tileEntity instanceof TileEntityStreetlight)
        {
            TileEntityStreetlight TileEntityStreetlight = (TileEntityStreetlight) tileEntity;
            ForgeDirection direction = null;
            if (TileEntityStreetlight.getWorldObj() != null)
            {
                direction = ForgeDirection.getOrientation(TileEntityStreetlight.getBlockMetadata());
            }
            FMLClientHandler.instance().getClient().renderEngine.func_110577_a(streetlightResourceLocation);
   		 	GL11.glPushMatrix();
            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
            GL11.glScalef(1.0F, -1.0F, -1.0F);
            GL11.glTranslatef(0.5F, 0.5F, 0.5F);
            short angle = 0;
            if (direction != null)
            {
                if (direction == ForgeDirection.NORTH) 
                {
                    angle = 180;
                }
                else if (direction == ForgeDirection.SOUTH) 
                {
                    angle = 0;
                }
                else if (direction == ForgeDirection.WEST)
                {
                    angle = 90;
                }
                else if (direction == ForgeDirection.EAST)
                {
                    angle = -90;
                }
            }
            GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F);
            GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
            modelStreetlight.render();
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            GL11.glPopMatrix();
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        }
    }
}

 

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Sorry we seem to be unable to mind read you're code at the moment, so it's hard to tell what you did wrong

If you guys dont get it.. then well ya.. try harder...

Posted

Sorry we seem to be unable to mind read you're code at the moment, so it's hard to tell what you did wrong

I was in the middle of making the thread and I hit post accidently... But it's there now  :)

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Than I'll be making a new model class...

That doesn't work either... I got the same outcome... In another mod it works well, but that's for mc 1.5.2.

 

EDIT: I just took a look at the eclipse console and it sais:

 

2013-07-11 18:35:34 [sEVERE] [ForgeModLoader] A TileEntity type larsg310.mods.bd.tileentity.TileEntityStreetlight has throw an exception trying to write state. It will not persist. Report this to the mod author
java.lang.RuntimeException: class larsg310.mods.bd.tileentity.TileEntityStreetlight is missing a mapping! This is a bug!
at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:108)
at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:317)
at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:127)
at net.minecraft.world.gen.ChunkProviderServer.safeSaveChunk(ChunkProviderServer.java:232)
at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:284)
at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:897)
at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:358)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:591)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)
at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

 

Which looks like to me that it has to do something with the writeToNBT metho. And it sais it's a bug... But there isn't anything in the TileEntityStreetlight class (yet)!!!

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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.