Jump to content

[SOLVED]Render the Item of Block with special Renderer


Bedrock_Miner

Recommended Posts

You will also need an item renderer.

Check out my classes here:

https://github.com/Draco18s/Artifacts/tree/master/draco18s/artifacts/client

 

You'll be looking at the client proxy and the spikes.

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

You will also need an item renderer.

Check out my classes here:

https://github.com/Draco18s/Artifacts/tree/master/draco18s/artifacts/client

 

You'll be looking at the client proxy and the spikes.

The page responds the following:

This repository is temporarily unavailable.

The backend storage is temporarily offline. Usually this means the storage server is undergoing maintenance. Please contact support if the problem persists.

 

Can you give me the Code directly or send me another link?

Link to comment
Share on other sites

I had that problem too.  That's honestly the best way to give you everything.  It's a lot of cross referencing.

 

The primary class needed is a IItemRenderer:

 

public class ItemRenderSpikes implements IItemRenderer {
TileEntitySpecialRenderer render;
private TileEntity dummytile;
  
public ItemRenderSpikes(TileEntitySpecialRenderer render, TileEntity dummy) {
    this.render = render;
    this.dummytile = dummy;
}

@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.dummytile, 0.0D, 0.0D, 0.0D, 0.0F);
}
}

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

OK, I just added this to my Mod.

 

I registered it with this code:

MinecraftForgeClient.registerItemRenderer(ModBlock.magicCrafting.blockID, new RenderItemMagicCrafting(new RenderMagicCrafting(), new TileEntity()));

 

And I get the following Error when the Item should be rendered in the Inventory:

