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

Hey guys! How do I get the instance of an elder guardian?

there is only an entityguardian class with the boolean "isElder"..

So how do I make that "instanceof" part then?

 

Event Handler

 

 

    @SubscribeEvent

    public void onEntityDrop(LivingDropsEvent event) {

    if(event.entityLiving instanceof EntityGuardian) {

    event.entityLiving.dropItem(AOTOItems.gem, 1);

    }

    }

 

 

 

The normal guardians drop the gem.

But I only want the elder guardian to drop my gem.

 

Oh yeah, and how do I make it drop with the meta 0?

Cuz' dropItem only takes the item and how much..

  • Author

But I can't access it..

 

"Cannot make a static reference to the non-static method isElder() from the type EntityGuardian"

 

Or maybe I am dumb..

 

  • Author

Hmm sorry but somehow I dont understand how you mean it.. Which is the entity instance and which is the particular instance..

I don't know how to check if the entity guardian is elder..

 

 

  • Author

But how do I check if it is an elder guardian?

There is only the EntityGuardian class with

the little guardians. I want only the elder

guardian to drop the gem. So I found

the isElder boolean but I don't know

how to access it..

 

So I am checking if the instance of entity.entityLiving is EntityGuardian..

How do I check if it is an elder one?

Cast the entity instance to

EntityGuardian

and call the

isElder

method on it.

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

Thanks! Its working!

Got this now:

 

    @SubscribeEvent

    public void onEntityDrop(LivingDropsEvent event) {

    if(event.entityLiving instanceof EntityGuardian) {

      if(((EntityGuardian) event.entityLiving).isElder()) {

    event.entityLiving.entityDropItem(new ItemStack(AOTOItems.gem, 1, 0), 1.0F);

    }

    }

    }

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.