Jump to content

[1.7.10]check oredictonairy name of block


Recommended Posts

i tried this but it didnt work


public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)

Block block = world.getBlock(x, y, z);
String name=block.blockRegistry.getNameForObject(block);

int metadata = world.getBlockMetadata(x, y, z);

	if(stack != null)

		if (name == "blockGlassColorless")

			world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(block, 1)));
			world.setBlockToAir(x, y, z);
			return true;


return false;

Link to comment
Share on other sites



just after getting the name, have a look at the way the names are formated


also if the block you are testing for is always going to be the same type there is another way

if its a minecraft block you will find them defined in Blocks , example  Blocks.stained_glass_pane

if its one of your blocks, define them as public static and you can compare directly from your Blocks class




here is a block and an item as defined in one of my mods


public class MagicEnchantItems {
public static Item rainbowdust = new QuickItem("rainbow_dust","itemdust_rainbow");
public static Block magicenchantmenttable = new BlockMagicTable();
public static void init() {
	GameRegistry.registerItem(rainbowdust, "itemdust");
	GameRegistry.registerBlock(magicenchantmenttable, "magicenchantmenttable");

i can compair like this

  if (block==MagicEnchantItems.magicenchantmenttable){


Link to comment
Share on other sites

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.

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.

  • Create New...

Important Information

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