Jump to content

[1.7.10] [UNSOLVED] Problems with rendering item inside an Item???


Recommended Posts

Posted

Well, title explains what i'm doing, now i'll explain the rest:

To render item (or multiple), i'm using this code (in custom item renderer):

@Override
public void renderItem(ItemRenderType type, ItemStack itemstack, Object... data) {
	if(type == IItemRenderer.ItemRenderType.EQUIPPED || type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON){
		EntityLivingBase entity = (EntityLivingBase) data[1];
		if(type == IItemRenderer.ItemRenderType.EQUIPPED)
			GL11.glTranslated(1, 0, 0.5);
		if(itemstack.getItemDamage() == 0){
			for(int i = 1; i < 10; i++){
				ItemStack item = ItemCompressedTools.getToolFromMeta(itemstack, i);
				if(item != null){
					if(MinecraftForgeClient.getItemRenderer(item, type) != null)
						ForgeHooksClient.renderEquippedItem(type, MinecraftForgeClient.getItemRenderer(item, type), (RenderBlocks) data[0], entity, item);
					else
						renderer.renderItem(entity, item, 0, type);
					GL11.glTranslated(-0.1, 0, 0);
				}
			}
		} else {
			ItemStack item = ItemCompressedTools.getCurrentTool(itemstack);
			if(item != null){
				if(MinecraftForgeClient.getItemRenderer(item, type) != null)
					ForgeHooksClient.renderEquippedItem(type, MinecraftForgeClient.getItemRenderer(item, type), (RenderBlocks) data[0], entity, item);
				else
					renderer.renderItem(entity, item, 0, type);
			}
		}
	}
	if(type == IItemRenderer.ItemRenderType.ENTITY){
		EntityItem entity = (EntityItem) data[1];
		if(itemstack.getItemDamage() == 0){
			for(int i = 1; i < 10; i++){
				ItemStack item = ItemCompressedTools.getToolFromMeta(itemstack, i);
				if(item != null){
					entity.setEntityItemStack(item);
					if(!ForgeHooksClient.renderEntityItem(entity, item, 0, 0, new Random(), FMLClientHandler.instance().getClient().renderEngine, (RenderBlocks) data[0], 1))
						RenderManager.instance.renderEntitySimple(entity, 1);
					GL11.glTranslated(-0.1, 0, 0);
				}
			}
		} else {
			ItemStack item = ItemCompressedTools.getCurrentTool(itemstack);
			if(item != null){
				entity.setEntityItemStack(item);
				if(!ForgeHooksClient.renderEntityItem(entity, item, 0, 0, new Random(), FMLClientHandler.instance().getClient().renderEngine, (RenderBlocks) data[0], 1))
					RenderManager.instance.renderEntitySimple(entity, 1);
			}
		}
		entity.setEntityItemStack(itemstack);
	}
	if(type == IItemRenderer.ItemRenderType.INVENTORY){
		EntityPlayer player = Minecraft.getMinecraft().thePlayer; 
		GL11.glTranslated(0.5, 0, 0);
		if(itemstack.getItemDamage() == 0){
			for(int i = 1; i < 10; i++){
				ItemStack item = ItemCompressedTools.getToolFromMeta(itemstack, i);
				if(item != null){
					if(!ForgeHooksClient.renderInventoryItem((RenderBlocks) data[0], FMLClientHandler.instance().getClient().renderEngine, item, true, 0, 0, 0))
						renderer.renderItem(player, item, 0, type);	
					GL11.glTranslated(-0.1, 0, 0);
				}
			}
		} else {
			ItemStack item = ItemCompressedTools.getCurrentTool(itemstack);
			if(item != null){
				if(!ForgeHooksClient.renderInventoryItem((RenderBlocks) data[0], FMLClientHandler.instance().getClient().renderEngine, item, true, 0, 0, 0))
					renderer.renderItem(player, item, 0, type);	
			}
		}
	}
}

 

But here we don't need full code, we just need one part of it, the one that is responsible for rendering actual item "in item".

Here is one for equipped renderer:

if(MinecraftForgeClient.getItemRenderer(item, type) != null)
						ForgeHooksClient.renderEquippedItem(type, MinecraftForgeClient.getItemRenderer(item, type), (RenderBlocks) data[0], entity, item);
					else
						renderer.renderItem(entity, item, 0, type);

One for entity:

