Jump to content

Cant figure out how to pass Entity targetPos to task AIGoto


clowcadia

Recommended Posts

Link to comment
Share on other sites

19 minutes ago, clowcadia said:
                if(nbt==null) nbt = new NBTTagCompound();
                if(nbt.hasKey("targetX")){

When you create a brand new tag compound, it's never going to already have a given key - perhaps you meant to check if it doesn't have that key?

 

In gameplay terms, how do you want the ItemStack's target information to be given to the entity? Do you put the stack in the entity's inventory? Is the information sent to the entity as soon as the target is clicked?

Link to comment
Share on other sites

What this mod is supposed to do is allow the user to have a Target Item that is used by right clicking on a block/block position where the item internal nbt records the block position xyz. An entity that has a container with the gui where the player can then insert the Target item after a location in the Target item has been set to pass the location to the entity to go to. Once the entity reaches the target item target position the player then can take the target item back reset to a new target location to the items nbt and again insert to the entity s gui/container to pass another location to have the entity move to( this is where my mod is not functioning, the reset values of my target item are not passing to entity ai like they have the first time), this can be repeated unlimited times

Link to comment
Share on other sites

Then how do i read the items nbt from the task ai, everything i tried this far bring null on the calling of the nbt

i tried ItemStack.getItem().getSharedNBTTag().getInteger("targetX")

ItemStack.getNBTCompoundTag().getInteger("targetX")

top of my head examples of what i tried

Link to comment
Share on other sites

7 minutes ago, diesieben07 said:
  • Why are you calling getNBTShareTag? I don't think you know what it does...
  • In onItemUse you check if the stack already has an NBT tag. If it doesn't, you create a new NBT tag, put data into it and then just forget about it.

ShareTag i was using ealrier it work for the first time , and yes no idea what exactly it does, i do have the other option getNBTTagCompount as well though and it also returns null

 

and what do u mean forget about it, what else is supposed to be done?

 

https://github.com/Clowcadia/MinecraftForge/blob/master/1.11/NPCTesting/src/main/java/com/clowcadia/test/entities/living/ai/AIGoto.java#L36

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

Announcements



×
×
  • Create New...

Important Information

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