Jump to content

Recommended Posts

Posted

I have a problem with the block metadata textures. All the textures appear correct while in your inventory, but when you place them they all have the same texture, being the first block's texture. I don't know what I'm doing wrong. :P Here's my block file:

package com.eastonium.bionicle.blocks;

import java.util.List;

import com.eastonium.bionicle.Bionicle;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;

public class BlockKoro extends Block
{
public static final String[] stoneBlockNames = new String[] {"Onu_1", "Onu_2", "Po_1", "Po_2", "Ta_1", "Ta_2", "Ta_3", "Trdx_1", "Trdx_2"};
public static final String[] litBlockNames = new String[] {"Onu_1", "Ta_0"};
public static final String[] iceBlockNames = new String[] {"Ko_1", "Ko_2"};
public static final String[] leafyBlockNames = new String[] {"Ga_1", "Ga_2", "Ga_3"};
    @SideOnly(Side.CLIENT)
    private IIcon[] icons;

public BlockKoro(Material blockMaterial) 
{
	super(blockMaterial);
	this.setCreativeTab(Bionicle.bioBlockTab);
}

@Override
@SideOnly(Side.CLIENT)
    public IIcon getIcon(int par1, int par2)
    {
        if (par2 < 0 || par2 >= this.icons.length)
        {
            par2 = 0;
        }
        return this.icons[par2];
    }

@Override
public int damageDropped(int damage)
    {
        return damage;
    }

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
@SideOnly(Side.CLIENT)
    public void getSubBlocks(Item block, CreativeTabs creativeTabs, List list)
    {
	int type = (this.getMaterial() == Material.rock ? 9 : (this.getMaterial() == Material.leaves ? 3 : 2));
	for(int i = 0; i < type; i++)
	{
		list.add(new ItemStack(block, 1, i));
	}        
    }

@Override
@SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister iconRegisterer)
    {
	int type = (this.getMaterial() == Material.rock ? 9 : (this.getMaterial() == Material.leaves ? 3 : 2));
        this.icons = new IIcon[type];

        for (int i = 0; i < this.icons.length; ++i)
        {
        	if(this.getMaterial() == Material.rock){
        		this.icons[i] = iconRegisterer.registerIcon(Bionicle.MODID + ":" + stoneBlockNames[i]);
        	}else if(this.getMaterial() == Material.redstoneLight){
        		this.icons[i] = iconRegisterer.registerIcon(Bionicle.MODID + ":" + litBlockNames[i]);
        	}else if(this.getMaterial() == Material.packedIce){
        		this.icons[i] = iconRegisterer.registerIcon(Bionicle.MODID + ":" + iceBlockNames[i]);
        	}else if(this.getMaterial() == Material.leaves){
        		this.icons[i] = iconRegisterer.registerIcon(Bionicle.MODID + ":" + leafyBlockNames[i]);
        	}
        }
    }
}

Posted

the par2 in getIcon is the metadata, so I am accounting for it. the blocks don't have different textures on the sides.

Ah, yeah so it is.  I have them swapped in my helper function for some reason, sorry about that.

 

I'm guessing then that your block is always being placed with metadata 0.

Have you registered the Blocks correctly?  i.e. are you using ItemBlockWithMetadata, not just ItemBlock?  (or alternatively - your own Item extend ItemBlock overriding getMetadata() )?

 

-TGG

 

 

 

 

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.