Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

1.16.x Entity Attributes not being registered

Recommended Posts

Hi, I am trying to add a custom entity, however whenever I try to summon the entity I keep receiving the following error.

[10:19:35] [Server thread/WARN] [minecraft/EntityType]: Exception loading entity: 
java.lang.NullPointerException: null
	at net.minecraft.entity.ai.attributes.AttributeModifierManager.getAttributeValue(AttributeModifierManager.java:67) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.LivingEntity.getAttributeValue(LivingEntity.java:1849) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.LivingEntity.getMaxHealth(LivingEntity.java:1610) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.LivingEntity.<init>(LivingEntity.java:209) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.MobEntity.<init>(MobEntity.java:108) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.entity.CreatureEntity.<init>(CreatureEntity.java:13) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.AgeableEntity.<init>(AgeableEntity.java:21) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.passive.AnimalEntity.<init>(AnimalEntity.java:37) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.passive.CowEntity.<init>(CowEntity.java:35) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at me.minecraft.star.entities.TestEntity.<init>(TestEntity.java:15) ~[main/:?] {re:classloading}
	at net.minecraft.entity.EntityType.create(EntityType.java:448) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.EntityType.lambda$loadEntityUnchecked$1(EntityType.java:459) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
//removed excess
	at net.minecraft.server.MinecraftServer.runScheduledTasks(MinecraftServer.java:721) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:667) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.lambda$startServer$0(MinecraftServer.java:233) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282] {}
[10:19:35] [Render thread/INFO] [minecraft/NewChatGui]: [CHAT] Unable to summon entity

I have tried multiple different methods but for some reason the entity attributes are not being set correctly. I am currently using the method suggested in the topic below with no success. 




Main class:

