Jump to content

Recommended Posts

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

Capture.PNG

Edited by bradylox
Posted
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

Posted (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 by Malkierian
  • Like 1
Posted
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.

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

Posted
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

Posted
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

Posted
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

Posted (edited)
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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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