Posted September 13, 201510 yr 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..
September 13, 201510 yr 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..
September 13, 201510 yr 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..
September 13, 201510 yr 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?
September 13, 201510 yr 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.
September 14, 201510 yr 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.