public class Main {
	//Removed excess
    private void setup(final FMLCommonSetupEvent event)
    	LOGGER.info("STAR - Setup Complete");
    	DeferredWorkQueue.runLater(() -> {
            GlobalEntityTypeAttributes.put(EntityRegister.TESTENTITY_TYPE, TestEntity.setCustomAttributes().create());

Entity Class:

public class TestEntity extends CowEntity {
	//Removed Excess
	public static AttributeModifierMap.MutableAttribute setCustomAttributes() {
        return MobEntity.func_233666_p_().createMutableAttribute(Attributes.MOVEMENT_SPEED,  (double)0.5F).createMutableAttribute(Attributes.MAX_HEALTH, 20.0D).createMutableAttribute(Attributes.ATTACK_DAMAGE, 5.0D);

I am using a deferred register method to register entities and it seems to be registering them successfully in the output. It also appears in the commands autofill.

Any help would be greatly appreciated :)

Link to post
Share on other sites
  • 3 weeks later...

Okay, so I've tried to add it as a subscribe event but it does not appear to exist. I'm using forge-1.16.4-35.1.4 in the eclipse IDE.

Here is the event I created:

    public void entityAttributeCreationEvent(EntityAttributeCreationEvent event) { //EntityAttributeCreateEvent cannot be resolved to a type

There don't seem to be any import candidates.

Link to post
Share on other sites

Thanks for all your help. Here is the method that seems to register the attributes correctly.

Entity Class:

public class TestEntity extends CowEntity {

	public static final String REG = "simple_entity";
	public static final EntityType<TestEntity> TYPE = EntityType.Builder.<TestEntity>of(TestEntity::new, EntityClassification.MISC)
			.sized(0.98F, 0.7F)
	public static final AttributeModifierMap MAP = AttributeModifierMap.builder().add(Attributes.MAX_HEALTH, 20.0)
			.add(Attributes.MOVEMENT_SPEED, 20.0)
			.add(Attributes.FOLLOW_RANGE, 20.0)
	public TestEntity(EntityType<? extends CowEntity> p_i48567_1_, World p_i48567_2_) {
		super(p_i48567_1_, p_i48567_2_);

Main Class:

public class Main {
	public Main() {
		IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
		LOGGER.info("STAR has been initialised");

	public static void entityAttributeCreationEvent(EntityAttributeCreationEvent event) {
    	LOGGER.info("STAR - Entity Attribute Event");
		event.put(TestEntity.TYPE, TestEntity.MAP);


Now I seem to have an error where there is no defined ai for the entity causing a ticking crash but I'll make a separate topic for that.

Link to post
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.

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.

  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Its at the top of the post
    • This is a follow up to an earlier post about not being able to use the knockback method. Well, since then I've learned a bit more about the nature of my problem. It turns out that knockback DOES work, but the catch is if I cancel the LivingAttackEvent that I'm calling the code from, then all attempts to modify the velocity of the player are nullified, even if i extract the mojang knockback code and reuse it (which I don't want to do in the long run, for legal reasons). As soon as I stop canceling the event, the knockback works. Unfortunately, I NEED to cancel the event, since its the whole point of the mod. What could be causing this interaction???
    • Well yes, vanilla armor models have two layers. The leggings grab the body and the legs while the boots grab only the legs. You could fix this by splitting your texture in two and draw the second texture only when the equipment slot is the legs.
    • I've got a model that I've parented to the correct parts of BipedModel properly; i.e. headwear-> head, chest->body, etc: My item registry: /**ARMOR*/ //avalon mail public static final RegistryObject<WithernautsArmor> AVALON_MAIL_HELMET = ITEMS.register("avalon_mail_helmet", () -> new WithernautsArmor(ArmorMaterial.DIAMOND, EquipmentSlotType.HEAD, "avalon_mail", new AvalonMailArmorModel(0.4f))); public static final RegistryObject<WithernautsArmor> AVALON_MAIL_PLATE = ITEMS.register("avalon_mail_plate", () -> new WithernautsArmor(ArmorMaterial.DIAMOND, EquipmentSlotType.CHEST, "avalon_mail", new AvalonMailArmorModel(0.4f))); public static final RegistryObject<WithernautsArmor> AVALON_MAIL_LEGS = ITEMS.register("avalon_mail_legs", () -> new WithernautsArmor(ArmorMaterial.DIAMOND, EquipmentSlotType.LEGS, "avalon_mail", new AvalonMailArmorModel(0.4f))); public static final RegistryObject<WithernautsArmor> AVALON_MAIL_FEET = ITEMS.register("avalon_mail_feet", () -> new WithernautsArmor(ArmorMaterial.DIAMOND, EquipmentSlotType.FEET, "avalon_mail", new AvalonMailArmorModel(0.4f)));   My armor's model: public AvalonMailArmorModel(float modelSize) { super(modelSize, 0, 64, 64); this.textureWidth = 64; this.textureHeight = 64; this.am_leg_pivot_r = new ModelRenderer(this, 0, 0); this.am_leg_pivot_r.setRotationPoint(0.0F, 0.0F, 0.0F); this.am_leg_pivot_r.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1, 0.0F); this.am_torso_4 = new ModelRenderer(this, 0, 27); this.am_torso_4.setRotationPoint(0.0F, 13.0F, 0.0F); this.am_torso_4.addBox(-2.0F, -3.0F, -2.5F, 4, 4, 5, 0.0F); this.am_shoulder_l_1 = new ModelRenderer(this, 0, 54); this.am_shoulder_l_1.mirror = true; this.am_shoulder_l_1.setRotationPoint(0.0F, 0.0F, 0.0F); this.am_shoulder_l_1.addBox(-1.0F, -2.5F, -3.0F, 5, 4, 6, 0.0F); this.am_helm_2 = new ModelRenderer(this, 0, 18); this.am_helm_2.setRotationPoint(0.0F, -5.0F, -4.0F); this.am_helm_2.addBox(-2.5F, -6.0F, -1.5F, 5, 6, 3, 0.0F); this.am_shoulder_r_2 = new ModelRenderer(this, 48, 55); this.am_shoulder_r_2.setRotationPoint(-0.5F, 4.0F, 0.0F); this.am_shoulder_r_2.addBox(-3.0F, -4.0F, -2.5F, 2, 4, 5, 0.0F); this.am_boot_l = new ModelRenderer(this, 36, 8); this.am_boot_l.mirror = true; this.am_boot_l.setRotationPoint(0.0F, 0.0F, 0.0F); this.am_boot_l.addBox(-2.5F, 7.0F, -2.5F, 5, 5, 5, 0.0F); this.am_torso_2 = new ModelRenderer(this, 36, 0); this.am_torso_2.mirror = true; this.am_torso_2.setRotationPoint(2.25F, 9.0F, -2.0F); this.am_torso_2.addBox(-2.0F, -8.0F, 0.0F, 4, 5, 1, 0.0F); this.setRotateAngle(am_torso_2, 0.3141592653589793F, -0.5235987755982988F, -0.10471975511965977F); this.am_shoulder_r_4 = new ModelRenderer(this, 22, 56); this.am_shoulder_r_4.setRotationPoint(0.0F, 0.0F, 0.0F); this.am_shoulder_r_4.addBox(-5.0F, 0.5F, -3.5F, 6, 1, 7, 0.0F); this.am_leg_l_2 = new ModelRenderer(this, 28, 28); this.am_leg_l_2.mirror = true; this.am_leg_l_2.setRotationPoint(0.0F, -2.0F, 0.0F); this.am_leg_l_2.addBox(0.0F, 0.0F, -3.5F, 4, 1, 7, 0.0F); this.am_shoulder_r_5 = new ModelRenderer(this, 0, 51); this.am_shoulder_r_5.setRotationPoint(-4.4F, 1.5F, 0.0F); this.am_shoulder_r_5.addBox(-0.5F, -3.0F, -1.0F, 1, 3, 2, 0.0F); this.am_torso = new ModelRenderer(this, 0, 36); this.am_torso.setRotationPoint(0.0F, 0.0F, 0.0F); this.am_torso.addBox(-4.5F, 0.0F, -2.5F, 9, 10, 5, 0.0F); this.am_shoulder_r_1 = new ModelRenderer(this, 0, 54); this.am_shoulder_r_1.setRotationPoint(0.0F, 0.0F, 0.0F); this.am_shoulder_r_1.addBox(-4.0F, -2.5F, -3.0F, 5, 4, 6, 0.0F); this.am_shoulder_l_4 = new ModelRenderer(this, 16, 18); this.am_shoulder_l_4.mirror = true; this.am_shoulder_l_4.setRotationPoint(0.0F, -2.5F, 0.0F); this.am_shoulder_l_4.addBox(0.0F, -2.0F, -3.0F, 1, 2, 6, 0.0F); this.am_shoulder_l_6 = new ModelRenderer(this, 0, 51); this.am_shoulder_l_6.mirror = true; this.am_shoulder_l_6.setRotationPoint(4.4F, 0.5F, 0.0F); this.am_shoulder_l_6.addBox(-0.5F, -2.0F, -1.0F, 1, 2, 2, 0.0F); this.am_leg_r_1 = new ModelRenderer(this, 28, 36); this.am_leg_r_1.setRotationPoint(0.0F, 0.0F, 0.0F); this.am_leg_r_1.addBox(-3.0F, -2.0F, -3.0F, 3, 6, 6, 0.0F); this.setRotateAngle(am_leg_r_1, 0.0F, 0.0F, 0.17453292519943295F); this.am_leg_pivot_l = new ModelRenderer(this, 0, 0); this.am_leg_pivot_l.setRotationPoint(0.0F, 0.0F, 0.0F); this.am_leg_pivot_l.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1, 0.0F); this.am_shoulder_l_5 = new ModelRenderer(this, 22, 56); this.am_shoulder_l_5.mirror = true; this.am_shoulder_l_5.setRotationPoint(0.0F, 0.0F, 0.0F); this.am_shoulder_l_5.addBox(-1.0F, 0.5F, -3.5F, 6, 1, 7, 0.0F); this.am_torso_3 = new ModelRenderer(this, 46, 0); this.am_torso_3.setRotationPoint(0.0F, 9.0F, -2.5F); this.am_torso_3.addBox(-1.0F, -8.0F, -0.5F, 2, 5, 1, 0.0F); this.setRotateAngle(am_torso_3, 0.296705972839036F, 0.0F, 0.0F); this.am_leg_l_1 = new ModelRenderer(this, 28, 36); this.am_leg_l_1.mirror = true; this.am_leg_l_1.setRotationPoint(0.0F, 0.0F, 0.0F); this.am_leg_l_1.addBox(0.0F, -2.0F, -3.0F, 3, 6, 6, 0.0F); this.setRotateAngle(am_leg_l_1, 0.0F, 0.0F, -0.17453292519943295F); this.am_shoulder_l_3 = new ModelRenderer(this, 48, 55); this.am_shoulder_l_3.mirror = true; this.am_shoulder_l_3.setRotationPoint(1.5F, 4.0F, 0.0F); this.am_shoulder_l_3.addBox(0.0F, -4.0F, -2.5F, 2, 4, 5, 0.0F); this.am_torso_5 = new ModelRenderer(this, 28, 48); this.am_torso_5.setRotationPoint(0.0F, 9.0F, -1.0F); this.am_torso_5.addBox(-2.0F, -4.0F, -2.0F, 4, 4, 4, 0.0F); this.am_leg_r_2 = new ModelRenderer(this, 28, 28); this.am_leg_r_2.setRotationPoint(0.0F, -2.0F, 0.0F); this.am_leg_r_2.addBox(-4.0F, 0.0F, -3.5F, 4, 1, 7, 0.0F); this.am_torso_1 = new ModelRenderer(this, 36, 0); this.am_torso_1.setRotationPoint(-2.25F, 9.0F, -2.0F); this.am_torso_1.addBox(-2.0F, -8.0F, 0.0F, 4, 5, 1, 0.0F); this.setRotateAngle(am_torso_1, 0.3141592653589793F, 0.5235987755982988F, 0.10471975511965977F); this.am_helm_1 = new ModelRenderer(this, 0, 0); this.am_helm_1.setRotationPoint(0.0F, 0.0F, 0.0F); this.am_helm_1.addBox(-4.5F, -9.0F, -4.5F, 9, 9, 9, 0.0F); this.am_boot_r = new ModelRenderer(this, 36, 8); this.am_boot_r.setRotationPoint(0.0F, 0.0F, 0.0F); this.am_boot_r.addBox(-2.5F, 7.0F, -2.5F, 5, 5, 5, 0.0F); this.am_shoulder_r_3 = new ModelRenderer(this, 16, 18); this.am_shoulder_r_3.setRotationPoint(0.0F, -2.5F, 0.0F); this.am_shoulder_r_3.addBox(-1.0F, -2.0F, -3.0F, 1, 2, 6, 0.0F); this.bipedHead.addChild(this.am_helm_1); this.bipedRightLeg.addChild(this.am_leg_pivot_r); this.bipedLeftLeg.addChild(this.am_leg_pivot_l); this.bipedRightLeg.addChild(this.am_boot_r); this.bipedLeftLeg.addChild(this.am_boot_l); this.bipedRightArm.addChild(this.am_shoulder_r_1); this.bipedLeftArm.addChild(this.am_shoulder_l_1); this.bipedBody.addChild(this.am_torso); this.am_torso.addChild(this.am_torso_4); this.am_helm_1.addChild(this.am_helm_2); this.am_shoulder_r_1.addChild(this.am_shoulder_r_2); this.am_torso.addChild(this.am_torso_2); this.am_shoulder_r_1.addChild(this.am_shoulder_r_4); this.am_leg_l_1.addChild(this.am_leg_l_2); this.am_shoulder_r_1.addChild(this.am_shoulder_r_5); this.am_shoulder_l_1.addChild(this.am_shoulder_l_4); this.am_shoulder_l_1.addChild(this.am_shoulder_l_6); this.am_shoulder_l_1.addChild(this.am_shoulder_l_5); this.am_torso.addChild(this.am_torso_3); this.am_shoulder_l_1.addChild(this.am_shoulder_l_3); this.am_torso.addChild(this.am_torso_5); this.am_leg_r_1.addChild(this.am_leg_r_2); this.am_torso.addChild(this.am_torso_1); this.am_shoulder_r_1.addChild(this.am_shoulder_r_3); this.am_leg_pivot_r.addChild(this.am_leg_r_1); this.am_leg_pivot_l.addChild(this.am_leg_l_1); } However, this is the result when I put on the armor in-game (ignore the missing textures for now, it's intentional) Wearing ONLY helm. Okay, this is correct.   ONLY chestplate. Correct as well.   ONLY legging. For some reason, am_torso is rendered as well   and when I put on the feet, it looks like it's rendering the entire legging because BipedModel doesn't have a group just for feet.   What's the cleanest way to do this?
  • Topics

  • Who's Online (See full list)

  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.