Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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.

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.

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);
    }
}

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"?

OK, I am going to try that out and report back afterwards.

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.

I got it working now. Thank you for your help.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.