Jump to content

[1.8] Elder Guardian drop (instanceof) (SOLVED)


Recommended Posts

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

Posted

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

 

 

Posted

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?

Posted

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.

Posted

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

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