Jump to content

[1.9.4] Remove AI task from vanilla mob (kill Silverfish forkbomb)


Syndaryl

Recommended Posts

Context: I'm trying to disable the ability of Silverfish to summon more Silverfish, because I hate that particular design choice too much for my own good health. I'll probably try to replace it with some other ability that doesn't give me The Rage, but first I have to nuke it.

 

I'm poking around in

EntitySilverfish

and it's a custom AI task. "AHA!" I said to myself, "I can just remove it from the task list when they spawn!" (via the

EntityJoinWorldEvent

  event). Alas, it's a package scoped internal class, and the instance of the class on each

EntitySilverfish

is in a private variable.

 

So my first idea won't work:

entity.tasks.removeTask(entity.summonSilverfish); // instance of AI class - private, can't access

and my second idea won't work, to whit iterating over entity.tasks.taskEntries to find the one that is of class EntitySilverfish.AISummonSilverfish, and remove THAT. Can't check for that, since it's private.

 

I can nuke silverfish from spawning entirely by catching

LivingSpawnEvent.CheckSpawn

and denying them, but completely forbidding them is overkill, and I'm not sure how to catch if they've been summoned by a silverfish at this point.

 

Soooo... how can I remove this private class from the list when I'm not even allowed to know its a thing?

Link to comment
Share on other sites

Use reflection to access the

EntitySilverfish#summonSilverfish

field, then remove that value from the task list.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.