Jump to content

Custom Textures MultiItemBlock [1.3.2]


Zhor

Recommended Posts

hey guys,

 

i just made some custom fences with the help of the wiki-article MultiBlocks (see http://www.minecraftforge.net/wiki/Tutorials/Multiblock).

 

for this i created a class "MultiFence" with the following code:

 

public class MultiFence extends BlockFence{

/* public MultiFence (int id) {

super(id, Material.ground);

 

setCreativeTab(CreativeTabs.tabDeco);

}*/

 

public MultiFence(int par1)

    {

super(par1, Material.wood);

//this.blockIndexInTexture=

//super(par1, 0, Material.wood);

        setBlockName("multiFence");

        this.setCreativeTab(CreativeTabs.tabDeco);

    }

 

 

    public MultiFence(int par1, int par2, Material par3Material)

    {

        super(par1, par2, par3Material);

    setBlockName("multiFence");

        this.setCreativeTab(CreativeTabs.tabDeco);

    }

 

@Override

public int getBlockTextureFromSideAndMetadata (int side, int metadata) {

 

return metadata;

 

}

 

@Override

public String getTextureFile() {

    return "/blocks.png";

    }

 

@Override

public int damageDropped (int metadata) {

return metadata;

}

 

@SideOnly(Side.CLIENT)

public void getSubBlocks(int par1, CreativeTabs tab, List subItems) {

for (int ix = 0; ix < 16; ix++) {

subItems.add(new ItemStack(this, 1, ix));

}

}

 

public static boolean isIdAFence(int par0)

    {

        return true;

    }

 

 

the class MultiItemBlock:

 

public class MultiItemBlock extends ItemBlock {

private final static String[] subNames = {

"white", "orange",  "magenta", "lightBlue", "yellow", "lightGreen",

"pink", "darkGrey", "lightGrey", "cyan", "purple", "blue", "brown",

"green", "red", "black"

};

 

public MultiItemBlock(int id) {

super(id);

setHasSubtypes(true);

setItemName("multiFence");

}

 

@Override

public int getMetadata (int damageValue) {

return damageValue;

}

 

@Override

public String getItemNameIS(ItemStack itemstack) {

return getItemName() + "." + subNames[itemstack.getItemDamage()];

}

 

 

and i even modified the BlockFence.java, i added my constructor to fit in the tutorial-parameters.

FYI, BlockFence doesnt have a contructor, that takes only the id and the material as parameters.

 

 

public BlockFence(int par1, Material par2Material){

    super(par1, par2Material);

    this.setCreativeTab(CreativeTabs.tabDeco);

    }

 

 

 

I set the MultiFence as a subclass of BlockFence to get the typical Fence-behavior and the right texture-rendering. I dont think it is possible to manage it without being subclass of BlockFence.

I really followed all the other steps in the Tutorial.

So here the Problem:

 

While the textures of the fences are perfectly fine block, the inventory takes only one particular texture for all fences.

If i change the MultiFence class to extend Block (instead of BlockFence), the inventory works fine, but (ofc.) the Fences are normal Blocks.

How can i set the ItemBlock textures to fit the texture of the Block itself?

 

Below are 2 screenshots of exact the same situation. First having MultiFence extends Block, second extends BlockFence.

 

Thanks,

 

Zhor

Link to comment
Share on other sites

Are you sure you registered a seperate item instance for your BlockFence?

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

not quite sure what you mean ;)

i only registered it like that:

GameRegistry.registerBlock(multiFence, MultiFenceItemBlock.class);

 

and for each color its own itemstack:

for (int ix = 0; ix < 16; ix++) {
		ItemStack multiBlockStack = new ItemStack(multiFence, 1, ix);
...}

Link to comment
Share on other sites

You make a few mistakes,

1. When you use multiBlocks it use the Metadata to store the 16 diff Blocks, Crops, Stairs & Fences use the Metadata to store the direction, so it will not work.

2. in your Block Class:

public MultiFence(int par1, int texture)
    {   
      super(par1, Material.wood);
      this.blockIndexInTexture= texture
      //super(par1, 0, Material.wood);
        setBlockName("multiFence");
        this.setCreativeTab(CreativeTabs.tabDeco);
    }

Then you give the texture ID in the Block declaration.

then in :

   @Override
   public int getBlockTextureFromSideAndMetadata (int side, int metadata) {
      
      return blockIndexInTexture + metadata;
      
   }

but how i told you multi Blocks never work when the Block use the Metadata

 

The render in the Inventory not work, i think it´s because you render the Fence not a normal Block, you must say him how to render this in the Inventory. i hope this is correct, but think you must use some code like you do with custom Render Blocks

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.