Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

Capture.PNG

Edited by bradylox

  • 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.

Capture.PNG

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

  • Author
4 minutes ago, bradylox said:

oh that its this 


Block block = Block.blocksList[world.getBlockId(i, j, k)];

 

Doesn't work xD

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 by Malkierian

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.

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

 

  • 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?

  • 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

  • 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 xD

10 minutes ago, HexNation said:

Im talking about with code on forge 1.10 up xD

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

  • 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

Block blockClicked = world.getBlockState(new BlockPos(x, y, z)).getBlock();

 

Where/how are you getting the world object?

Edited 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.

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...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.