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

Different block face textures while using infinite terrain


HuskyBlueFire
 Share

Recommended Posts

Hi :)

 

I'm currently trying to figure out how to get different textures on different sides of a block, while using the infinite terrain / sprite index.

 

I did this before in modloader fine, but in forge using the terrain.png style approach I'm a bit stumped.  I have tried for hours scouring the net for answers and the few I found were just vague.  Maybe I'm being blind and/or stupid but hopefully someone can help.

 

I have the textures working fine using the mods terrain.png, I just need to know the code that applies a different index number for each side of the block in question.

 

Thanks in advance,

Husky :)

 

NB: Work I've referenced http://www.minecraftforge.net/wiki/How_to_use_infinite_terrain_and_sprite_indexes

Link to comment
Share on other sites

Hi :)

 

I'm currently trying to figure out how to get different textures on different sides of a block, while using the infinite terrain / sprite index.

 

I did this before in modloader fine, but in forge using the terrain.png style approach I'm a bit stumped.  I have tried for hours scouring the net for answers and the few I found were just vague.  Maybe I'm being blind and/or stupid but hopefully someone can help.

 

I have the textures working fine using the mods terrain.png, I just need to know the code that applies a different index number for each side of the block in question.

 

Thanks in advance,

Husky :)

 

NB: Work I've referenced http://www.minecraftforge.net/wiki/How_to_use_infinite_terrain_and_sprite_indexes

 

This is actually really simple, don't get discouaged. Texture files have mini texture tiles of 16 rows of 16. if you start numbering them from the top left to the bottom right, these are the numbers that are expected to be returned. The code depends on the way you set up your texture file, and which side needs which texture, but in the method:

getTextureFromSideAndMetadata(int i, int j) the two variables are, as expected side and metadata, in that order.

 

From this info, you can figure out which texture index you need to return. The actual texture file is retrieved by the renderer by your getTextureFile() method you need to override.

 

 

Link to comment
Share on other sites

Simple as that... >.< 

 

Haha, I guess I've been battling with it for long enough I expect it to be more difficult.  Can't wait to get home and try this out!  Have a relaxing day of VBA programming until then though :P

 

Thanks guys :)  Glad I signed up here now.

 

Husky

 

 

EDIT:

 

So the coding might be like this:

 

public int getBlockTextureFromSide(int sideNumber)
{
    if(sideNumber==0)
        {
            return 6;
        }
    if(sideNumber==1)
        {
            return 7;
        }
    if(sideNumber==2)
        {
            return 8;
        }
    if(sideNumber==3)
        {
            return 9;
        }
    Else
        {
            return 10;
}
}

 

I'm quite new to Java programming and wrote the above in notepad so forgive any errors.  I'm wondering if there is more elegant way of writing this, perhaps select case?  I found some code by googling, adapted it, and wonder if this is right?

 

public int getBlockTextureFromSide(int sideNumber)
{
    Switch (sideNumber)
    {
        Case 0:
            return 6;
        Case 1:
            return 7;
        Case 2:
            return 8;
        Case 3:
            return 9;
        Case 4:
        Case 5:
        default:
            return 10;
    }
}

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



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.