Small_Miao
本帖最后由 Small_Miao 于 2022-6-19 21:22 编辑

Farbic 环境配置
配置完毕后 测试时启动游戏时 FarbicLoader抛出错误求解补充 当Gradlew 执行remapping sources 时出现
:remapping sources
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type net.minecraft.class_2960 cannot be resolved. It is indirectly referenced from required .class files
Could not remap fabric-content-registries-v0-3.1.0+4a3ec384a9-sources.jar fully!
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0

错误
下面是DEBUG启动错误
net.fabricmc.loader.impl.FormattedException: java.lang.NoSuchMethodError: 'net.minecraft.util.Identifier net.minecraft.util.registry.RegistryKey.method_29177()'
        at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:462) ~[fabric-loader-0.14.6.jar:?]
        at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) [fabric-loader-0.14.6.jar:?]
        at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) [fabric-loader-0.14.6.jar:?]
        at net.fabricmc.devlaunchinjector.Main.main(Main.java:86) [dev-launch-injector-0.2.1+build.8.jar:?]
Caused by: java.lang.NoSuchMethodError: 'net.minecraft.util.Identifier net.minecraft.util.registry.RegistryKey.method_29177()'
        at net.minecraft.util.registry.SimpleRegistry.handler$zdl000$setPre(SimpleRegistry.java:651) ~[[email protected]:?]
        at net.minecraft.util.registry.SimpleRegistry.set(SimpleRegistry.java) ~[[email protected]:?]
        at net.minecraft.util.registry.SimpleRegistry.set(SimpleRegistry.java:88) ~[[email protected]:?]
        at net.minecraft.util.registry.SimpleRegistry.add(SimpleRegistry.java:128) ~[[email protected]:?]
        at net.minecraft.util.registry.Registry.create(Registry.java:365) ~[[email protected]:?]
        at net.minecraft.util.registry.Registry.create(Registry.java:359) ~[[email protected]:?]
        at net.minecraft.util.registry.Registry.create(Registry.java:343) ~[[email protected]:?]
        at net.minecraft.util.registry.Registry.<clinit>(Registry.java:207) ~[[email protected]:?]
        at net.minecraft.Bootstrap.initialize(Bootstrap.java:50) ~[[email protected]:?]
        at net.minecraft.client.main.Main.main(Main.java:148) ~[[email protected]:?]
        at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:460) ~[fabric-loader-0.14.6.jar:?]
        ... 3 more




aiusyudiyab
什么叫 fabric 环境,你是在 eclipse 里? fabric-example-mod 还是?
(其实现在用idea的人更多)

Small_Miao
aiusyudiyab 发表于 2022-6-19 21:25
什么叫 fabric 环境,你是在 eclipse 里? fabric-example-mod 还是?
(其实现在用idea的人更多) ...

使用的IDEA 后面用了VSCODE 两个都是1.19配置出现问题

Small_Miao
aiusyudiyab 发表于 2022-6-19 21:25
什么叫 fabric 环境,你是在 eclipse 里? fabric-example-mod 还是?
(其实现在用idea的人更多) ...

现在切换到了 1.18.1 的话 就直接游戏找不到class 我也不知道要怎么解决好了

aiusyudiyab
本帖最后由 aiusyudiyab 于 2022-6-19 22:18 编辑
Small_Miao 发表于 2022-6-19 21:37
使用的IDEA 后面用了VSCODE 两个都是1.19配置出现问题

那写java,特别mc,必然无脑idea,还有mc插件
eclipse也就算了,还算能用,vscode就是个编辑器,用他写java恐怕像样的补全都没有,这怎么用,你写一个mod的时间人家都写了10个了,效率太低


aiusyudiyab
Small_Miao 发表于 2022-6-19 21:38
现在切换到了 1.18.1 的话 就直接游戏找不到class 我也不知道要怎么解决好了
...

你的提问让人摸不着头脑,啥都不说,我也不知道你干了什么,怎么解决呢

Small_Miao
aiusyudiyab 发表于 2022-6-19 22:17
你的提问让人摸不着头脑,啥都不说,我也不知道你干了什么,怎么解决呢 ...

这么说吧 我用IDEA 1.19版本 全部配置完毕后 启动游戏会报错
报错上面我给了
游戏直接crash
我切换到VSCODE 并且转换到1.18版本
启动runClient项目 farbic会提示无法找到MC主类 无法启动

Small_Miao
[22:23:24] [ERROR] [FabricLoader/GameProvider]: Minecraft game provider couldn't locate the game! The game may be absent from the class path, lacks some expected files, suffers from jar corruption or is of an unsupported variety/version.
[22:23:24] [ERROR] [FabricLoader/]: Uncaught exception in thread "main"
java.lang.RuntimeException: Minecraft game provider couldn't locate the game! The game may be absent from the class path, lacks some expected files, suffers from jar corruption or is of an unsupported variety/version.
        at net.fabricmc.loader.impl.launch.knot.Knot.createGameProvider(Knot.java:214)
        at net.fabricmc.loader.impl.launch.knot.Knot.init(Knot.java:130)
        at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:68)
        at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
        at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)
1.18.1 启动报错

aiusyudiyab
Small_Miao 发表于 2022-6-19 22:23
[22:23:24] [ERROR] [FabricLoader/GameProvider]: Minecraft game provider couldn't locate the game! Th ...

看下 build.gradle ,另外源码是哪里来的?

https://github.com/FabricMC/fabric-example-mod/ 这里的 runClient 一点问题都没有


Small_Miao
aiusyudiyab 发表于 2022-6-19 22:31
看下 build.gradle ,另外源码是哪里来的?

https://github.com/FabricMC/fabric-example-mod/ 这里的 run ...

用的就是这个 不行 1.19 游戏会crash 1.18 找不到游戏主类
现在的build.gradle 是1.18
plugins {
    id 'fabric-loom' version '0.12-SNAPSHOT'
    id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

repositories {
    // Add repositories to retrieve artifacts from in here.
    // You should only use this when depending on other mods because
    // Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
    // See https://docs.gradle.org/current/ ... g_repositories.html
    // for more information about repositories.
}

dependencies {
    // To change the versions see the gradle.properties file
    minecraft "com.mojang:minecraft:${project.minecraft_version}"
    mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
    modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

    // Fabric API. This is technically optional, but you probably want it anyway.
    modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

    // Uncomment the following line to enable the deprecated Fabric API modules.
    // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.

    // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
}

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

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

tasks.withType(JavaCompile).configureEach {
    // Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
    it.options.release = 17
}

java {
    // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
    // if it is present.
    // If you remove this line, sources will not be generated.
    withSourcesJar()
}

jar {
    from("LICENSE") {
        rename { "${it}_${project.archivesBaseName}"}
    }
}

// configure the maven publication
publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }

    // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
    repositories {
        // Add repositories to publish to here.
        // Notice: This block does NOT have the same function as the block in the top level.
        // The repositories here will be used for publishing your artifact, not for
        // retrieving dependencies.
    }
}




Small_Miao
aiusyudiyab 发表于 2022-6-19 22:31
看下 build.gradle ,另外源码是哪里来的?

https://github.com/FabricMC/fabric-example-mod/ 这里的 run ...

外加 我应该在你群里(