Jump to content

[Solved] Metadata Blocks not registering the names and textures correctly.


SoldierW518

Recommended Posts

I've been working on my new mod More Tools and I've ran into a bump. Whenever I make a Block MetaData Value the Block names aren't registered and the textures aren't all registered. The only thing I get in the console is what I entered in which is that there was an Invalid metadata for fortile.advancedWoodPlanks.

 

moretools.java

package soldierw518.moretools;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;



@Mod(modid = moretools.mod_id, name = moretools.mod_name, version = moretools.mod_version)
@NetworkMod(clientSideRequired = true, serverSideRequired = false)

public class moretools
{
public static final String mod_id = "MoreTools";
public static final String mod_name = "More Tools";
public static final String mod_version = "Alpha 1.4 (Build #005)";

public static Block advancedWoodPlanks;

@PreInit
public void load(FMLPreInitializationEvent event)
{

}

@Init
public void load(FMLInitializationEvent event)
{
	advancedWoodPlanks = new BlockAdvancedWoodPlanks(4000, Material.wood).setUnlocalizedName("advancedWoodPlanks");
	GameRegistry.registerBlock(advancedWoodPlanks, ItemAdvancedWoodPlanks.class, mod_id + (advancedWoodPlanks.getUnlocalizedName().substring(5)));

	LanguageRegistry.addName(new ItemStack(advancedWoodPlanks, 1, 0), "Advanced Oak Wooden Planks");
	LanguageRegistry.addName(new ItemStack(advancedWoodPlanks, 1, 1), "Advanced Spruce Wooden Planks");
	LanguageRegistry.addName(new ItemStack(advancedWoodPlanks, 1, 2), "Advanced Birch Wooden Planks");
	LanguageRegistry.addName(new ItemStack(advancedWoodPlanks, 1, 3), "Advanced Jungle Wooden Planks");
}

@PostInit
public void load(FMLPostInitializationEvent event)
{

}
}

Blocks.java

package soldierw518.moretools;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;

public class Blocks extends Block
{
public Blocks(int id, Material par2Material)
{
	super(id, par2Material);
	this.setCreativeTab(CreativeTabs.tabBlock);
}

public void registerIcons(IconRegister par1IconRegister)
{
	this.blockIcon = par1IconRegister.registerIcon(moretools.mod_id + ":" + (this.getUnlocalizedName().substring(5)));
}
}

BlockAdvancedWoodPlanks.java

package soldierw518.moretools;

import java.util.List;

import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;


public class BlockAdvancedWoodPlanks extends Blocks
{
public BlockAdvancedWoodPlanks(int id, Material par2Material)
{
	super(id, par2Material);
}

@SideOnly(Side.CLIENT)
private Icon[] icons;

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
	icons = new Icon[4];

	for(int i = 0; i < icons.length; i++)
	{
		icons[i] = par1IconRegister.registerIcon(moretools.mod_id + ":" + (this.getUnlocalizedName().substring(5)) + i);
	}
}

@SideOnly(Side.CLIENT)
public Icon getIcon(int par1, int par2)
{
	switch(par2)
	{
		case 0:
				return icons[0];
		case 1:
		{
			switch (par1)
			{
				case 0:
						return icons[1];
				case 1:
						return icons[2];
				default:
						return icons[3];
			}
		}
		default:
		{
			System.out.println("Invalid metadata for" + this.getUnlocalizedName());
			return icons[0];
		}
	}
}

@SideOnly(Side.CLIENT)
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
	for(int j = 0; j < icons.length; j++)
	{
		par3List.add(new ItemStack(par1, 1, j));
	}
}
}

ItemAdvancedWoodPlanks.java

package soldierw518.moretools;

import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;



public class ItemAdvancedWoodPlanks extends ItemBlock
{
public ItemAdvancedWoodPlanks(int par1)
{
	super(par1);
	setHasSubtypes(true);
}

public String getUnlocalizedName(ItemStack itemstack)
{
	String name = "";
	switch(itemstack.getItemDamage())
	{
		case 0:
		{
			name = "world";
				break;
		}
		case 1:
		{
			name = "nether";
			break;
		}
		default: name = "broken";
	}
	return getUnlocalizedName() + "." + name;
}

public int getMetadata(int par1)
{
	return par1;
}
}

 

Any help would be greatly appreciated.

 

Thank you very much for Reading,

 

- Justin (SoldierW518)

Link to comment
Share on other sites

