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.

[1.7.10] Pass on data that is saved in an Itemstack to an instance of an Entity

Featured Replies

Posted

Hi,

I have created an item that gets the x,y,z coordinates of whichever block that a player right clicks. These coordinates are then saved as NBT tag compounds in the following way

 

item.stackTagCompound.setDouble("selectedBlockXCoord", x);
item.stackTagCompound.setDouble("selectedBlockYCoord", y);
item.stackTagCompound.setDouble("selectedBlockZCoord", z);

 

I know that you can retrieve this data in the following way

Double selectedBlockXCoord =item.stackTagCompound.getDouble("selectedBlockXCoord");

 

I wish to use this item to get world coordinates and then to pass these coordinates to any entity that I right click on. I am trying to figure out a way to accomplish this functionality. Does anyone have any ideas?

 

If the entity is yours, you can override the

interact(EntityPlayer)

method, in which you can get the ItemStack the player is holding (can be null), check if the item is the item you want, and get the variables from the

stackTagCompound

(can be null) of the item the player is currently holding.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • 2 weeks later...
  • Author

What do you mean by if the entity is yours? Do you mean tamed by you or do you mean a custom entity that I have created and added as part of my mod? My ultimate goal is: I wish to use the item to "select" any entity in the world a custom entity to start but eventually try to extend the functionality to any entity found in the world and then pass on to it coordinates that the entity will use to create way-points and from those calculate a vector so that custom pathing can be achieved. I have been trying to break the problem down into smaller and smaller chunks as my thread involving custom pathing didnt generate specific enough responses.

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.