Getting error < no instance(s) of type variable(s) exist so that Builder<PenguinEntity> conforms to EntityType<?> >when trying to register my entity. Error is shown in ENTITY_TYPES.register(). Any idea what is wrong. Intellij has no suggestions.
Entity Class
public class PenguinEntity extends Animal implements IAnimatable {
private AnimationFactory factory = new AnimationFactory(this);
public PenguinEntity(EntityType<? extends Animal> entityType, Level level) {
super(entityType, level);
}
public static AttributeSupplier setAttributes() {
return Animal.createMobAttributes()
.add(Attributes.MAX_HEALTH, 20)
.add(Attributes.ATTACK_DAMAGE, 3.0f)
.add(Attributes.ATTACK_SPEED, 2.0f)
.add(Attributes.MOVEMENT_SPEED, 0.5f)
.build();
}
protected void registerGoals() {
this.goalSelector.addGoal(1, new FloatGoal(this));
this.goalSelector.addGoal(2, new PanicGoal(this, 1.25D));
this.goalSelector.addGoal(3, new LookAtPlayerGoal(this, Player.class, 8.0F));
this.goalSelector.addGoal(4, new WaterAvoidingRandomStrollGoal(this, 1.0D));
this.goalSelector.addGoal(5, new RandomLookAroundGoal(this));
this.goalSelector.addGoal(6, (new HurtByTargetGoal(this)).setAlertOthers());
}
@Nullable
@Override
public AgeableMob getBreedOffspring(ServerLevel serverLevel, AgeableMob ageableMob) {
return null;
}
private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) {
if(event.isMoving()) {
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.penguin.walk", true));
return PlayState.CONTINUE;
}
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.penguin.idle", true));
return PlayState.CONTINUE;
}
@Override
public void registerControllers(AnimationData data) {
data.addAnimationController(new AnimationController(this, "controller", 0, this::predicate));
}
@Override
public AnimationFactory getFactory() {
return this.factory;
}
protected void playStepSound(BlockPos pos, BlockState blockIn) {
this.playSound(SoundEvents.GRASS_STEP,0.15f, 1.0f);
}
protected SoundEvent getAmbientSound() {
return SoundEvents.CAT_STRAY_AMBIENT;
}
protected SoundEvent getHurtSound(DamageSource damageSourceIn) {
return SoundEvents.DOLPHIN_HURT;
}
protected SoundEvent getDeathSound() {
return SoundEvents.DOLPHIN_DEATH;
}
protected float getSoundVolume() {
return 0.2f;
}
}
Registry
public class ModEntityType {
public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, MagiCraft.MOD_ID);
public static final RegistryObject<EntityType<ModFireBall>> MOD_FIREBALL =
ENTITY_TYPES.register("mod_fireball", () -> EntityType.Builder.<ModFireBall>of(ModFireBall::new, MobCategory.MISC).sized(0.25f, 0.25f).clientTrackingRange(4).updateInterval(20)
.build(new ResourceLocation(MagiCraft.MOD_ID, "mod_fireball").toString()));
public static final RegistryObject<EntityType<PenguinEntity>> PENGUIN =
ENTITY_TYPES.register("penguin", () -> EntityType.Builder.of(PenguinEntity::new, MobCategory.CREATURE).sized(0.8f, 0.6f))
.build(new ResourceLocation(MagiCraft.MOD_ID,"penguin").toString());
public static void register(IEventBus eventbus) {
ENTITY_TYPES.register(eventbus);
}
}