Dimension-based textures (Nether and End ores, anyone?)

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

SatanicSanta

New Member
Jul 29, 2019
4,849
-3
0
Alright, so a lot of people tend to make separate ores for the separate dimensions. This isn't really necessary. You can generate the exact same ores in different dimensions. "But what about textures?" you may ask, to which I will reply with arrays and if statements.

Now, enough blabbering, here is some example code I just wrote for the next Flaxbeard's Steam Power update

Code:
public class BlockSteamcraftOre extends Block {

    public IIcon[] icon = new IIcon[7];

    public BlockSteamcraftOre() {
        super(Material.rock);
        setResistance(5.0F);
        setHardness(1.5F);
        setStepSound(Block.soundTypeStone);
    }

    @Override
    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister ir) {
        this.icon[0] = ir.registerIcon("steamcraft:oreCopper");
        this.icon[1] = ir.registerIcon("steamcraft:oreZinc");
        this.icon[2] = ir.registerIcon("steamcraft:poorOreZinc");
        this.icon[3] = ir.registerIcon("steamcraft:copper_nether");
        this.icon[4] = ir.registerIcon("steamcraft:zinc_nether");
        this.icon[5] = ir.registerIcon("steamcraft:copper_end");
        this.icon[6] = ir.registerIcon("steamcraft:zinc_end");

    }

    @SideOnly(Side.CLIENT)
    @Override
    public IIcon getIcon(int par1, int par2) {
        int dimensionID = Minecraft.getMinecraft().theWorld.provider.dimensionId;

        if (dimensionID == 0) {
            if (par2 == 0) {
                return this.icon[0];
            }
            if (par2 == 1) {
                return this.icon[1];
            }
            if (par2 == 2) {
                return this.icon[2];
            }
        }

        if (dimensionID == -1){
            if (par2 == 0){
                return this.icon[3];
            }
            if (par2 == 1){
                return this.icon[4];
            }
        }

        if (dimensionID == 1){
            if (par2 == 0){
                return this.icon[5];
            }
            if (par2 == 1){
                return this.icon[6];
            }
        }
        return this.icon[0];
    }

    @SideOnly(Side.CLIENT)
    public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
        par3List.add(new ItemStack(par1, 1, 0));
        par3List.add(new ItemStack(par1, 1, 1));
        if (Loader.isModLoaded("Railcraft") && Config.genPoorOre) {
            par3List.add(new ItemStack(par1, 1, 2));
        }
    }

As you can see, there are only 3 metadata blocks: Copper, Zinc, and Poor Zinc.

As you can also see, there is an array of 7, each icon in the array is a new texture. I still don't know how to dynamically /create/ textures. Then, it just checks what dimension it's at with Minecraft.getMinecraft().theWorld.provider.dimensionId. It even works with the blocks in your inv! As soon as you exit that dimension, it'll change the texture.

Just thought yall should know about this :)

Edit:
Because it was requested, pics:
2014-11-06_00.34.35.png 2014-11-06_00.33.48.png 2014-11-06_00.35.20.png
 
Last edited:
C

chbachman

Guest
I still don't know how to dynamically /create/ textures.

Code from Railcraft Ores, should help you. Source.

Code:
@Override
public IIcon getIcon(int side, int meta) {
    if (renderPass == 0)
      switch (EnumOre.fromMeta(meta)) {
      case SALTPETER:
         return Blocks.sandstone.getIcon(ForgeDirection.DOWN.ordinal(), 0);
      case FIRESTONE:
         return Blocks.netherrack.getIcon(0, 0);
      case DARK_DIAMOND:
      case DARK_EMERALD:
      case DARK_LAPIS:
         IIcon icon = EnumCube.ABYSSAL_STONE.getIcon();
      if (icon != null)
         return icon;
      default:
         return Blocks.stone.getIcon(side, 0);
   }
   return EnumOre.fromMeta(meta).getTexture(side);
}
 
  • Like
Reactions: SatanicSanta

SatanicSanta

New Member
Jul 29, 2019
4,849
-3
0
Code from Railcraft Ores, should help you. Source.

Code:
@Override
public IIcon getIcon(int side, int meta) {
    if (renderPass == 0)
      switch (EnumOre.fromMeta(meta)) {
      case SALTPETER:
         return Blocks.sandstone.getIcon(ForgeDirection.DOWN.ordinal(), 0);
      case FIRESTONE:
         return Blocks.netherrack.getIcon(0, 0);
      case DARK_DIAMOND:
      case DARK_EMERALD:
      case DARK_LAPIS:
         IIcon icon = EnumCube.ABYSSAL_STONE.getIcon();
      if (icon != null)
         return icon;
      default:
         return Blocks.stone.getIcon(side, 0);
   }
   return EnumOre.fromMeta(meta).getTexture(side);
}
Honestly, unless I do some crazy GregTech-like metaitem thing, I'm not interested in dynamically created textures, just because it doesn't allow the same control as making my own textures in Photoshop does.
 
  • Like
Reactions: 1SDAN and chbachman

SatanicSanta

New Member
Jul 29, 2019
4,849
-3
0
Hey Santa, why do you only set the icon for poor Zinc ore in the overworld? In the nether and end your code seems to just return the default of overworld Copper Ore which seems wrong.
I actually completely forgot about poor ore... I'll fix it right nowFixed :p
 
Last edited:

VapourDrive

New Member
Jul 29, 2019
536
-8
1
Honestly, unless I do some crazy GregTech-like metaitem thing, I'm not interested in dynamically created textures, just because it doesn't allow the same control as making my own textures in Photoshop does.
ehem, GIMP or Inkscape - opensource software ftw! ;)
 
  • Like
Reactions: 1SDAN

VapourDrive

New Member
Jul 29, 2019
536
-8
1
And so much more expensive. Plus PS' production quality is definitely a bigger plus than its power in terms of what it has over GIMP. If I had hundreds of dollars lying around....
 
  • Like
Reactions: 1SDAN