Jump to content

Recommended Posts

Posted

I tried to render Items onto a block, but when I start Minecraft, it shows these error message:

[17:29:41] [Client thread/ERROR] [FML]: Model definition for location instanttransport:tower_frame#inventory not found
[17:29:41] [Client thread/ERROR] [FML]: Model definition for location instanttransport:tower_frame#normal not found

Do I need to do anything else to avoid this, or maybe something has just gone wrong

Posted

Also, I am trying to render an Item onto the block, but it isn't showing up, this is my rendering code(Note: tileentity.south is the defines how many items there are on the south side of a block):

public class TileEntityRenderTowerFrame extends TileEntitySpecialRenderer {

	@Override
	public void renderTileEntityAt(TileEntity tileentity, double posX, double posY, double posZ,
			float unknown, int blockBreakingProccess) {
		GlStateManager.pushMatrix();
		if(((TileEntityTowerFrame)tileentity).south!=0){
			Minecraft.getMinecraft().getRenderItem().renderItemModel(new ItemStack(ModItems.iron_stick));
			if(((TileEntityTowerFrame)tileentity).south==2){
				GlStateManager.rotate(270.0F, 0.0F, 0.0F, 1.0F);
				Minecraft.getMinecraft().getRenderItem().renderItemModel(new ItemStack(ModItems.iron_stick));
			}
		}
		GlStateManager.popMatrix();
	}
}

 

Posted (edited)
1 hour ago, TheJavaNoob said:

Do I need to do anything else to avoid this, or maybe something has just gone wrong

Well, look at the error message. It tells you exactly what is wrong. You should look into the entire fml_client_latest.log for more verbose output and figure out how to fix that.

 

57 minutes ago, TheJavaNoob said:

TileEntityRenderTowerFrame extends TileEntitySpecialRenderer

57 minutes ago, TheJavaNoob said:

TileEntity tileentity

Do you know what generics are? Using them here will save you from a lot of redundant casts. As to the issue:

  • Rendering an item with a block does not require a TESR and can be achieved with a custom IBakedModel.
  • You are currently rendering at origin point(0,0,0). Well, view-space origin that is. Translate the matrix by x,y,z passed to you as parameters. Make sure that the item rendered does not end up inside a block where you can't see it before saying "it doesn't work either"
  • It is probably not a good idea to create a new ItemStack object x2 each frame. Especially considering that they are identical by content. If you need to render a constant ItemStack like that have it in a constant field.
  • You haven't shown how/where you are registering your TESR.

 

Edited by V0idWa1k3r
Posted
14 minutes ago, V0idWa1k3r said:

Well, look at the error message. It tells you exactly what is wrong. You should look into the entire fml_client_latest.log for more verbose output and figure out how to fix that.

public class TileEntityRenderTowerFrame extends TileEntitySpecialRenderer {

	@Override
	public void renderTileEntityAt(TileEntity tileentity, double posX, double posY, double posZ,
			float unknown, int destroyStage) {
		GlStateManager.pushMatrix();
		if(((TileEntityTowerFrame)tileentity).south!=0){
			Minecraft.getMinecraft().getRenderItem().renderItemModel(new ItemStack(ModItems.iron_stick));
			if(((TileEntityTowerFrame)tileentity).south==2){
				Minecraft.getMinecraft().getRenderItem().renderItemModel(new ItemStack(ModItems.iron_stick));
				GlStateManager.rotate(270.0F, 0.0F, 0.0F, 1.0F);
				GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
				GlStateManager.translate((float)posX, (float)posY + 1.0F, (float)posZ + 1.0F);
			}
		}
		GlStateManager.popMatrix();
	}
}

Here is my new code, I translated the item to where the block is.

ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTowerFrame.class, new TileEntityRenderTowerFrame());

This is where I registered my TileEntitySpecialRenderer

 

.And also, you said I need to use an iBakedModel, can you tell me how I can do that.

Posted (edited)
53 minutes ago, TheJavaNoob said:

I translated the item to where the block is.

No you didn't. You are still rendering your items at view origin and then translating the matrix. 

You are still not using generics for your TESR. And are still creating a new ItemStack x2 each frame.

53 minutes ago, TheJavaNoob said:

This is where I registered my TileEntitySpecialRenderer

This is a segment of code that shows how you are doing it, not where and it certainly does not confirm that the TESR is even being registered.

 

53 minutes ago, TheJavaNoob said:

I need to use an iBakedModel, can you tell me how I can do that.

I am not really sure actually, I've never done that kind of a custom IBakedModel before. I assume that as with other custom IBakedModels you would need a custom ICustomModelLoader implementation with a custom IModel implementation that would allow you to have your custom IBakedModel to begin with. You would need to have 2 lists of quads in that model - 1 for your block and 1 for your item and in your getQuads implementation you would return a combination of those lists. While I can get the following to work in my test environment I am sure that there are more efficient ways to do this - (this part is written after my ~30 minute search :P)and I have found one on this very forum!

 