hello it seems that your Block class is wrong cant tell where but here is my working code that you can take a look at:

 

    @SideOnly(Side.CLIENT)
    private Icon[] iconArray;
    
    public Icon getIcon(int par1, int par2)
    {
        return this.iconArray[par2 % this.iconArray.length];
    }
    
    public int damageDropped(int par1)
    {
        return par1;
    }
    @SuppressWarnings("unchecked")
    @SideOnly(Side.CLIENT)
    public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, @SuppressWarnings("rawtypes") List par3List)
    {
        for (int var4 = 0; var4 < 15; ++var4)
        {
            par3List.add(new ItemStack(par1, 1, var4));
        }
    }
   @SideOnly(Side.CLIENT)
    public void registerIcons(IconRegister par1IconRegister)
    {
        this.iconArray = new Icon[16];

        for (int i = 0; i < this.iconArray.length; ++i)
        {
            this.iconArray[i] = par1IconRegister.registerIcon(Reference.MOD_ID + ":" + this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".")+1)+ i);
      

 

ofc you need to change 15 to 3 in my var4

Link to comment
Share on other sites

Thank you very much for the reply but this still didn't solve my problem now the textures load and everything but now my the block with the id of 4000:2 isn't even listed in the creative tabs and the blocks with the id of 4000:2 and 4000:3 still have the same name.

 

Here is my improved code based off of yours:

package soldierw518.moretools;

import java.util.List;

import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;


public class BlockAdvancedWoodPlanks extends Blocks
{
public BlockAdvancedWoodPlanks(int id, Material par2Material)
{
	super(id, par2Material);
}

@SideOnly(Side.CLIENT)
private Icon[] iconArray;

public Icon getIcon(int par1, int par2)
{
	return this.iconArray[par2 % this.iconArray.length];
}

public int damageDropped(int par1)
{
	return par1;
}

@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, @SuppressWarnings("rawtypes") List par3List)
{
	for(int var4 = 0; var4 < 3; ++var4)
	{
		par3List.add(new ItemStack(par1, 1, var4));
	}
}

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
	this.iconArray = new Icon[4];

	for(int i = 0; i < this.iconArray.length; ++i)
	{
		this.iconArray[i] = par1IconRegister.registerIcon(moretools.mod_id + ":" + this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".")+1) + i);
	}
}
}

 

Thank you very much for reading,

 

- Justin (SoldierW518)

Link to comment
Share on other sites

Thank you very much for the reply but this still didn't solve my problem now the textures load and everything but now my the block with the id of 4000:2 isn't even listed in the creative tabs and the blocks with the id of 4000:2 and 4000:3 still have the same name.

 

Here is my improved code based off of yours:

package soldierw518.moretools;

import java.util.List;

import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;


public class BlockAdvancedWoodPlanks extends Blocks
{
public BlockAdvancedWoodPlanks(int id, Material par2Material)
{
	super(id, par2Material);
}

@SideOnly(Side.CLIENT)
private Icon[] iconArray;

public Icon getIcon(int par1, int par2)
{
	return this.iconArray[par2 % this.iconArray.length];
}

public int damageDropped(int par1)
{
	return par1;
}

@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, @SuppressWarnings("rawtypes") List par3List)
{
	for(int var4 = 0; var4 < 3; ++var4)
	{
		par3List.add(new ItemStack(par1, 1, var4));
	}
}

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
	this.iconArray = new Icon[4];

	for(int i = 0; i < this.iconArray.length; ++i)
	{
		this.iconArray[i] = par1IconRegister.registerIcon(moretools.mod_id + ":" + this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".")+1) + i);
	}
}
}

 

Thank you very much for reading,

 

- Justin (SoldierW518)

 

where you do super(id, par2Material); just add:

this.setCreativetab([your tab]

Link to comment
Share on other sites

I added that in my Blocks.java class which the BlockAdvancedWoodPlanks.java class extends. So, it does show 3 of the 4 that I made. So far it shows 4000:0, 4000:1, 4000:2, but just not 4000:3. And 4000:2 and 4000:3 show the same name which is what 4000:3 is suppose to be.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
    • OLXTOTO adalah situs bandar togel online resmi terbesar dan terpercaya di Indonesia. Bergabunglah dengan OLXTOTO dan nikmati pengalaman bermain togel yang aman dan terjamin. Koleksi toto 4D dan togel toto terlengkap di OLXTOTO membuat para member memiliki pilihan taruhan yang lebih banyak. Sebagai situs togel terpercaya, OLXTOTO menjaga keamanan dan kenyamanan para membernya dengan sistem keamanan terbaik dan enkripsi data. Transaksi yang cepat, aman, dan terpercaya merupakan jaminan dari OLXTOTO. Nikmati layanan situs toto terbaik dari OLXTOTO dengan tampilan yang user-friendly dan mudah digunakan. Layanan pelanggan tersedia 24/7 untuk membantu para member. Bergabunglah dengan OLXTOTO sekarang untuk merasakan pengalaman bermain togel yang menyenangkan dan menguntungkan.
    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.