Jump to content

Recommended Posts

Posted

I'm adding a sapling class with twelve different sub-blocks. The saplings show the correct texture when placed in the world, but when in the inventory they always show the icon of the first sapling.

 

I've checked and getIcon() is always being given a metadata value of zero. If I change meta to any other appropriate number then that sapling's icon is shown. I cannot figure out why this is happening. I do the exact same thing with my leaves and logs and it works great.

 

Sapling class:

package arrowsplus;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
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 BlockArrowTreeSapling extends BlockFlower
{
public static final String[] woodType = new String[] {"aspen", "cottonwood", "alder", "sycamore", "gum", "softmaple",
	"ash", "beech", "hardmaple", "hickory", "mahogany", "sypherus"};
    @SideOnly(Side.CLIENT)
    private Icon[] saplingIcon;

    protected BlockArrowTreeSapling(int par1)
    {
        super(par1);
        this.setCreativeTab(ArrowsPlus.instance.tabArrowsPlus);
        this.setTickRandomly(true);
    }

@Override
public Block func_111022_d(String par1Str)
{
	this.field_111026_f = "arrowsPlus:tree";
	return this;
}

    @SideOnly(Side.CLIENT)
    public Icon getIcon(int side, int meta)
    {
    	//-----------------> Meta is always zero.
        return this.saplingIcon[meta];
    }

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

    @SideOnly(Side.CLIENT)
    public void getSubBlocks(int itemId, CreativeTabs creativeTab, List listSubBlocks)
    {
	listSubBlocks.add(new ItemStack(itemId, 1, 0));
	listSubBlocks.add(new ItemStack(itemId, 1, 1));
	listSubBlocks.add(new ItemStack(itemId, 1, 2));
	listSubBlocks.add(new ItemStack(itemId, 1, 3));
	listSubBlocks.add(new ItemStack(itemId, 1, 4));
	listSubBlocks.add(new ItemStack(itemId, 1, 5));
	listSubBlocks.add(new ItemStack(itemId, 1, 6));
	listSubBlocks.add(new ItemStack(itemId, 1, 7));
	listSubBlocks.add(new ItemStack(itemId, 1, );
	listSubBlocks.add(new ItemStack(itemId, 1, 9));
	listSubBlocks.add(new ItemStack(itemId, 1, 10));
	listSubBlocks.add(new ItemStack(itemId, 1, 11));
    }

    @SideOnly(Side.CLIENT)
    public void registerIcons(IconRegister iconRegister)
    {
	this.saplingIcon = new Icon[woodType.length];
	for (int i = 0; i < this.saplingIcon.length; ++i)
	{
		this.saplingIcon[i] = iconRegister.registerIcon(this.func_111023_E() + "_" + woodType[i] + "_sapling");
	}
    }
   
}

 

They are registered as such in preInit()

		blockArrowTreeSapling = new BlockArrowTreeSapling(modPropertiesManager.modProperties.blockId_ArrowLogSapling).func_111022_d("tree");
	GameRegistry.registerBlock(blockArrowTreeSapling, ItemBlockSapling.class, "Arrow Saplings");

	for (int i = 0; i < 12; i++)
	{
		ItemStack saplingStack = new ItemStack(blockArrowTreeSapling, 1, i);
		LanguageRegistry.addName(saplingStack, saplingNames[i]);
	}

 

The ItemBlock for the saplings

package arrowsplus;

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

public class ItemBlockSapling extends ItemBlock
{
public static final String[] saplingNames = new String[] {"Aspen Sapling", "Cottonwood Sapling", "Alder Sapling", "Sycamore Sapling", "Gum Sapling", "Soft Maple Sapling",
	"Ash Sapling", "Beech Sapling", "Hard Maple Sapling", "Hickory Sapling", "Mahogany Sapling", "Sypherus Sapling"};

public ItemBlockSapling(int id) 
{
	super(id);
	setHasSubtypes(true);
	setUnlocalizedName("ItemBlockSapling");
}

@Override
public int getMetadata(int damageValue) 
{
	ArrowsPlus.instance.log(damageValue);
	return damageValue;
}

    public String getUnlocalizedName(ItemStack par1ItemStack)
    {
        return saplingNames[par1ItemStack.getItemDamage()];
    }
}

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
    • Maybe you need to create file in assets/<modid>/items/<itemname>.json with content like this:   { "model": { "type": "minecraft:model", "model": "modname:item/itemname" } }  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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