Reputation: 229
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.
Upvotes: 18
Views: 329914
Reputation: 1356
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 });
}
}
Upvotes: 32
Reputation: 41
Yes. You were missing a '{' under the public class line. And then one at the end of your code to close it.
Upvotes: 3
Reputation: 351
It happens when you don't properly close the code block:
if (condition){
// your code goes here*
{ // This doesn't close the code block
Correct way:
if (condition){
// your code goes here
} // Close the code block
Upvotes: 8
Reputation: 421030
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
});
}
}
Upvotes: 11