Jump to content

Setting a blocks texture based on state and rotation


Asweez

Recommended Posts

I have a wall that I've made and I want the texture on top to rotate base on the direction the wall is facing. I also want to change the texture if the wall is a post rather than a connector. How would I do this?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

You will need a custom block renderer (using ISimpleBlockRenderingHandler).

Then before you draw your Block (possibly using renderBlockWall in the RenderBlocks instance you get) you set uvRotateTop in that same RenderBlocks to a value 0-3 to rotate the top texture. Set it to 0 again afterwards.

Do you know a tutorial? If not where do I register the renderer and what vanilla class could I reference?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

I don't know of a tutorial, but all your renderWorldBlock method needs to do is set the rotation and then call the original renderBlockWall method.

You register your ISBRH with FMLs RenderingRegistry class.

 

OK, I'm not that familiar with ISBRH so how do I detect what direction the block is facing? And how would I rotate the texture after that?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

OK, I'm not that familiar with ISBRH so how do I detect what direction the block is facing? And how would I rotate the texture after that?

 

world#getBlockMetadata?

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

Well the wall I have already has other walls with metadata. And the world param isn't actually world. It can't detect that stuff.

OK, I'm not that familiar with ISBRH so how do I detect what direction the block is facing? And how would I rotate the texture after that?

 

world#getBlockMetadata?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

IBlockAccess still has getBlock and getBlockMetadata.

 

Point is:

If you want to change the rotation to a specific direction, you're going to need to figure out what defines that specific direction yourself.  No one else can say "oh just do X" because you're the one who wants something specific based on parameters only you know.

 

If its based on which direction the player was facing when they placed it down you're either going to have to save it in the metadata or use a TileEntity.  There are no ifs, ands, or buts about it.  The game isn't magic and can't interpret what you say into what you mean unless you are clear and unambiguous.

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

IBlockAccess still has getBlock and getBlockMetadata.

 

Point is:

If you want to change the rotation to a specific direction, you're going to need to figure out what defines that specific direction yourself.  No one else can say "oh just do X" because you're the one who wants something specific based on parameters only you know.

 

If its based on which direction the player was facing when they placed it down you're either going to have to save it in the metadata or use a TileEntity.  There are no ifs, ands, or buts about it.  The game isn't magic and can't interpret what you say into what you mean unless you are clear and unambiguous.

I don't want it to be determined by the way the player was facing, I want the way the wall is connected to adjacent walls to determine the rotation of the texture.

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

Then you're going to need to know if there's a wall at XPos, ZPos, XNeg, or ZNeg.  world#getBlock

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 need a custom block renderer (using ISimpleBlockRenderingHandler).

Then before you draw your Block (possibly using renderBlockWall in the RenderBlocks instance you get) you set uvRotateTop in that same RenderBlocks to a value 0-3 to rotate the top texture. Set it to 0 again afterwards.

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

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.



×
×
  • Create New...

Important Information

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