Jump to content

Block textures not loading


Recommended Posts

Posted

I am trying to add textures to my blocks, but they don't load. I don't get missing texture errors in the log.

Posted

You're using the wrong version (or the wrong technique for the version you have).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

I am using MC 1.7.10.

 

This is the base block class:

package XFactHD.thermalreactors.common.blocks;

import XFactHD.thermalreactors.ThermalReactors;
import XFactHD.thermalreactors.common.util.Reference;

import cofh.api.block.IDismantleable;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

import java.util.ArrayList;
import java.util.List;

public abstract class BlockBaseTR extends BlockContainer implements IDismantleable
{
    public String name;
    public String[] subNames;
    public final IIcon[][] icons;

    public BlockBaseTR(String name, Material mat, int iconDimensions, Class<? extends ItemBlockBaseTR> itemblock, String... subNames)
    {
        super(mat);
        this.subNames = subNames;
        this.name = name;
        this.icons = new IIcon[subNames.length][iconDimensions];
        this.setBlockName(Reference.MOD_ID + ":" + name);
        GameRegistry.registerBlock(this, itemblock, name);
        this.setCreativeTab(ThermalReactors.creativeTab);
    }

    @Override
    public int damageDropped(int meta)
    {
        return meta;
    }
    @Override
    public void getSubBlocks(Item item, CreativeTabs tab, List list)
    {
        for(int i=0; i<subNames.length; i++)
        {
            list.add(new ItemStack(item, 1, i));
        }
    }

    @Override
    public void registerBlockIcons(IIconRegister iconRegister)
    {
        for(int i=0;i<subNames.length;i++)
            icons[i][0] = iconRegister.registerIcon(Reference.MOD_ID + ":" + name + "_" + subNames[i]);
    }

    @Override
    public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z)
    {
        return false;
    }

    @Override
    public boolean canDismantle(EntityPlayer entityPlayer, World world, int i, int i1, int i2)
    {
        return false;
    }

    @Override
    public ArrayList<ItemStack> dismantleBlock(EntityPlayer entityPlayer, World world, int x, int y, int z, boolean b)
    {
        return null;
    }
}

This is one of the extending block classes:

package XFactHD.thermalreactors.common.blocks.stone;

import XFactHD.thermalreactors.common.blocks.BlockSimpleTR;
import XFactHD.thermalreactors.common.blocks.ItemBlockBaseTR;

import net.minecraft.block.material.Material;

public class BlockOre extends BlockSimpleTR
{
    public BlockOre()
    {
        super("ore", Material.rock, ItemBlockBaseTR.class, "Uranium", "Zirconium");
        setHardness(0.5F);
    }
}

Posted

But I am using the registerBlockIcons() method:

    @Override
    public void registerBlockIcons(IIconRegister iconRegister)
    {
        for(int i=0;i<subNames.length;i++)
            icons[i][0] = iconRegister.registerIcon(Reference.MOD_ID + ":" + name + "_" + subNames[i]);
    }

Or is that what you mean by "filling the array"?

Posted

You're using the wrong version (or the wrong technique for the version you have).

How can you know? There is no information provided at all.

Exactly, which I took as license to use my imagination. I imagined that the author had watched the wrong tutorial for the Forge version he had.

 

Instead, it looks like he just missed a step. I think that each simple block in 1.7 needs to call setBlockTextureName. However, a block with subtypes has needs to override getIcon instead:

 

  @Override
  @SideOnly(Side.CLIENT)
  public IIcon getIcon(int side, int meta) {...}

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.