Abstract Class Conflict

Started by Black Flag625 on Sat, 05/23/2020 - 23:45

Topic category: Advanced modding

Last seen on 23:56, 11. Jun 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Abstract Class Conflict
Sat, 05/23/2020 - 23:45

I've been attempting to create a tameable mob, and I've managed to iron out every build error but this one (minus the location link):

 : error: CustomEntity is not abstract and does not override abstract method createChild(AgeableEntity) in AgeableEntity    public static class CustomEntity extends TameableEntity implements IRangedAttackMob {

Now, if I do what it wants and change static to abstract, I get a bunch of other errors telling me that CustomEntity is not allowed to be abstract. I also don't know how to override createChild(AgeableEntity), because the mob is not ageable in the first place. The only connection my mob has to AgeableEntity.java is through TameableEntity, which extends AnimalEntity, which extends AgeableEntity.

Anyone have any ideas as to what the issue is?

Last seen on 05:41, 24. Jul 2021
Joined May 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Because TameableEntity…
Sun, 05/24/2020 - 02:16

Because TameableEntity extends AgeableEntity, it wants you to create an override method in your entity called createChild, with the parameters given. This method returns what "child" entity will be created when your custom entity is bred. I believe this is a void method and it will look like this:

public [your entity here] createChild(AgeableEntity entity)
{
return null; //or return your entity if you want it to be breedable
}

Replace [your entity here] with the class of your custom entity, as it is referred to in your code. For example, entities generated by MCreator are called CustomEntity.

I hope this isn't too confusing. I'm relatively new at java so I don't know all the terms for various things, but I ran into this issue as well a couple weeks ago and this is how I solved it.

Last seen on 05:41, 24. Jul 2021
Joined May 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
OH! I forgot to put this in,…
Sun, 05/24/2020 - 02:18

OH! I forgot to put this in, but above this code put @Override because you are overriding createChild from AgeableEntity.