Posted May 26, 20178 yr 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
May 26, 20178 yr 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, 20178 yr by bradylox
May 26, 20178 yr Author 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
May 26, 20178 yr Author 4 minutes ago, bradylox said: oh that its this Block block = Block.blocksList[world.getBlockId(i, j, k)]; Doesn't work
May 26, 20178 yr 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, 20178 yr by Malkierian
May 26, 20178 yr 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.
May 26, 20178 yr 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
May 26, 20178 yr Author 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?
May 26, 20178 yr Author 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
May 26, 20178 yr Author 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
May 26, 20178 yr i know i thouught u ment getting a block lol untill you became a little more specific
May 26, 20178 yr 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
May 26, 20178 yr Author 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
May 26, 20178 yr Block blockClicked = world.getBlockState(new BlockPos(x, y, z)).getBlock(); Where/how are you getting the world object? Edited May 26, 20178 yr by Dakati
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.