Jump to content

[1.11] Trying to kill off my mobs if they are burning and remove their drops.


Mopop

Recommended Posts

I've been working on a mod that makes all mobs during sunlight. Problem is that the witches heal, and then the mobs drop a ton of crap. I wanted to set it that after the mob burns for 8 seconds it will kill them. I messed around with WorldTickEvent and make some kind of a timer, but the problem was I couldn't get any information from the LivingUpdate method holding all the entity information. I then tried just having them start to burn, then kill them off immediately, but it looked very unnatural. Then I tried what I'm posting below...

 

 

@SubscribeEvent(priority = EventPriority.HIGHEST)
    public void BurnMobs(LivingEvent.LivingUpdateEvent e)
    {
        EntityLivingBase entity = e.getEntityLiving();
        World world = e.getEntity().getEntityWorld();

        BurningMobs(world, entity);

        while(entity.isBurning())
        {
            if(entity instanceof EntityWitch)
            {
                if(entity.isBurning() && ((EntityWitch) entity).isDrinkingPotion())
                {
                    killStingyMob(entity);
                }
            }

            if(entity.isBurning() && isBrightEnoughToBurn(world, entity))
            {
                killStingyMob(entity);
            }
        }
    }

    public void BurningMobs(World world, EntityLivingBase entity)
    {
        if (isBrightEnoughToBurn(world, entity))
        {
            entity.setFire(30);
        }
    }

public void killStingyMob(EntityLivingBase e)
    {
        e.setDead();
        e.setDropItemsWhenDead(false);
    }

 

 

That locks my code up also the StingyMobs method when used they'll still drop items. So I've been at a lost on what to do and really could use some direction, thank you.

Link to comment
Share on other sites

Not sure how you mean that question. You shouldn't use

WorldTickEvent

, use

LivingUpdateEvent

like you are now.

 

I probably worded it poorly. I was asking if should use a timer class I wrote myself then attach it using capabilities or use the built in tick events, sorry.

Link to comment
Share on other sites

Well I looked at capabilities, whew, kind of a brain scratcher.

 

The docs don't tell me much, the few tutorials left a lot of questions too. Is there a good resource I can look at for help?

 

Depends on your use case. If you need to do something every tick for (almost) every entity, use LivingUpdateEvent. If you need to do something every once in a while for some entities based on a certain event (which you can detect outside of just ticking) then use WorldTickEvent with a list of tasks to do.

 

I was always wondering if the was possible in my main block of code with all the entity data if I could call WorldTickEvent, instead of subscribing to it?

Link to comment
Share on other sites

I was always wondering if the was possible in my main block of code with all the entity data if I could call WorldTickEvent, instead of subscribing to it?

Uhm... what? I have no idea what you are talking about.

Probably worded it poorly again. I was asking if I had to subcribe to an event to fire it, or if I can just call it in another block of code. Say like once the enemy was set on fire it would start the tick event to count 8 seconds and execute code I wrote instead of having it listen for ticks the whole time, hopefully it's worded better.

 

http://www.planetminecraft.com/blog/forge-tutorial-capability-system/

 

I followed this guide. I know about interfaces, but I was wondering how I could get entity data from it, this guy uses his implementation to get a mana value he sets. Then the whole NBT thing was a headscratcher too. Thanks for the help.

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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