CraftTweaker

CraftTweaker

151M Downloads

[Bug] EntityLivingDeathDrops fires although entity isn't dead

CREEATION opened this issue ยท 2 comments

commented

Issue Description:

EntityLivingDeathDrops fires, even though entities aren't dead yet. I'm really new to all this, so this might very well be just expected behaviour and I'm doing something wrong.

What happens:

I spawned two adult sheeps and five baby sheeps. Then I threw both a "splash potion of vulnerability" and a "splash potion of poison" at them. They didn't die, yet the log fires my debug messages in the EntityLivingDeathDrops event.

Issue in action: https://imgur.com/vncXN28

What you expected to happen:

EntityLivingDeathDrops should only fire when the entity is actually dead and about to drop something, as described in the documentation.

Script used:

https://pastebin.com/EQ6wPisG

Affected part of the script (for quicker reference):

events.onEntityLivingDeathDrops(function(event as EntityLivingDeathDropsEvent) {
    val animalEntity = event.entityLivingBase;
    
    // leather only drops if animal isn't a baby
    if ( !animalEntity.isChild ) {
        print("not a baby, yay! " ~ animalEntity.health);
        
        if ( additionalLeatherAnimals.keys has animalEntity.definition ) {
            print("got one! " ~ animalEntity.health);
        }
    } else {
        print("just a baby :( " ~ animalEntity.health);
    }
    
    print("------");
});

crafttweaker.log file:

https://pastebin.com/qnkv0nxE


Affected Versions:

  • Minecraft: 1.12.2
  • Forge: 14.23.5.2776
  • Crafttweaker: 4.1.15
  • Using a server: no
commented

We only pass the event from forge, when forge fires the event, we fire it to ZS, so nothing I can do about entities not being dead.

Saying that, the comments on the forge event say:

 * This event is {@link Cancelable}.<br>
 * If this event is canceled, the Entity does not die.<br>

it is possible that another mod is canceling the event after we fire it to zs.

commented

I see, thanks! So that other mod should not do that, right? In terms of "properly coded".