Jump to content

Cannot invoke "net.minecraft.entity.ai.attributes.AttributeModifierMap.getValue(net.minecraft.entity.ai.attributes.Attribute)"


MCArTyR

Recommended Posts

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?

Link to comment
Share on other sites

18 minutes ago, kiou.23 said:

the error points to your FrogEntity constructor:



at me.mcartyr.tutorial.entities.FrogEntity.<init>(FrogEntity.java:31) ~[main/:?] {re:classloading}

can you post it (and mark what line is line 31)?

Thats constructor with super() only. 
Here is the whole code, I removed only irrelevant methods
 

public class FrogEntity extends AnimalEntity { 
  public FrogEntity(EntityType<? extends AnimalEntity> type, World worldIn) {
        super(type, worldIn);
    } // << - 31 line

    public static AttributeModifierMap.MutableAttribute setCustomAttributes() {
        return MobEntity.createMobAttributes()
                .add(Attributes.MAX_HEALTH, 10.0)
                .add(Attributes.MOVEMENT_SPEED, 0.25);
    }

    @Nullable
    @Override
    public AgeableEntity getBreedOffspring(ServerWorld world, AgeableEntity p_241840_2_) {
        return RegistryHandler.FROG_ENTITY.get().create(world);
    }
}

 

Edited by MCArTyR
Mark line
Link to comment
Share on other sites

I found that in logs

[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes
[00:27:34] [modloading-worker-2/ERROR] [minecraft/GlobalEntityTypeAttributes]: Entity tutorial:frog has no attributes

 

Link to comment
Share on other sites

Now I have a problem like this:

java.lang.NullPointerException: Cannot invoke "net.minecraft.client.renderer.entity.EntityRenderer.shouldRender(net.minecraft.entity.Entity, net.minecraft.client.renderer.culling.ClippingHelper, double, double, double)" because "entityrenderer" is null
	at net.minecraft.client.renderer.entity.EntityRendererManager.shouldRender(EntityRendererManager.java:238) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.WorldRenderer.renderLevel(WorldRenderer.java:987) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.GameRenderer.renderLevel(GameRenderer.java:608) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:425) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.runTick(Minecraft.java:976) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:607) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) ~[?:?] {}
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
	at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?] {}
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.9.jar:?] {}
	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] {}

FrogRenderer:

public class FrogRenderer extends MobRenderer<FrogEntity, FrogModel<FrogEntity>> {

    protected static final ResourceLocation TEXTURE = new ResourceLocation(Main.MOD_ID, "textures/entity/frog");

    public FrogRenderer(EntityRendererManager renderManagerIn) {
        super(renderManagerIn, new FrogModel<>(), 0.7F);
    }

    @Override
    public ResourceLocation getTextureLocation(FrogEntity p_110775_1_) {
        return TEXTURE;
    }
}

 

Edited by MCArTyR
Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.