Jump to content

Recommended Posts

Posted

hello

 

i was wondering if there was a way to check the oredictonairy name of an block.

 

and when i know that how do you check if it has like een spefific part in that name?

 

 

 

Posted

to get the name of an Item use (i use this)

 

String name=Item.itemRegistry.getNameForObject(item);

 

try this for blocks (I havn't tested it)

 

String name=Block.blockRegistry.getNameForObject(block);

Posted

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);
player.swingItem();
if(!world.isRemote)
{

	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;

Posted

Try passing the block you want to check and the block you want to match as itemstacks to OreDictionary.itemMatches(targetBlock, inputBlock, false).

could you give me and examle of the block to itemstack sting.

i have no clue

Posted

add

System.out.println(name);

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

 

example

 

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){

 

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.