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?