Jump to content

Multi-Texture Block


MateuszKam7

Recommended Posts

I tried to make a block (grass), which has multiple textures. The block i made says "Missing Texture" all over it... Does anyone know how to make this? Here is my code:

package mods.MattCraft.Common;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.Icon;
import net.minecraft.world.ColorizerGrass;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class ZGrassBlock extends Block
{
    private Icon ZGrassTop;
    private Icon ZGrassSide;
    private Icon ZDirtBlock;
    

    protected ZGrassBlock(int par1)
    {
        super(par1, Material.ground);
        this.setTickRandomly(true);
        this.setCreativeTab(CreativeTabs.tabBlock);
   
    }
    public int idDropped(int par1, Random par2Random, int par3)
    {
        return MattCraftMain.ZDirt.idDropped(0, par2Random, par3);
    }

    @SideOnly(Side.CLIENT)

    /**
     * When this method is called, your block should register all the icons it needs with the given IconRegister. This
     * is the only chance you get to register icons.
     */
    public void registerIcons(IconRegister reg){
    	this.blockIcon = reg.registerIcon("MattCraft:ZGrassTop");
    	this.blockIcon = reg.registerIcon("MattCraft:ZGrassSide");
    	this.blockIcon = reg.registerIcon("MattCraft:ZDirtBlock");

    }
    @SideOnly(Side.CLIENT)
    public Icon getBlockTextureFromSideAndMetadata(int i, int j)
    {
            if (i == 0)
            {
                    return ZDirtBlock;
            }
            if (i == 1)
            {
                    return ZGrassTop;
            }
            else
            {
                    return ZGrassSide;
            }
    }
    
    

}

 

Link to comment
Share on other sites

I tried to make a block (grass), which has multiple textures. The block i made says "Missing Texture" all over it... Does anyone know how to make this? Here is my code:

package mods.MattCraft.Common;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.Icon;
import net.minecraft.world.ColorizerGrass;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class ZGrassBlock extends Block
{
    private Icon ZGrassTop;
    private Icon ZGrassSide;
    private Icon ZDirtBlock;
    

    protected ZGrassBlock(int par1)
    {
        super(par1, Material.ground);
        this.setTickRandomly(true);
        this.setCreativeTab(CreativeTabs.tabBlock);
   
    }
    public int idDropped(int par1, Random par2Random, int par3)
    {
        return MattCraftMain.ZDirt.idDropped(0, par2Random, par3);
    }

    @SideOnly(Side.CLIENT)

    /**
     * When this method is called, your block should register all the icons it needs with the given IconRegister. This
     * is the only chance you get to register icons.
     */
    public void registerIcons(IconRegister reg){
    	this.blockIcon = reg.registerIcon("MattCraft:ZGrassTop");
    	this.blockIcon = reg.registerIcon("MattCraft:ZGrassSide");
    	this.blockIcon = reg.registerIcon("MattCraft:ZDirtBlock");

    }
    @SideOnly(Side.CLIENT)
    public Icon getBlockTextureFromSideAndMetadata(int i, int j)
    {
            if (i == 0)
            {
                    return ZDirtBlock;
            }
            if (i == 1)
            {
                    return ZGrassTop;
            }
            else
            {
                    return ZGrassSide;
            }
    }
    
    

}

 

Link to comment
Share on other sites

you never set the texture ZGrassTop to anything.

You set the blockIcon variable to 3 different things, meaning it will have the latest value you gave it.

 

this.blockIcon = reg.registerIcon("MattCraft:ZGrassTop");
this.ZGrassTop= reg.registerIcon("MattCraft:ZGrassTop");
     this.ZGrassSide= reg.registerIcon("MattCraft:ZGrassSide");
     this.ZDirtBlock= reg.registerIcon("MattCraft:ZDirtBlock");

 

And it should work

 

 

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

you never set the texture ZGrassTop to anything.

You set the blockIcon variable to 3 different things, meaning it will have the latest value you gave it.

 

this.blockIcon = reg.registerIcon("MattCraft:ZGrassTop");
this.ZGrassTop= reg.registerIcon("MattCraft:ZGrassTop");
     this.ZGrassSide= reg.registerIcon("MattCraft:ZGrassSide");
     this.ZDirtBlock= reg.registerIcon("MattCraft:ZDirtBlock");

 

And it should work

 

 

If you guys dont get it.. then well ya.. try harder...

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.