I read what needs to be done like this:
private void setup(final FMLCommonSetupEvent event){
DefferedWorkQueue.runLater(() -> {
GlobalEntityTypeAttributes.put(...);
});
}
But due to deprecation warnings, I did this:
@SubscribeEvent
public static void onEntityAttributeCreation(EntityAttributeCreationEvent event){
event.put(RegistryHandler.FROG_ENTITY.get(), FrogEntity.setCustomAttributes().build());
}
My error:
java.lang.NullPointerException: Cannot invoke "net.minecraft.entity.ai.attributes.AttributeModifierMap.getValue(net.minecraft.entity.ai.attributes.Attribute)" because "this.supplier" is null
at net.minecraft.entity.ai.attributes.AttributeModifierManager.getValue(AttributeModifierManager.java:67) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading}
at net.minecraft.entity.LivingEntity.getAttributeValue(LivingEntity.java:1729) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading}
at net.minecraft.entity.LivingEntity.getMaxHealth(LivingEntity.java:1509) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading}
at net.minecraft.entity.LivingEntity.<init>(LivingEntity.java:207) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading}
at net.minecraft.entity.MobEntity.<init>(MobEntity.java:108) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.entity.CreatureEntity.<init>(CreatureEntity.java:13) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading}
at net.minecraft.entity.AgeableEntity.<init>(AgeableEntity.java:21) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading}
at net.minecraft.entity.passive.AnimalEntity.<init>(AnimalEntity.java:37) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading}
at me.mcartyr.tutorial.entities.FrogEntity.<init>(FrogEntity.java:31) ~[main/:?] {re:classloading}
How to fix it?