我一直在争取试图让一个面料国防部的工作,但无济于事。我已经遵循了人类所知的每一个教程,但我总是被困在同一个地方。
package net.example;
import net.fabricmc.api.ModInitializer;
import static net.minecraft.server.command.CommandManager.*;
public class ExampleMod implements ModInitializer {
@Override
public void onInitialize() {
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(literal("foo")
.executes(context -> {
// For versions below 1.19, replace "Text.literal" with "new LiteralText".
context.getSource().sendMessage(LiteralText("Called /foo with no arguments"));
return 1;
})));
}
}
这段代码告诉我“CommandRegistrationCallback”“无法解析”,这是https://fabricmc.net/wiki/tutorial:commands中提供的代码,所以我不知道我做错了什么。
以下是我的其他文件:
build.gradle:
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'maven-publish'
}
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/userguide/declaring_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}"
}
base {
archivesName = project.archives_base_name
}
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()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
jar {
from("LICENSE") {
rename { "${it}_${base.archivesName.get()}"}
}
}
// 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.
}
}
fabric.mod.json:
{
"schemaVersion": 1,
"id": "example",
"version": "${version}",
"name": "example",
"description": "idk",
"authors": [
"me"
],
"contact": {
},
"license": "CC0-1.0",
"icon": "assets/example/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"net.example.ExampleMod"
]
},
"mixins": [
],
"depends": {
"fabricloader": ">=0.14.17",
"fabric-api": "*",
"minecraft": "~1.19.4",
"java": ">=17"
},
"suggests": {
"another-mod": "*"
}
}
gradle.properties:
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx10G
org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.2
loader_version=0.14.19
# Mod Properties
mod_version = 1.0.0
maven_group = net.byescreen
archives_base_name = byescreen
# Dependencies
fabric_version=0.78.0+1.19.4
这是我的文件夹结构:Folder Structure
我超越了我自己,凌晨4点,我什么也没做。我需要互联网的帮助。
已经有了所有的最新版本。Java有20版,不得不降级到最后的17版。就这样
已经重建与gradlew约200倍,复制和粘贴几十个例子从互联网上和没有工作。我总是得到的问题,它找不到“CommandRegistrationCallback”或任何其他类,我需要只是阅读球员的命令。
1条答案
按热度按时间oknrviil1#
在>=1.19.4中必须使用“CommandManager.literal(“test”)”而不是“literal(“test”)"注册。注册时。