Jump to content

[1.16.5] Entity has no attributes


ISenseHostility

Recommended Posts

I am having a problem with entity attributes. I feel like have set them correctly, but when I launch the game I get multiple errors stating that I, in fact, have not.

I'm not sure where the problem lies, so I was hoping someone could help me.

 

Here is the log: https://privatebin.net/?0938f12eb189ae59#H5EKLWjp8BL2iZ6tAgVFmAyheUSmJDVhBgMcbHS12G79

 

Here is the entity class:

Spoiler

package com.isensehostility.entity_testing.entities;

import net.minecraft.entity.AgeableEntity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.ai.goal.*;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;

import javax.annotation.Nullable;

public class TestEntity extends AnimalEntity {

    public TestEntity(EntityType<? extends AnimalEntity> type, World worldIn) {
        super(type, worldIn);
    }

    @Nullable
    @Override
    public AgeableEntity func_241840_a(ServerWorld p_241840_1_, AgeableEntity p_241840_2_) {
        return null;
    }

    @Override
    protected void registerGoals() {
        super.registerGoals();
        this.goalSelector.addGoal(0, new SwimGoal(this));
        this.goalSelector.addGoal(3, new WaterAvoidingRandomFlyingGoal(this, 1.0D));
        this.goalSelector.addGoal(4, new WaterAvoidingRandomWalkingGoal(this, 1.0D));
        this.goalSelector.addGoal(5, new LookAtGoal(this, PlayerEntity.class, 6.0F));
        this.goalSelector.addGoal(6, new LookRandomlyGoal(this));
    }

    public static AttributeModifierMap.MutableAttribute setAttributes() {
        return MobEntity.func_233666_p_()
                .createMutableAttribute(Attributes.MAX_HEALTH, 1.0D)
                .createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.25D);
    }


}

 

Here is the registry class:

Spoiler

package com.isensehostility.entity_testing.registries;

import com.isensehostility.entity_testing.EntityTesting;
import com.isensehostility.entity_testing.entities.TestEntity;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

public class EntityRegistry {

    private static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, EntityTesting.MODID);

    public static void init() {
        ENTITIES.register(FMLJavaModLoadingContext.get().getModEventBus());

    }

    public static final RegistryObject<EntityType<TestEntity>> TEST_ENTITY = ENTITIES.register("test_entity", () -> EntityType.Builder.create(TestEntity::new, EntityClassification.CREATURE).size(1.0F,1.0F).build(new ResourceLocation(EntityTesting.MODID, "test_entity").toString()));
}

 

Here is the main class:

Spoiler

package com.isensehostility.entity_testing;

import com.isensehostility.entity_testing.entities.TestEntity;
import com.isensehostility.entity_testing.registries.EntityRegistry;
import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DeferredWorkQueue;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;

@Mod("entity_testing")
public class EntityTesting
{
    public static final String MODID = "entity_testing";

    public EntityTesting() {
        EntityRegistry.init();
        MinecraftForge.EVENT_BUS.register(this);
    }

    @SubscribeEvent
    public static void setup(final FMLCommonSetupEvent event) {
        DeferredWorkQueue.runLater(()->
                GlobalEntityTypeAttributes.put(EntityRegistry.TEST_ENTITY.get(), TestEntity.setAttributes().create()));

    }

}

 

If more info is needed tell me and I will add it.

Edited by ISenseHostility
removed quotes because it looked weird
Link to comment
Share on other sites

  • 3 months later...

It's ok, I think I've found this particular problem - it does complain if your Projectile is registered as EntityType.Builder<>.of() with anything other than MobCategory.MISC

For some crazy reason, I registered it with MobCategory.AMBIENT. 

This is where having cool examples would really come in handy 😄

Thank you diesieben07 

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.