#Error package net.fabricmc.api does not exist

30 messages · Page 1 of 1 (latest)

native onyx
#

Can someone help me know why i get this error building my mod?

It says the error is here when importing from fabric api

import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader; ```
>>
> error: package net.fabricmc.api does not exist
> import net.fabricmc.api.ModInitializer;
>                        ^
even though it should be loaded in my dependency?

dependencies {
// Fabric Loom and Minecraft
minecraft "com.mojang:minecraft:1.21.8"
mappings "net.fabricmc:yarn:1.21.8-rc1+build.2:v2"

// Fabric API
modImplementation "net.fabricmc.fabric-api:fabric-api:0.130.0+1.21.8"

// Mixin library
modImplementation "org.spongepowered:mixin:0.8.5"

}```

It should be obvious i am extremely new to modding fabric and i may just be stupid :D

wanton roost
#

did you use the example mod generator?

cold jewel
#

I smell split sources nvm unrelated

native onyx
wanton roost
#

wdym which one

#

nvm

cold jewel
wanton roost
#

either the mcdev plugin one or the one on fabricmcs website

native onyx
wanton roost
#

i see

native onyx
# cold jewel What's your entire build.gradle?
    id 'fabric-loom' version "${loom_version}"
    id 'maven-publish'
}

version = project.mod_version
group = project.maven_group

base {
    archivesName = project.archives_base_name
}

repositories {
    maven {
        url = uri("https://maven.fabricmc.net/")
    }
    maven {
        url = uri("https://repo.spongepowered.org/maven")
    }
    mavenCentral()
}


loom {
    splitEnvironmentSourceSets()

    mods {
        "piston_piston" {
            sourceSet sourceSets.main
            sourceSet sourceSets.client
        }
    }

}
dependencies {
    // Fabric Loom and Minecraft
    minecraft "com.mojang:minecraft:1.21.8"
    mappings "net.fabricmc:yarn:1.21.8-rc1+build.2:v2"

    // Fabric API
    modImplementation "net.fabricmc.fabric-api:fabric-api:0.130.0+1.21.8"

    // Mixin library
    modImplementation "org.spongepowered:mixin:0.8.5"
}



processResources {
    inputs.property "version", project.version

    filesMatching("fabric.mod.json") {
        expand "version": inputs.properties.version
    }
}

tasks.withType(JavaCompile).configureEach {
    it.options.release = 21
}

java {
    withSourcesJar()

    sourceCompatibility = JavaVersion.VERSION_21
    targetCompatibility = JavaVersion.VERSION_21
}

jar {
    inputs.property "archivesName", project.base.archivesName

    from("LICENSE") {
        rename { "${it}_${inputs.properties.archivesName}"}
    }
}

// configure the maven publication
publishing {
    publications {
        create("mavenJava", MavenPublication) {
            artifactId = project.archives_base_name
            from components.java
        }
    }
}```
(edit typo when pasting mb)
cold jewel
#

Oh, huh

#

That package is from the fabric loader

#

But you have mixin instead

#

Do modImplementation "net.fabricmc:fabric-loader:0.16.14" instead of modImplementation "org.spongepowered:mixin:0.8.5"

#

You won't need to depend on mixin explicity if you have the loader

#

You also need the loader to access the loader itself

#

To get the runtime/config directories and see what mods are loaded or not

native onyx
#

do i use loader too for the mixins then or how would that work?

native onyx
cold jewel
#

The loader has that already, yeah

#

And mixin extras too

#

Which, you'd be missing without explicitly depending on it as well afaik

cold jewel
native onyx
#

in discord?

cold jewel
#

Yeah

native onyx
#

wtf lol ty i never knew that

cold jewel
#

Just saying in case you want further help and want to spare others the effort of mentally parsing what they're reading

#

Tho, idk how good the groovy syntax highlighting would be even if you did that

#

Even the intellij plugin for groovy is just trash