I have the following source code
public class mod_MyMod extends BaseMod
public String Version()
{
return "1.2_02";
}
public void AddRecipes(CraftingManager recipes)
{
recipes.addRecipe(new ItemStack(Item.diamond), new Object[] {
"#", Character.valueOf('#'), Block.dirt
});
}
When I try to compile it I get the following error:
java:11: reached end of file while parsing }
What am I doing wrong? Any help appreciated.
The error Reached End of File While Parsing is a compiler error and almost always means that your curly parenthesis are not ending completely or maybe there could be extra parenthesis in the end.
This error occurs if a closing curly bracket i.e "}" is missing for a block of code (e.g method, class).
Missing braces According to Java syntax, every block has to start and end with an opening and a closing curly brace, respectively. If a brace is omitted, the compiler won't be able to identify the start and/or the end of a block, which will result in an illegal start of expression error (Fig. 4(a)).
'else' without 'if' This error means that Java is unable to find an if statement associated to your else statement. Else statements do not work unless they are associated with an if statement. Ensure that you have an if statement and that your else statement isn't nested within your if statement.
You have to open and close your class with { ... }
like:
public class mod_MyMod extends BaseMod
{
public String Version()
{
return "1.2_02";
}
public void AddRecipes(CraftingManager recipes)
{
recipes.addRecipe(new ItemStack(Item.diamond), new Object[] {
"#", Character.valueOf('#'), Block.dirt });
}
}
You need to enclose your class in {
and }
. A few extra pointers: According to the Java coding conventions, you should
{
on the same line as the method declaration:Here's how I would write it:
public class ModMyMod extends BaseMod {
public String version() {
return "1.2_02";
}
public void addRecipes(CraftingManager recipes) {
recipes.addRecipe(new ItemStack(Item.diamond), new Object[] {
"#", Character.valueOf('#'), Block.dirt
});
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With