Jump to content

New Attack Target not Working


saxon564

Recommended Posts

I am working on adding infections for the chickens in my mod, and one of the infections causes the chicken to attack the other chickens from the mod. I have gone about this various ways, and have seen that the target is getting added, but the chicken is not attacking the target like it supposed to be.

 

The code is here on GitHub

Edited by saxon564
Strikeout Original Post
Link to comment
Share on other sites

I notice the first post didn't seem to really offer much information so I have reworked the post to be:

 

I am working on adding infections for the chickens in my mod, and one of the infections causes the chicken to attack the other chickens from the mod. I have gone about this various ways, and have seen that the target is getting added, but the chicken is not attacking the target like it supposed to be. They still attack players like they are supposed to, just not other chickens. All my chickens extend from EntityMoChicken so they should all be valid targets. I have tried a specific chicken class and it still did not work. Is there something I am missing?

 

The code is here on GitHub

Link to comment
Share on other sites

When debugging this sort of thing, you simply need to observe the execution. I usually do that by adding console print statements at every interesting point including printing out the values of key variables.

 

In your setMadChickenDisease() method, you only set the attack AI if the bool parameter is true. However, are you sure that you are calling that method properly with bool value as true? To check that you should print out the value of bool as first line in that method. I suspect that you're having trouble with that because it looks like you call the method using some value you get from a tag compound so I have no idea if that is set properly.

 

One other thing that comes to mind is that in your target task you have set the checkSight parameter to true. That is probably what you want, but it is possible that chickens, which have very low eye height, might have trouble actually seeing other chickens since maybe even grass could hide them or something. You might want to try setting that to false for testing purposes.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

I do have a line printing to the console if the bool is true and I do see that line while testing. I am also testing on a 3x3 platform near build height so I dont get any chickens spawning on the ground, so there is nothing obstructing their view. Though I have tried it with checkSight set to both true and false. Setting an attack target is such a simple thing to do, which is why I am so confused as to why it isnt working.

Link to comment
Share on other sites

To continue to dig into it, you need to further observe the execution. You need to see if the AI shouldExecute() is getting called at all and if it is whether it is returning true. You should set a breakpoint on that method and use debug run mode in Eclipse to see if it hits that line (breaks) and then inspect the field values as well as step through the rest of the AI execution.

 

Depending on what you find, there will be different solutions. If it isn't being called at all then it means that either the AI task isn't properly on the list, or that it is being pre-empted -- AI only runs depending on the priority combined with the mutex bits. For example, if certain other AI is already running it may never actually check your shouldExecute().

 

Anyway, using breakpoint and debug mode should tell you a lot about what is going on.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

So I found that only when the chicken is tamed, the list of possible near targets returns empty, even if the chickens are right next to each other, but if the chicken is not tamed, it does return a list with the closest chickens. The strange part is, if I comment out the taming code, the list will still return empty if the chicken is spawned in with an owner, though it doesnt know it is actually tamed.

Edited by saxon564
More information
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.