Posted December 15, 201311 yr 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
December 15, 201311 yr 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!
December 15, 201311 yr 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/
December 15, 201311 yr Hi There is a whole bunch of information in here on item rendering including some sample code to do exactly what you want... http://greyminecraftcoder.blogspot.com.au/p/list-of-topics.html See the sections under "Items". -TGG
December 17, 201311 yr 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.