Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Using a TileEntitySpecialRenderer


TheJavaNoob
 Share

Recommended Posts

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

Link to comment
Share on other sites

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();
	}
}

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

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
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.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Im trying to make a moddes server with my friends but every single time we get same error https://pastebin.com/UP6P6YSd Is there a way to fix it? Thanks for solutions
    • Take a break, go for a walk. Then try again. 🙂
    • Where did you see that? Sorry if I am being a bother, it's just that I have been staring at this mod for a long time and I'm probably looking over a lot of things
    • Taking a look at AbstractContainerScreen.renderSlot() I got the following code: Method created in my AbstractContainerScreen class: private void renderCustomSlot(PoseStack poseStack,ItemStack itemstack,int x, int y) { boolean visible = true; boolean hover = false; this.setBlitOffset(100); this.itemRenderer.blitOffset = 100.0F; if (visible) { if (hover) { //Draw a rectangle behind the item fill(poseStack, x, y, x + 16, y + 16, -2130706433); } //Render item icon RenderSystem.enableDepthTest(); this.itemRenderer.renderAndDecorateItem(this.minecraft.player, itemstack, x, y, x + y * this.imageWidth); //Render item string count PoseStack posestack = new PoseStack(); if (itemstack.getCount() != 1) { String s = String.valueOf(itemstack.getCount()); posestack.translate(0.0D, 0.0D, itemRenderer.blitOffset + 200.0F); MultiBufferSource.BufferSource multibuffersource$buffersource = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); /* float scale; if (s.length()<3){ scale=1f; }else if (s.length()<4){ scale = 0.75f; }else { scale=0.5f; s = s.substring(0,s.length()-3)+"k"; } float compensatingScale = 1/scale; float stringX = (x + 19f - 2 - font.width(s)*scale)*compensatingScale; float stringY =(y + 6f + 3)*compensatingScale; posestack.scale(scale,scale,scale); */ float stringX = (x + 19f - 2 - font.width(s)); float stringY =(y + 6f + 3); font.drawInBatch(s,stringX,stringY,16777215, true, posestack.last().pose(), multibuffersource$buffersource, false, 0, 15728880); //posestack.scale(compensatingScale,compensatingScale,compensatingScale); multibuffersource$buffersource.endBatch(); } } this.itemRenderer.blitOffset = 0.0F; this.setBlitOffset(0); } Now it works correctly: Thanks to warjort for the tip!
    • Hello, I am currently trying to get a forge server setup so I can play the Pixelmon mod with some friends on a private server and have run into some issues with launching my forge server file, I downloaded the forge 12.2.2-14.23.5.2859 installer, downloaded it into a folder on my desktop, ran the Mc server file, agreed to Eula, made a run.bat file to launch the forge server at 6GBs, and when I try launching I get this issue: Pixelmon Server>java -Xmx6144M -Xms6144M -jar forge-1.12.2-14.23.5.2859-universal.jar --nogui We appear to be missing one or more essential library files. You will need to add them to your server before FML and Forge will run successfully.java.lang.ClassNotFoundException: org.objectweb.asm.Type         at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)         at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)         at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)         at java.base/java.lang.Class.forName0(Native Method)         at java.base/java.lang.Class.forName(Class.java:466)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:53)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34)   I've tried using another minecraft server jar file from a different source to see if that would solve anything but its still coming up with this issue. Any help is greatly appreciated, thanks for your help in advance.
  • Topics

×
×
  • Create New...

Important Information

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