2013-11-10 20:54:12 [iNFO] [sTDERR] net.minecraft.util.ReportedException: Rendering screen
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1045)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:945)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.run(Minecraft.java:837)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at net.minecraft.client.main.Main.main(Main.java:93)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at net.minecraft.launchwrapper.Launch.main(Launch.java:27)
2013-11-10 20:54:12 [iNFO] [sTDERR] Caused by: java.lang.NullPointerException
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer.bindTexture(TileEntitySpecialRenderer.java:23)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at magicum.minecraft.client.renderer.RenderMagicCrafting.renderTileEntityAt(RenderMagicCrafting.java:40)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at magicum.minecraft.client.renderer.RenderItemMagicCrafting.renderItem(RenderItemMagicCrafting.java:34)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at net.minecraftforge.client.ForgeHooksClient.renderInventoryItem(ForgeHooksClient.java:163)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:465)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at net.minecraft.client.gui.inventory.GuiContainer.drawSlotInventory(GuiContainer.java:421)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:132)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:43)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:683)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1036)
2013-11-10 20:54:12 [iNFO] [sTDERR] 	... 9 more
2013-11-10 20:54:12 [iNFO] [sTDOUT] ---- Minecraft Crash Report ----
2013-11-10 20:54:12 [iNFO] [sTDOUT] // I just don't know what went wrong 
2013-11-10 20:54:12 [iNFO] [sTDOUT] 
2013-11-10 20:54:12 [iNFO] [sTDOUT] Time: 10.11.13 20:54
2013-11-10 20:54:12 [iNFO] [sTDOUT] Description: Rendering screen
2013-11-10 20:54:12 [iNFO] [sTDOUT] 
2013-11-10 20:54:12 [iNFO] [sTDOUT] java.lang.NullPointerException
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer.bindTexture(TileEntitySpecialRenderer.java:23)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at magicum.minecraft.client.renderer.RenderMagicCrafting.renderTileEntityAt(RenderMagicCrafting.java:40)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at magicum.minecraft.client.renderer.RenderItemMagicCrafting.renderItem(RenderItemMagicCrafting.java:34)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraftforge.client.ForgeHooksClient.renderInventoryItem(ForgeHooksClient.java:163)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:465)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.gui.inventory.GuiContainer.drawSlotInventory(GuiContainer.java:421)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:132)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:43)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:683)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1036)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:945)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.Minecraft.run(Minecraft.java:837)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.main.Main.main(Main.java:93)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at java.lang.reflect.Method.invoke(Unknown Source)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.launchwrapper.Launch.main(Launch.java:27)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 
2013-11-10 20:54:12 [iNFO] [sTDOUT] 
2013-11-10 20:54:12 [iNFO] [sTDOUT] A detailed walkthrough of the error, its code path and all known details is as follows:
2013-11-10 20:54:12 [iNFO] [sTDOUT] ---------------------------------------------------------------------------------------
2013-11-10 20:54:12 [iNFO] [sTDOUT] 
2013-11-10 20:54:12 [iNFO] [sTDOUT] -- Head --
2013-11-10 20:54:12 [iNFO] [sTDOUT] Stacktrace:
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer.bindTexture(TileEntitySpecialRenderer.java:23)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at magicum.minecraft.client.renderer.RenderMagicCrafting.renderTileEntityAt(RenderMagicCrafting.java:40)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at magicum.minecraft.client.renderer.RenderItemMagicCrafting.renderItem(RenderItemMagicCrafting.java:34)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraftforge.client.ForgeHooksClient.renderInventoryItem(ForgeHooksClient.java:163)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:465)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.gui.inventory.GuiContainer.drawSlotInventory(GuiContainer.java:421)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:132)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:43)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:683)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 
2013-11-10 20:54:12 [iNFO] [sTDOUT] -- Screen render details --
2013-11-10 20:54:12 [iNFO] [sTDOUT] Details:
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	Screen name: net.minecraft.client.gui.inventory.GuiContainerCreative
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	Mouse location: Scaled: (294, 204). Absolute: (589, 70)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	Screen size: Scaled: (427, 240). Absolute: (854, 480). Scale factor of 2
2013-11-10 20:54:12 [iNFO] [sTDOUT] 
2013-11-10 20:54:12 [iNFO] [sTDOUT] -- Affected level --
2013-11-10 20:54:12 [iNFO] [sTDOUT] Details:
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	Level name: MpServer
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	All players: 1 total; [EntityClientPlayerMP['Player115'/240, l='MpServer', x=162,36, y=66,62, z=236,88]]
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	Chunk stats: MultiplayerChunkCache: 405
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	Level seed: 0
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	Level generator: ID 00 - default, ver 1. Features enabled: false
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	Level generator options: 
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	Level spawn location: World: (152,64,256), Chunk: (at 8,4,0 in 9,16; contains blocks 144,0,256 to 159,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	Level time: 32410 game time, 6646 day time
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	Level dimension: 0
2013-11-10 20:54:12 [iNFO] [sTDOUT] 	Level storage version: 0x00000 - Unknown?

 

 

The Stacktrace points to this method in TileEntitySpecialRenderer:

protected void bindTexture(ResourceLocation par1ResourceLocation)
    {
        TextureManager texturemanager = this.tileEntityRenderer.renderEngine;

        if (texturemanager != null)
        {
            texturemanager.bindTexture(par1ResourceLocation);
        }
    }

 

bindTexture is called in the Renderer like this:

 

GL11.glPushMatrix();
            GL11.glTranslatef((float) x + 0.5F, (float) y + (6F / 16F), (float) z + 0.5F);
            this.bindTexture(new ResourceLocation(Resources.getModId() + "textures/models/MagicCrafting.png"));
            GL11.glPushMatrix();
            GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
            this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
            GL11.glPopMatrix();
            GL11.glPopMatrix();

 

 

I really don't know, whats wrong.

Write if you need more code.

 

Link to comment
Share on other sites

Don't pass new TileEntity(), pass a new YourTileEntityClass()

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

Here's my client proxy:

 

        render = new SpikesRenderer();
        ClientRegistry.bindTileEntitySpecialRenderer(EntitySpikes.class, render);
        MinecraftForgeClient.registerItemRenderer(BlockSpikes.instance.blockID, new ItemRenderPedestal(render, new EntitySpikes()));

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

Here's my client proxy:

 

        render = new SpikesRenderer();
        ClientRegistry.bindTileEntitySpecialRenderer(EntitySpikes.class, render);
        MinecraftForgeClient.registerItemRenderer(BlockSpikes.instance.blockID, new ItemRenderPedestal(render, new EntitySpikes()));

Thank you very much!

The problem was that I created two different renderers...

 

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.