Jump to content

[1.15.2] My deferred registry won't work with entities


Triphion

Recommended Posts

I recently started to use deferred registries instead of the old way of registering stuff such as items and blocks. And i've gotten all other stuff i've tried to work splendidly, all but entities. It just gives me error messages for every single solution I try; and it's driving me nuts. Help please. 

 

What is it that's so wrong with this code? 

	public static final DeferredRegister<EntityType<?>> ENTITIES = new DeferredRegister<>(ForgeRegistries.ENTITIES, Reference.MODID);
	
	public static final RegistryObject<EntityType<ChupnutEntity>> CHUPNUT = ENTITIES.register("chupnut", () -> EntityType.Builder.create(ChupnutEntity::new, EntityClassification.CREATURE)
			.size(0.8f, 0.6f)
			.setShouldReceiveVelocityUpdates(false)
			.build("chupnut"));

Also, this error doesn't pop up if i change the entity class to any of the vanilla ones, and so this leads me to believe that there is something that is supposed to go into the entity class that i'm not aware of.

And so, this is my entity class:

public class ChupnutEntity extends CreatureEntity
{
	protected ChupnutEntity(EntityType<? extends CreatureEntity> type, World worldIn) 
	{
		super(type, worldIn);
		
		this.experienceValue = 5;
	}
	
	@Override
	protected void registerGoals() 
	{
		this.goalSelector.addGoal(0, new SwimGoal(this));
		this.goalSelector.addGoal(3, new MeleeAttackGoal(this, 1.0D, true));
		this.goalSelector.addGoal(5, new WaterAvoidingRandomWalkingGoal(this, 1.0D));
		this.goalSelector.addGoal(7, new LookAtGoal(this, LivingEntity.class, 16.0f));
		this.targetSelector.addGoal(0, new HurtByTargetGoal(this, new Class[0]));
		this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true));
		this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, ChickenEntity.class, true));
	}
	
	@Override
	protected void registerAttributes() 
	{
		super.registerAttributes();
		this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(16.0D);
		this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D);
		this.getAttributes().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(2.0D);
	}
	
	@Override
	protected void updateAITasks() 
	{
		super.updateAITasks();
	}
	
    public boolean attackEntityAsMob(Entity entityIn)
    {
        boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float)((int)this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue()));

        if (flag)
        {
            this.applyEnchantments(this, entityIn);
        }

        return flag;
    }
	
	@Override
	protected SoundEvent getAmbientSound() 
	{
		return super.getAmbientSound();
	}
	
	@Override
	protected SoundEvent getHurtSound(DamageSource damageSourceIn) 
	{
		return super.getHurtSound(damageSourceIn);
	}
	
	@Override
	protected SoundEvent getDeathSound() 
	{
		return super.getDeathSound();
	}
	
	@Override
	protected float getStandingEyeHeight(Pose poseIn, EntitySize sizeIn) 
	{
		return 0.4f;
	}
}

Oh, and these errors are the ones that keep popping up:

Quote

The method register(String, Supplier<? extends I>) in the type DeferredRegister<EntityType<?>> is not applicable for the arguments (String, () -> {})

Quote

The method create(EntityType.IFactory<T>, EntityClassification) in the type EntityType.Builder is not applicable for the arguments (ChupnutEntity::new, EntityClassification)

Quote

The type ChupnutEntity does not define ChupnutEntity(EntityType<T>, World) that is applicable here

These also don't disappear even if I were to extend another vanilla class. 

Edited by Triphion
Link to comment
Share on other sites

37 minutes ago, diesieben07 said:

So... what's the error?

 

50 minutes ago, Triphion said:
Quote

The method register(String, Supplier<? extends I>) in the type DeferredRegister<EntityType<?>> is not applicable for the arguments (String, () -> {})

Quote

The method create(EntityType.IFactory<T>, EntityClassification) in the type EntityType.Builder is not applicable for the arguments (ChupnutEntity::new, EntityClassification)

Quote

The type ChupnutEntity does not define ChupnutEntity(EntityType<T>, World) that is applicable here

These also don't disappear even if I were to extend another vanilla class. 

These. 

Link to comment
Share on other sites

1 minute ago, diesieben07 said:

Okay. You can try changing your constructor to use EntityType<YOurEntityClass> directly.

Eclipse has its own compiler, which sometimes has bugs.

I just fixed it. For some reason my entity constructor had "protected" instead of "public"...

Thanks for the pointers! :D

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.