MayaqqDev / Estrogen

Adds estrogen pills into the game!
Other
73 stars 39 forks source link

(BUG) when shooting entity with a custom arrow with the Girl Power effect, game crashes #24

Closed lovebug0706 closed 8 months ago

lovebug0706 commented 9 months ago

Probably because it wasnt meant for other creatures, but maybe you can add it. Heres the error: The game crashed whilst ticking entity Error: java.lang.NullPointerException: Cannot invoke "net.minecraft.class_1324.method_6201()" because "attributeInstance" is null

Example: I shot a chicken, or a villager.

arksurv commented 8 months ago

https://github.com/MayaqqDev/Estrogen/blob/8e64acac008961b1d0786fe7270863eccbbdb42c/src/main/java/dev/mayaqq/estrogen/registry/common/effects/EstrogenEffect.java#L118

EntityAttributeInstance attributeInstance = entity.getAttributeInstance(BOOB_GROWING_START_TIME);
if (attributeInstance.getBaseValue() < 0.0) {
     double currentTime = Time.currentTime(entity.getWorld());
     entity.getAttributeInstance(BOOB_GROWING_START_TIME).setBaseValue(currentTime);
}

It looks like the crash is due to entity.getAttributeInstance(BOOB_GROWING_START_TIME) returning null and not being validated before .getBaseValue() is used on the result.

It might also be a solution to move the attribute check into the preexisting player check if there's no plan to expand to include other entities.