HexNation Posted May 26, 2017 Share Posted May 26, 2017 I'm using the event onItemUse and getting the coordinate of the block im right clicking, how do I get the block from the coordinates Quote Link to comment Share on other sites More sharing options...
bradylox Posted May 26, 2017 Share Posted May 26, 2017 (edited) do you want the cords of the block if so just do F3 then hover over the block your gonna right click the itll show you the cords of that block. Or do u need the id of blocks. Edited May 26, 2017 by bradylox Quote Link to comment Share on other sites More sharing options...
HexNation Posted May 26, 2017 Author Share Posted May 26, 2017 3 minutes ago, bradylox said: do you want the cords of the block if so just do F3 then hover over the block your gonna right click the itll show you the cords of that block. Or do u need the id of blocks. I know the the cords of the block, its just from MC Forge, there use to be some world command that allowed you to grab a block with Coordinates and it 1.11.2 idk what it is/forgot Quote Link to comment Share on other sites More sharing options...
bradylox Posted May 26, 2017 Share Posted May 26, 2017 oh that its this Block block = Block.blocksList[world.getBlockId(i, j, k)]; Quote Link to comment Share on other sites More sharing options...
HexNation Posted May 26, 2017 Author Share Posted May 26, 2017 4 minutes ago, bradylox said: oh that its this Block block = Block.blocksList[world.getBlockId(i, j, k)]; Doesn't work Quote Link to comment Share on other sites More sharing options...
Malkierian Posted May 26, 2017 Share Posted May 26, 2017 (edited) Which version of MC are you modding for? At the very least, 1.10 and above (and probably 1.9, as well), would require you do something like this: Block blockClicked = world.getBlockState(new BlockPos(x, y, z)).getBlock(); EDIT: On top of that, I would think that any method in Item that would give you the block clicked would give you the Block, or at least a BlockPos, not xyz coordinates. Edited May 26, 2017 by Malkierian 1 Quote Link to comment Share on other sites More sharing options...
bradylox Posted May 26, 2017 Share Posted May 26, 2017 okay wait im gonna do a bit of reaserch bc thats supposed to work Quote Link to comment Share on other sites More sharing options...
Malkierian Posted May 26, 2017 Share Posted May 26, 2017 1 minute ago, bradylox said: okay wait im gonna do a bit of reaserch bc thats supposed to work The method you were using was outdated a long time ago when we stopped worrying about block IDs. Quote Link to comment Share on other sites More sharing options...
bradylox Posted May 26, 2017 Share Posted May 26, 2017 Just now, Malkierian said: The method you were using was outdated a long time ago when we stopped worrying about block IDs. Wel its still good to know ids Quote Link to comment Share on other sites More sharing options...
bradylox Posted May 26, 2017 Share Posted May 26, 2017 Do you know the 10 parameters Quote Link to comment Share on other sites More sharing options...
HexNation Posted May 26, 2017 Author Share Posted May 26, 2017 7 minutes ago, Malkierian said: Which version of MC are you modding for? At the very least, 1.10 and above (and probably 1.9, as well), would require you do something like this: Block blockClicked = world.getBlockState(new BlockPos(x, y, z)).getBlock(); EDIT: On top of that, I would think that any method in Item that would give you the block clicked would give you the Block, or at least a BlockPos, not xyz coordinates. It does and it worked public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { System.out.println(world.getBlockState(pos).getBlock()); return EnumActionResult.PASS; } But just another side question, do you know how to do it with say a dropped item on the ground? Quote Link to comment Share on other sites More sharing options...
Malkierian Posted May 26, 2017 Share Posted May 26, 2017 You mean getting the block that a thrown item rests on? Quote Link to comment Share on other sites More sharing options...
HexNation Posted May 26, 2017 Author Share Posted May 26, 2017 1 minute ago, Malkierian said: You mean getting the block that a thrown item rests on? Not like that, but as in like I throw in item on the ground, and then right click it with another item to do something Quote Link to comment Share on other sites More sharing options...
bradylox Posted May 26, 2017 Share Posted May 26, 2017 you could do ctrl+alt+middleclick if u have a mouse Quote Link to comment Share on other sites More sharing options...
HexNation Posted May 26, 2017 Author Share Posted May 26, 2017 1 minute ago, bradylox said: you could do ctrl+alt+middleclick if u have a mouse Im talking about with code on forge 1.10 up Quote Link to comment Share on other sites More sharing options...
bradylox Posted May 26, 2017 Share Posted May 26, 2017 i know i thouught u ment getting a block lol untill you became a little more specific Quote Link to comment Share on other sites More sharing options...
bradylox Posted May 26, 2017 Share Posted May 26, 2017 10 minutes ago, HexNation said: Im talking about with code on forge 1.10 up Can you try to be a lttle more specific so this is what i think you mean that if u throw a block on a ground and right click it something will happen Quote Link to comment Share on other sites More sharing options...
HexNation Posted May 26, 2017 Author Share Posted May 26, 2017 1 hour ago, bradylox said: Can you try to be a lttle more specific so this is what i think you mean that if u throw a block on a ground and right click it something will happen Yes, but instead a block an item Quote Link to comment Share on other sites More sharing options...
Dakati Posted May 26, 2017 Share Posted May 26, 2017 (edited) Block blockClicked = world.getBlockState(new BlockPos(x, y, z)).getBlock(); Where/how are you getting the world object? Edited May 26, 2017 by Dakati Quote Link to comment Share on other sites More sharing options...
loordgek Posted May 27, 2017 Share Posted May 27, 2017 look at the onItemUse parameters it is there Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.