Jump to content

Item render not being used/ working


david476

Recommended Posts

Hi, sorry for the new thread, this isn't urgent but it would be nice to clear up. I followed

for rendering techne models as blocks. The block works fine but it renders as a flat texture that I gave it in my inventory. From 33:40 he talks about using the tile entity renderer in you inventory but mine dosn't seem to work, no crashes but nothing is changed. Just wondering if anyone can notice the stupid mistake I probably made.

 

Nothing related to the render in my INIT class

 

Client Proxy:

package com.deb.debmodularships.proxies;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.Item;
import net.minecraftforge.client.MinecraftForgeClient;

import com.deb.debmodularships.ModularshipsINIT;
import com.deb.debmodularships.entities.EntityController;
import com.deb.debmodularships.renders.ItemRenderController;
import com.deb.debmodularships.renders.RenderController;
import com.deb.debmodularships.renders.RenderTEController;
import com.deb.debmodularships.tileentities.TileEntityController;

import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;

public class ClientProxy extends CommonProxy{
public void registerRenderers() {
	RenderingRegistry.registerEntityRenderingHandler(EntityController.class, new RenderController());
	TileEntitySpecialRenderer crender = new RenderTEController();
	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityController.class, crender);
	MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModularshipsINIT.BlockController), new ItemRenderController(crender, new TileEntityController()));
}

public void registerTileEntitySpecialRenderer() {

}
}

 

Item Renderer:

package com.deb.debmodularships.renders;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.client.IItemRenderer;

public class ItemRenderController implements IItemRenderer{

TileEntitySpecialRenderer render;
private TileEntity entity;

public ItemRenderController(TileEntitySpecialRenderer render, TileEntity entity) {
	this.entity = entity;
	this.render = render;
}

@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) {
	if (type == IItemRenderer.ItemRenderType.ENTITY)
		GL11.glTranslatef(-0.5f, 0.0f, -0.5f);
	this.render.renderTileEntityAt(this.entity, 0.0d, 0.0d, 0.0d, 0.0f);
}

}

 

Renderer:

package com.deb.debmodularships.renders;

import org.lwjgl.opengl.GL11;

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

import com.deb.debmodularships.ModularshipsINIT;
import com.deb.debmodularships.models.ModelController;
import com.deb.debmodularships.tileentities.TileEntityController;

public class RenderTEController extends TileEntitySpecialRenderer{

public static final ResourceLocation Ctexture = new ResourceLocation(ModularshipsINIT.MODID + ":textures/entity/entitycontroller.png");
private ModelController model;

public RenderTEController() {
	this.model = new ModelController();
}

@Override
public void renderTileEntityAt(TileEntity TE, double x, double y, double z, float f) {
	TileEntityController TEC = (TileEntityController)TE;
	GL11.glPushMatrix();
		GL11.glTranslatef((float)x + 0.5f, (float)y + 1f, (float)z + 0.5f);
		GL11.glRotatef(180f, 0f, 0f, 1f);
		GL11.glRotatef(180 + TEC.rotation, 0f, 1f, 0f);
		this.bindTexture(Ctexture);
		GL11.glPushMatrix();
			this.model.renderModel(0.03125f);
		GL11.glPopMatrix();
	GL11.glPopMatrix();
}

}

 

Let me know if you might need other classes!

Link to comment
Share on other sites

Hi

 

Do you know if renderItem is being called?  (i.e. breakpoint or System.out.println?)

 

If so - something is wrong with your renderer, eg is rendering at the wrong coordinates, offscreen etc.

If not - probably you haven't registered the Item renderer properly.

 

I don't see obvious problems but there might be something subtle I'm missing.

 

-TGG

Link to comment
Share on other sites

FIGURED IT OUT!!!

 

I called the proxy method before setting the block variable to a block, the renderer was registered for a null variable! ("facepalm"). Thanks for trying to help, I realize you couldn't have seen the problem as I didn't post the INIT class.

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.