Apothic Attributes (AttributesLib)

Apothic Attributes (AttributesLib)

11M Downloads

crash when entering the world

Kasualix opened this issue ยท 6 comments

commented
commented

The owner should never be null, it is set in the constructor via this mixin

/**
* Constructor mixin to call {@link IEntityOwned#setOwner(LivingEntity)} on {@link #attributes}.<br>
* Supports {@link AttributeChangedValueEvent}.
*/
@Inject(at = @At(value = "TAIL"), method = "<init>(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;)V", require = 1, remap = false)
public void apoth_ownedAttrMap(EntityType<?> type, Level level, CallbackInfo ci) {
((IEntityOwned) attributes).setOwner((LivingEntity) (Object) this);
}

And this code is executed well after the constructor, given that it is from an entity join level event.

So the question then becomes why is the owner null. This is an error condition, and adding a null check would just mask the error. You might want to try removing mods to see if you can determine what is messing with the attribute map, since it looks like this will trigger consistently on world load until the change is undone.

commented

It seems only that world is broken
A new created world will not crash.

commented

Ice and Fire updates attributes the attribute modifier map before the entity is initialized so people can dynamically change them via config files. Example (entity code interface code )
Is this a very bodged way of doing things? Absolutely! But as far as I know there's no other way of accomplishing this behavior.

This causes the exact behavior as described here.
I'm very much willing to fix this issue on my end but I wouldn't know how.

commented

I would need to know the exact goal this is accomplishing. If this is just adjusting the base values of attributes, this is unnecessary, as they can be changed retroactively.

commented

No idea why I never thought about doing that...
Oh well thanks :)
Might still be a good idea to add a check with an error log on your end, in case other people are as dumb as me but I can also understand if you don't want to do that!

commented

I'll be adding a proper error message but the crash will still happen when an owner can't be detected, and unfortunately the errors will probably not be super helpful since there is no way to detect who the owner should have been.