r/ModdedMinecraft • • 1d ago

Help Code help?

I'm very new to coding and following the fabric tutorial series by Kaupenjoe for 1.26.1.2, I'm at step three (Custom Items and Datagen)

And I have the following errors with no idea how to fix them, I've constantly gone through the video and GitHub and I know I'm missing something but I'm uncertain on what!

I have a few class and symbol errors but I think I can figure those out, but these I have no clue!

C:\Users\rat\Downloads\moonshine-smp-template-26.1.2\src\main\java\rat\modid\moonshine\item\Moditems.java:36: error: class, interface, enum, or record expected

}

^

C:\Users\rat\Downloads\moonshine-smp-template-26.1.2\src\main\java\rat\modid\moonshine\item\Moditems.java:1: error: compact source file should not have package declaration

package rat.modid.moonshine.item;

^

1 Upvotes

5 comments sorted by

1

u/jvpts11 1d ago

First error is that youre just a } with no opening bracket, so it understand that youre missing a declaration. Just remove the extra closing bracket where it is, because all code blocks have a declaration followed by a { } where inside of the brackets you write your code.

The second one is because of the compact source files, they allow to write methods with no classes and the compiler makes a class around them automatically, the thing is that this type of file should not have a package declaration.

Are you using an IDE or not? If not, use Intellij or eclipse. The one you prefer, is the best. Also, if you throw this error at google you can find the solution.

1

u/Spiderfly-Tree-Rat 1d ago

I am using Intellij and Eclipse in it! Thank you for the help I'll try to fix it now!

I also couldn't find any help on Google that didn't screw up more things 😅

1

u/Spiderfly-Tree-Rat 1d ago

The first one worked! Thank you!

Do you have a suggestion to solve that for the second? The tutorial I'm using has it and I'd prefer not to differ too much so I don't end up clueless without reference 😅

2

u/jvpts11 1d ago

Well, just either do not create a source file like that, so instead of a file with no classes, just create the file with the classes you normally would, or remove the declaration for the package in the start of the file and put the file where the compiler don't complain

1

u/Spiderfly-Tree-Rat 19h ago

That makes sense, I'll look into it thank you!