Posted March 16, 20178 yr I am trying to pass the targetPos BlockPos value to my AI Task so it can use it try and go to its xyz but on should execute its apears as null https://github.com/Clowcadia/MinecraftForge/blob/master/1.11/NPCTesting/src/main/java/com/clowcadia/test/entities/living/Test.java https://github.com/Clowcadia/MinecraftForge/blob/master/1.11/NPCTesting/src/main/java/com/clowcadia/test/entities/living/ai/AIGoto.java
March 16, 20178 yr Author I am sorry, just recently i dont get much responce.. for like days sometimes. it is understanding after a day when i figure it out just its true i am impatient and i like input thats all
March 16, 20178 yr Author As thus comparing with unlocalized names, what are other ways of comparing?
March 16, 20178 yr 9 minutes ago, clowcadia said: As thus comparing with unlocalized names, what are other ways of comparing? Compare the Item directly. Items are singletons so can be compared just using the == operator. Edited March 16, 20178 yr by Jay Avery
March 16, 20178 yr Author i am trying to compare an itemstack , to what i inserted in the container if(foodStack.equals(ItemHandler.target)){ if(foodStack == ItemHandler.target){
March 16, 20178 yr Author Yep, got that as for the data in item, its just temporary i am just trying to get it to work before i do the correct way of things
March 17, 20178 yr Author Ok i did that , so i corrected the comparissopn, along with nbt, now how can i pass the items nbt values to an ai task? https://github.com/Clowcadia/MinecraftForge/blob/master/1.11/NPCTesting/src/main/java/com/clowcadia/test/items/ItemTarget.java https://github.com/Clowcadia/MinecraftForge/blob/master/1.11/NPCTesting/src/main/java/com/clowcadia/test/entities/living/Test.java https://github.com/Clowcadia/MinecraftForge/blob/master/1.11/NPCTesting/src/main/java/com/clowcadia/test/entities/living/ai/AIGoto.java
March 17, 20178 yr 19 minutes ago, clowcadia said: Ok i did that , so i corrected the comparissopn, along with nbt, now how can i pass the items nbt values to an ai task? https://github.com/Clowcadia/MinecraftForge/blob/master/1.11/NPCTesting/src/main/java/com/clowcadia/test/items/ItemTarget.java https://github.com/Clowcadia/MinecraftForge/blob/master/1.11/NPCTesting/src/main/java/com/clowcadia/test/entities/living/Test.java https://github.com/Clowcadia/MinecraftForge/blob/master/1.11/NPCTesting/src/main/java/com/clowcadia/test/entities/living/ai/AIGoto.java 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?
March 17, 20178 yr Author ok i did so but now its only a one time thing while running the game, i have to exicute out of the game to give new co-ordinates https://github.com/Clowcadia/MinecraftForge/blob/master/1.11/NPCTesting/src/main/java/com/clowcadia/test/entities/living/ai/AIGoto.java
March 18, 20178 yr Author i am seriously tried alot of different methods, and the most succestful once only return success one time, where the targetItem is vaible one use, iwant it multiple uses
March 18, 20178 yr Be more specific: are you unable to use the item a second time? Does it not save the co-ordinates a second time? Does the entity's AI target not change when the item is changed?
March 18, 20178 yr So you remove the item from the entity's inventory, target it to a new position, give it back to the entity, and the entity doesn't change it's target?
March 18, 20178 yr Author 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
March 18, 20178 yr Author 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
March 18, 20178 yr Author https://github.com/Clowcadia/MinecraftForge/blob/master/1.11/NPCTesting/src/main/java/com/clowcadia/test/entities/living/ai/AIGoto.java#L35-L36 Edited March 18, 20178 yr by clowcadia
March 18, 20178 yr Author 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 March 18, 20178 yr by clowcadia
March 18, 20178 yr Author ok so the compound is set, but i cant read it after changing the target position
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.