Edited by V0idWa1k3r
Posted (edited)
1 hour ago, V0idWa1k3r said:

You are still not using generics for your TESR. And are still creating a new ItemStack x2 each frame.

OK, I finally understood what this meant(English is not my first language, don't judge me). So you said I need to use generics for TESR, I don't know what that is. Also, whenever I click the block, the onBlockActivated method are called for multiple times, it(seems like) didn't happen when I does this earlier. This is my onBlockActivated method:

Spoiler

@Override
	public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
			EnumFacing side, float hitX, float hitY, float hitZ) {
		boolean put=false;
		System.out.println("Clicked");
		if(playerIn.inventory.getCurrentItem().getItem()==ModItems.iron_stick){
			if(side.compareTo(EnumFacing.SOUTH)==0&&this.te.south!=2){
				this.te.south+=1;
				put=true;
			}else if(side.compareTo(EnumFacing.NORTH)==0&&this.te.north!=2){
				this.te.north+=1;
				put=true;
			}else if(side.compareTo(EnumFacing.EAST)==0&&this.te.east!=2){
				this.te.east+=1;
				put=true;
			}else if(side.compareTo(EnumFacing.WEST)==0&&this.te.west!=2){
				this.te.west+=1;
				put=true;
			}
			if(put){
				playerIn.inventory.decrStackSize(playerIn.inventory.currentItem, 1);
			}
		}
		return true;
	}

 

Keeping track of my new rendering code:

Spoiler

@Override
	public void renderTileEntityAt(TileEntity tileentity, double posX, double posY, double posZ,
			float unknown, int destroyStage) {
		GlStateManager.pushMatrix();
		if(((TileEntityTowerFrame)tileentity).south!=0){
			GlStateManager.rotate(270.0F, 0.0F, 0.0F, 1.0F);
			GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
			GlStateManager.translate((float)posX, (float)posY + 1.0F, (float)posZ + 1.0F);
			Minecraft.getMinecraft().getRenderItem().renderItemModel(stack);
			if(((TileEntityTowerFrame)tileentity).south==2){
				Minecraft.getMinecraft().getRenderItem().renderItemModel(stack);
			}
		}
		GlStateManager.popMatrix();
	}

I moved the translation all the way up, but it still didn't work.

BTW, I registered the rendering code in the BlockRenderRegister which is called in the preInit in the ClientProxy(When I was typing this in, I suddenly discovered that I forgot to call the BlockRenderRegister.:S)

Edited by TheJavaNoob
Forgot something
Posted (edited)
15 minutes ago, TheJavaNoob said:

So you said I need to use generics for TESR, I don't know what that is

Well, you should learn the language that you are using to create mods first then. At least it's basics.

Block::onBlockActivated indeed gets called multiple times - 1 on the server and 1 on the client. Also I do not think that that signature is right - where is the EnumHand argument? What version of the game are you creating a mod for?

 

15 minutes ago, TheJavaNoob said:

GlStateManager.rotate(270.0F, 0.0F, 0.0F, 1.0F);

GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

GlStateManager.translate((float)posX, (float)posY + 1.0F, (float)posZ + 1.0F);

You must translate the matrix first, then rotate it.

Edited by V0idWa1k3r
Posted
5 minutes ago, V0idWa1k3r said:

What version of the game are you creating a mod for?

I am using Minecraft 1.8. And when I said the thing about language, I meant I don't actually speak English. Still, I don't know what "generics for TESR" is. Is it a method or a class or anything else?

Posted

1.8 is very outdated and you should update.

1 minute ago, TheJavaNoob said:

Still, I don't know what "generics for TESR" is. Is it a method or a class or anything else?

Generics are a feature of java and many other programming languages. Look it up in a java manual or use a search engine of your choice. I guess it won't apply to 1.8 as 1.8 still was not using generics for TileEntitySpecialRenderer(aka TESR). 

 

If you have moved the translate above your rotate call and it is still not working I would suggest using a debugger to find out if

  • Your TESR's renderTileEntityAt is being called at all.
  • The client is aware of the values of the fields.

 

Posted
5 minutes ago, TheJavaNoob said:

I am using Minecraft 1.8. And when I said the thing about language, I meant I don't actually speak English. Still, I don't know what "generics for TESR" is. Is it a method or a class or anything else?

He's referring to https://en.wikipedia.org/wiki/Generics_in_Java

  • Like 1

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.

Posted

Generics, I know that. Maybe I got used to how they call them in Chinese. I'm working in 1.8, so I can't use it whatsoever.

I finally found out where the problem is. There is nothing wrong with the rendering, when I removed the if statement, the Item renders properly(but not correctly) now.

2017-08-09_22_10_18.png.fb7412c066b41f16cdbad9f94f75cc06.png

Posted

So, the last problem is solved, but I got a new problem. When I start the game, The sticks on the first block I placed down renders correctly, but when I placed down the second block, nothing showed up. According to the debugging, the tileentity argument passed to my renderTileEntity was not right.

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.