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.

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

Featured Replies

Posted

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.

You should be able to use

LivingDropsEvent

which is fired when an entity dies and before it drops its loot. Then you can check for the type of entity and the damage source and clear the entity's drops if it fits your criteria.

  • Author

So you want a timer per entity? Look at Capabilities, they allow you to attach data to any entity.

 

Am I able to use the WorldTickEvent event with this? Or would I have to use a timer I wrote myself...which I deleted lol.

  • Author

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.

  • Author

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?

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

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.