Posted August 21, 201411 yr 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?
August 21, 201411 yr 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);
August 21, 201411 yr Author 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;
August 21, 201411 yr Try passing the block you want to check and the block you want to match as itemstacks to OreDictionary.itemMatches(targetBlock, inputBlock, false).
August 21, 201411 yr Author 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
August 22, 201411 yr 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.