Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

public int getBlockTextureFromSide(int i);

 

This is a method that can go in your block class. You should say if(i == x) return y; With x being the side (a number between 0 and 5) and y being the sprite index (a number between 0 and 255).

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.

 

 

  • Author

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

yes, well:

Case 4:

Case 5:

default:

    return 10;

is redundant. default means everything else, and cases will do the code in the next case unless you break or return, so you can remove the last two cases and it would do the same thing.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.