Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

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.

  • Author

Use reflection to access the

EntitySilverfish#summonSilverfish

field, then remove that value from the task list.

 

Herpderp. Thanks, not entirely used to reflection yet so I never think of it as a tool.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.