if(!ForgeHooksClient.renderEntityItem(entity, item, 0, 0, new Random(), FMLClientHandler.instance().getClient().renderEngine, (RenderBlocks) data[0], 1))
						RenderManager.instance.renderEntitySimple(entity, 1);

And one for inventory:

if(!ForgeHooksClient.renderInventoryItem((RenderBlocks) data[0], FMLClientHandler.instance().getClient().renderEngine, item, true, 0, 0, 0))
						renderer.renderItem(player, item, 0, type);

 

An well the problem is:

-items that have custom model are rendered few times bigger

-items with multiple render passes, are rendered with only one

-for entity renderer, item is rendered weirdly somewhere far awy from actual entity

And this applies for each renderer case!

 

Any help will be appreciated!

Posted

My guess would be "yes."

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.

  • 3 weeks later...
Posted

Hey, I don't know all the answers, but Ill try my verry best.

 

Fisrt of all, in the methode "renderItem()", you should specify the coördinates relative to the player. if the item is showing up far away from the player, you should change the values in the "GL11.glTranslated()".

If you want to change the scale you can use the "GL11.glScalef()" methode.

these first to can be different for each renderType.

 

and about your second point: "items with multiple render passes, are rendered with only one",

what exactualy do you mean?

 

Hope this helps a bit, other wise let us know ;D!

GL

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

Posted
  On 4/6/2015 at 6:34 AM, N247S said:

Hey, I don't know all the answers, but Ill try my verry best.

 

Fisrt of all, in the methode "renderItem()", you should specify the coördinates relative to the player. if the item is showing up far away from the player, you should change the values in the "GL11.glTranslated()".

If you want to change the scale you can use the "GL11.glScalef()" methode.

these first to can be different for each renderType.

 

and about your second point: "items with multiple render passes, are rendered with only one",

what exactualy do you mean?

 

Hope this helps a bit, other wise let us know ;D!

GL

1) I tried using translateD, and for some reasons this is not working... (why???)...

2) I mean that only first layer of item is rendered. Example: leather armor has 2 layers of texture, but only one is rendered

Posted

Pls post your current relevant code

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted
  On 4/6/2015 at 7:25 AM, Abastro said:

Pls post your current relevant code

One for entity is the case of not working translateD. Just adding right before it translateD, doesn't change a lot...

Well to explain better, it doesn't raproaches it to center, just to one point far away from it...

(i'll post pics here as soon as will have them, and sorry for long awaited post)...

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello all. I'm currently grappling with the updateShape method in a custom class extending Block.  My code currently looks like this: The conditionals in CheckState are there to switch blockstate properties, which is working fine, as it functions correctly every time in getStateForPlacement.  The problem I'm running into is that when I update a state, the blocks seem to call CheckState with the position of the block which was changed updated last.  If I build a wall I can see the same change propagate across. My question thus is this: is updateShape sending its return to the neighbouring block?  Is each block not independently executing the updateShape method, thus inserting its own current position?  The first statement appears to be true, and the second false (each block is not independently executing the method). I have tried to fix this by saving the block's own position to a variable myPos at inception, and then feeding this in as CheckState(myPos) but this causes a worse outcome, where all blocks take the update of the first modified block, rather than just their neighbour.  This raises more questions than it answers, obviously: how is a different instance's variable propagating here?  I also tried changing it so that CheckState did not take a BlockPos, but had myPos built into the body - same problem. I have previously looked at neighbourUpdate and onNeighbourUpdate, but could not find a way to get this to work at all.  One post on here about updatePostPlacement and other methods has proven itself long superceded.  All other sources on the net seem to be out of date. Many thanks in advance for any help you might offer me, it's been several days now of trying to get this work and several weeks of generally trying to get round this roadblock.  - Sandermall
    • sorry, I might be stupid, but how do I open it? because the only options I have are too X out, copy it, which doesn't work and send crash report, which doesn't show it to me, also, sorry for taking so long.
    • Can you reproduce this with version 55.0.21? A whole lot of plant placement issues were just fixed in this PR.
    • Necro'ing that thread to ask if you found a solution ? I'm encountering the same crash on loading the world. I created the world in Creative to test my MP, went into survival to test combat, died, crashed on respawn and since then crash on loading the world. Deactivating Oculus isn't fixing it either, and I don't have Optifine (Twilight forest is incompatible)
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.