Results 1 to 18 of 18
  1. #1
    intercroc is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Post java error "invalid method declaration;return type required"

    i'm trying to make a modification for a game
    but the i get this error please help!
    code:
    [CODE]package net.minecraft.src;

    import java.lang.reflect.Method;
    import java.util.Map;

    public class mod_markEvans extends BaseMod
    {

    public String Version()
    {
    //not sure exactly what this does, but I know that you can write pretty much anything you want in there.
    return "mod_MarkEvans version 0.3";
    }
    public mod_MarkEvans();
    {
    ModLoader.RegisterEntityID(EntityMarkevans.class, "Mark Evans", ModLoader.getUniqueEntityID());
    ModLoader.AddSpawn(EntityMarkEvans.class, 8, EnumCreatureType.creature);//not sure what the 8 does, play around with it if you want

    }
    //this part gives your mob a human model. This part is necessary if you want your mob to be able to carry stuff.
    public void AddRenderer(Map map)
    {
    map.put(EntityMarkEvans.class, new RenderBiped(new ModelBiped(), 0.5F));
    }
    }

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,381
    Blog Entries
    7
    Rep Power
    20

    Default Re: java error "invalid method declaration;return type required"

    Quote Originally Posted by intercroc View Post
    Java Code:
             public mod_MarkEvans();
    What's that semicolon doing there?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    intercroc is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default Re: java error "invalid method declaration;return type required"

    oops my fault

  4. #4
    intercroc is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default Re: java error "invalid method declaration;return type required"

    still not workin=(

  5. #5
    Wnt2bsleepin is offline Senior Member
    Join Date
    Feb 2012
    Posts
    219
    Rep Power
    3

    Default Re: java error "invalid method declaration;return type required"

    Are you still getting the same error message? Please show us the entire stack trace.

  6. #6
    intercroc is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default Re: java error "invalid method declaration;return type required"

    src\minecraft\net\minecraft\src\mod_MarkEvans.java :14: error: invalid method dec
    laration; return type required
    public Mod_MarkEvans();
    ^

    1 error
    ==================

  7. #7
    intercroc is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default Re: java error "invalid method declaration;return type required"

    the problem is in the word "Mod"

  8. #8
    Wnt2bsleepin is offline Senior Member
    Join Date
    Feb 2012
    Posts
    219
    Rep Power
    3

    Default Re: java error "invalid method declaration;return type required"

    No, it thinks you are trying to declare a method there. Without a return type, it is assumed to be a Constructor. Constructors have to have the same name as the class in which it is contained. How would you fix it?

  9. #9
    intercroc is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default Re: java error "invalid method declaration;return type required"

    no idea!!

  10. #10
    intercroc is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default Re: java error "invalid method declaration;return type required"

    please help me fix it!

  11. #11
    intercroc is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default Re: java error "invalid method declaration;return type required"

    how do i add a return type???!

  12. #12
    Wnt2bsleepin is offline Senior Member
    Join Date
    Feb 2012
    Posts
    219
    Rep Power
    3

    Default Re: java error "invalid method declaration;return type required"

    Do you even want a return type? Seems like this is trying to make a Constructor. Since there is no return type in a Constructor, the way it is would work except for one thing. I said that the Constructor must have the same name as the class in which it is contained. Does it have the same name?

  13. #13
    intercroc is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Post Re: java error "invalid method declaration;return type required"

    current code:
    package net.minecraft.src;

    import java.lang.reflect.Method;
    import java.util.Map;

    public class Mod_markEvans extends BaseMod
    {

    public String getVersion()
    {

    return "mod_MarkEvans version 0.3";
    }
    public Mod_MarkEvans();
    {
    ModLoader.RegisterEntityID(EntityMarkEvans.class, "Mark Evans", ModLoader.getUniqueEntityID());
    ModLoader.AddSpawn(EntityMarkEvans.class, 8, EnumCreatureType.creature);
    }
    //this part gives your mob a human model. This part is necessary if you want your mob to be able to carry stuff.
    public void AddRenderer(Map map)
    {
    map.put(EntityMarkEvans.class, new RenderBiped(new ModelBiped(), 0.5F));
    }
    }

  14. #14
    intercroc is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default Re: java error "invalid method declaration;return type required"

    the name of the file: mod_MarkEvans.java

  15. #15
    Wnt2bsleepin is offline Senior Member
    Join Date
    Feb 2012
    Posts
    219
    Rep Power
    3

    Default Re: java error "invalid method declaration;return type required"

    Remember that Java is case sensitive. Do the strings match?

  16. #16
    intercroc is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default Re: java error "invalid method declaration;return type required"

    i'm just learning java so i don't know everything

  17. #17
    Wnt2bsleepin is offline Senior Member
    Join Date
    Feb 2012
    Posts
    219
    Rep Power
    3

    Default Re: java error "invalid method declaration;return type required"

    That's fine, although you should work through some tutorials before doing something like this. The name of the file and the name of the class have to match. Any Constructors have to have the same name of the Class. Have a look through these documents to get an idea of some OOP concepts. Jumping headfirst into something like this will probably lead to frustration.

  18. #18
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,381
    Blog Entries
    7
    Rep Power
    20

    Default Re: java error "invalid method declaration;return type required"

    Quote Originally Posted by intercroc View Post
    Java Code:
             public Mod_MarkEvans();
    That semicolon is still there ...

    kInd regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 3
    Last Post: 03-08-2012, 08:33 PM
  2. invalid method declaration; return type required
    By DeclareVariablesNotWar in forum New To Java
    Replies: 10
    Last Post: 12-13-2011, 02:57 AM
  3. Invalid Method Declaration; Return Type Required
    By bremzb in forum AWT / Swing
    Replies: 3
    Last Post: 05-05-2011, 10:12 PM
  4. invalid method declaration; return type required
    By XaviannNJ in forum JCreator
    Replies: 7
    Last Post: 11-25-2010, 01:59 PM
  5. Replies: 3
    Last Post: 06-05-2010, 08:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •