Posted June 18, 20196 yr I want to check if an item contains certain OreDictionary. Something like: If(ThisItem.OreDictionary.contains("oreCopper"){ } Is it possible? Edited June 18, 20196 yr by Focamacho
June 19, 20196 yr Author I'm having trouble comparing one item and another. get right-clicked block: public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){ ItemStack itemstack = player.getHeldItem(hand); IBlockState iblockstate = worldIn.getBlockState(pos); Block block = iblockstate.getBlock(); ItemStack blockItem = new ItemStack(block); get oredictionary: public static final List<ItemStack> logWood = OreDictionary.getOres("logWood"); comparing right-clicked block & oredictionary: public boolean checkBlockOreDict(ItemStack blockItem, List<ItemStack> oreDict) { System.out.println("OreDict: " + oreDict); System.out.println("Block right-clicked: " + blockItem); for(ItemStack item : oreDict) { if(blockItem.isItemEqualIgnoreDurability(item)) { System.out.println("Match: yes"); return true; } } System.out.println("Match: no"); return false; } console output:
June 19, 20196 yr Author It's working fine now with vanilla logs, but for some reason it don't works with Biomes o plenty logs. New code: public boolean checkBlockOreDict(ItemStack blockItem, NonNullList<ItemStack> oreDict) { System.out.println("OreDict: " + oreDict); System.out.println("Block right-clicked: " + blockItem); for(ItemStack item : oreDict) { System.out.println("Testing now: " + item); if(OreDictionary.itemMatches(item, blockItem, false)) { System.out.println("Match: yes"); return true; } } System.out.println("Match: no"); return false; } Console Output: Spoiler Vanilla Wood: [15:29:36] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:112]: OreDict: [1xtile.log@32767, 1xtile.log@32767, 1xtile.log_0@4, 1xtile.log_0@5, 1xtile.log_0@6, 1xtile.log_0@7, 1xtile.log_1@4, 1xtile.log_1@5, 1xtile.log_1@6, 1xtile.log_1@7, 1xtile.log_2@4, 1xtile.log_2@5, 1xtile.log_2@6, 1xtile.log_2@7, 1xtile.log_3@4, 1xtile.log_3@5, 1xtile.log_3@6, 1xtile.log_3@7, 1xtile.log_4@4, 1xtile.log_4@5] [15:29:36] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:113]: Block right-clicked: 1xtile.log@0 [15:29:36] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log@32767 [15:29:36] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:117]: Match: yes Biomes o Plenty Wood: [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:112]: OreDict: [1xtile.log@32767, 1xtile.log@32767, 1xtile.log_0@4, 1xtile.log_0@5, 1xtile.log_0@6, 1xtile.log_0@7, 1xtile.log_1@4, 1xtile.log_1@5, 1xtile.log_1@6, 1xtile.log_1@7, 1xtile.log_2@4, 1xtile.log_2@5, 1xtile.log_2@6, 1xtile.log_2@7, 1xtile.log_3@4, 1xtile.log_3@5, 1xtile.log_3@6, 1xtile.log_3@7, 1xtile.log_4@4, 1xtile.log_4@5] [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:113]: Block right-clicked: 1xtile.log_2@0 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log@32767 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log@32767 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_0@4 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_0@5 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_0@6 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_0@7 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_1@4 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_1@5 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_1@6 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_1@7 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_2@4 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_2@5 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_2@6 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_2@7 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_3@4 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_3@5 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_3@6 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_3@7 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_4@4 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:115]: Testing now: 1xtile.log_4@5 [15:32:27] [Server thread/INFO] [STDOUT]: [com.focamacho.mysticaladaptations.items.SeedExtractor:checkBlockOreDict:121]: Match: no Edited June 19, 20196 yr by Focamacho
June 19, 20196 yr Quote Block right-clicked: 1xtile.log_2@0 Because of the way you wrote your code ("take the current block state, discard its metadata, create an item stack"), you created a block that doesn't exist. Notice how your oredict code loops over several metadata values for the same block: Quote 1xtile.log_2@4 1xtile.log_2@5 1xtile.log_2@6 1xtile.log_2@7 But that none of those are the same as what you said you right clicked. This is why PickBlock() exists. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.