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

Hi all,

I have a block I'm making, and it has a custom model.  I don't want it to be 3D in the inventory (I know how to do this and have done it before, but don't want to).  Is there any way to bind just a 16x16 texture to a block when it appears in your inventory?

Thanks,

Ninjapancakes87

Try making an item which places the block. Then just remove the block's creative visibility and use the item instead. Use this code:

 

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

public class ItemBlockPlacer extends Item
{
    public int blockID;
    public String textureName;

    public ItemFlintAndSteel(int par1, String textureName, int blockID)
    {
        super(par1);
        this.blockID = blockID;
    }

    /**
     * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
     * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
     */
    public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
    {
        if (par7 == 0)
        {
            --par5;
        }

        if (par7 == 1)
        {
            ++par5;
        }

        if (par7 == 2)
        {
            --par6;
        }

        if (par7 == 3)
        {
            ++par6;
        }

        if (par7 == 4)
        {
            --par4;
        }

        if (par7 == 5)
        {
            ++par4;
        }

        if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack))
        {
            return false;
        }
        else
        {
            if (par3World.isAirBlock(par4, par5, par6))
            {
                par3World.playSoundEffect((double)par4 + 0.5D, (double)par5 + 0.5D, (double)par6 + 0.5D, Block.blocksList[blockID].stepSound.getPlaceSound(), 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
                par3World.setBlock(par4, par5, par6, blockID);
            }

            --par1ItemStack.stackSize;
            return true;
        }
    }

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister ir) {

this.itemIcon = ir.registerIcon(textureName);

}
}

 

and when setting it up in the mod file, type this:

 

myBlockPlacer = new ItemBlockPlacer(/* TODO item ID */, /* TODO texture name e.g. "mymod:myitemplacer" */, myBlock.blockID)/* .setCreativeTab(CreativeTabs.tabBlock) etc. */;

 

Hope I helped!

 

Romejanic

Romejanic

 

Creator of Witch Hats, Explosive Chickens and Battlefield!

For your block to be 3D in your inventory you need an ItemRenderer. If you don't want that, delete the ItemRenderer and just make a texture for it just like you do with normal blocks.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author

Try making an item which places the block. Then just remove the block's creative visibility and use the item instead. Use this code:

 

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

public class ItemBlockPlacer extends Item
{
    public int blockID;
    public String textureName;

    public ItemFlintAndSteel(int par1, String textureName, int blockID)
    {
        super(par1);
        this.blockID = blockID;
    }

    /**
     * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
     * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
     */
    public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
    {
        if (par7 == 0)
        {
            --par5;
        }

        if (par7 == 1)
        {
            ++par5;
        }

        if (par7 == 2)
        {
            --par6;
        }

        if (par7 == 3)
        {
            ++par6;
        }

        if (par7 == 4)
        {
            --par4;
        }

        if (par7 == 5)
        {
            ++par4;
        }

        if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack))
        {
            return false;
        }
        else
        {
            if (par3World.isAirBlock(par4, par5, par6))
            {
                par3World.playSoundEffect((double)par4 + 0.5D, (double)par5 + 0.5D, (double)par6 + 0.5D, Block.blocksList[blockID].stepSound.getPlaceSound(), 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
                par3World.setBlock(par4, par5, par6, blockID);
            }

            --par1ItemStack.stackSize;
            return true;
        }
    }

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister ir) {

this.itemIcon = ir.registerIcon(textureName);

}
}

 

and when setting it up in the mod file, type this:

 

myBlockPlacer = new ItemBlockPlacer(/* TODO item ID */, /* TODO texture name e.g. "mymod:myitemplacer" */, myBlock.blockID)/* .setCreativeTab(CreativeTabs.tabBlock) etc. */;

 

Hope I helped!

 

Romejanic

That's what I was hoping to avoid, but ended up using anyway.  Thanks for the help anyway!

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.