Jump to content

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


Thornack

Recommended Posts

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?

 

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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