Jump to content

[1.6.4] How to change part of the texture of a block?


andreidim

Recommended Posts

Hello everyone :) I'm working on a mod and I need to change dinamically based on a variable in my tile entity a part of the texture, like a progress bar but for something else, how could I do that? A few good examples I know are the energy cells from from thermal expansion and the machines from forestry.

Is that hard to do? I don't have any open source mods to check out that do that... Why are there closed source mods? Yes, I know, but still, I want to see all of the sources, I like to learn new stuff, mostly how Azanor does his particles and stuff

Link to comment
Share on other sites

How is your block being rendered?  ISimpleBlockRenderingHandler, TileEntitySpecialRenderer, or neither?

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

If I will have a TE and stuff, should I use a TileEntitySpecialRenderer? I will have it look like a normal square block, but I need it to have textures that can change.

I never used an ISimpleBlockRenderingHandler because the only thing I used special renderers for was a chest-like thing that still has no animation and sound ;(

What do you think I should use?

Link to comment
Share on other sites

You don't need a TESR, I was asking if you were using one.

 

For a full cube you can either go the standard block renderer route or you can go ISimpleBlockRenderingHandler, if the default renderer won't work for you.

 

Likely the default renderer will work and you just need to write a getIcon() function to handle your needs.  There's one in the Block class that has an IBlockAccess or World parameter passed to it.  Use that parameter to get your TE and determine the state and which Icon should be returned as a result.

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

Yes.  Use multiple passes.  First pass renders the background, second pass uses the overlay.

 

Here's an example for an Item, but I'm pretty sure Blocks can do it too.

 

https://github.com/Draco18s/Artifacts/blob/master/draco18s/artifacts/item/ItemArtifact.java

 

(Keeping in mind that I'm using NBT data to store which icon to use and the icons themselves are stored in an API referenced hashtable)

 

If it doesn't work in a similar manner, an ISimpleBlockRenderingHandler will work

 

https://github.com/Draco18s/Artifacts/blob/master/draco18s/artifacts/client/RenderArrowTrap.java

Line 109 renders the base texture and the switch statement on 110 renders an overlay across one face.  Not the best code in the world, but it works, so I haven't cleaned it up.

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

Multiple render passes seem good enough, thanks :)

 

I figured. :D

I tend to do really bizarre things when I mod.  Works out to be great examples in so many ways for much simpler purposes.  I didn't know about multiple render passes when I did that block, though.  It dates about six months older than the Item...I should redo how several of the blocks are rendered.  The spikes block uses three textures (I could probably just use setTextureOffset instead!)

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.

Announcements



×
×
  • Create New...

Important Information

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