Jump to content

Multi-sided block textures not working


Eria8

Recommended Posts

I'm trying to get a block with a texture for sides, top and bottom. But all sides are always the side texture.

I've followed several tutorials but it's just not working. This is my code. What am I doing wrong?

 

package com.pixelmoncore.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;

import com.pixelmoncore.main.Main;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class Wall extends Block
{

@SideOnly(Side.CLIENT)
public IIcon topIcon;
@SideOnly(Side.CLIENT)
public IIcon bottomIcon;

@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
	return side == 1 || side == 0 ? this.topIcon : (side == 4 ? this.bottomIcon : this.blockIcon);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
	this.blockIcon = iconRegister.registerIcon(Main.modid + ":" + "wallSide");
	this.topIcon = iconRegister.registerIcon(Main.modid + ":" + "wallTop");
	this.bottomIcon = iconRegister.registerIcon(Main.modid + ":" + "wallBottom");
}





public Wall()
{
	super(Material.rock);
	this.setHardness(2F);
	this.setResistance(20F);
}
    public void setHarvestLevel(String toolClass, int level)
    {
        for (int m = 0; m < 16; m++)
        {
            setHarvestLevel("pickaxe", 2);
        }
    }

}

Link to comment
Share on other sites

Hi

 

I don't see any obvious problem there.

 

Perhaps you have accidentally made your three icon files the same?

Have you given your block a name?

 

I would suggest you put a breakpoint into getIcon to see whether it gets called with different side values and returns the correct icon.  This should give you a clue to eliminate a bunch of possible causes.

Alternatively

@Override
public IIcon getIcon(int side, int metadata)
{
           IIcon retval = side == 1 || side == 0 ? this.topIcon : (side == 4 ? this.bottomIcon : this.blockIcon);
           System.out.println("Side: " + side + " = " + retval);
           return  retval;
}

As a general rule it's a good idea to put @Override before methods you are trying to override from a base class, can help pick up subtle mistakes.

 

-TGG

Link to comment
Share on other sites

I tested your code and It works fine, as TheGreyGhost said, maybe you simply just made all your textures the same.

By the way I would recommend you to shorten your file a bit by replacing:

    public void setHarvestLevel(String toolClass, int level)
    {
        for (int m = 0; m < 16; m++)
        {
            setHarvestLevel("pickaxe", 2);
        }
    }

 

with one line in the constructor:

this.setHarvestLevel("pickaxe", 2);

If I helped please press the Thank You button.

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.