This commit is contained in:
0
fabric-qi-mod/.gitignore → .gitignore
vendored
0
fabric-qi-mod/.gitignore → .gitignore
vendored
9
.idea/mcMod.iml
generated
9
.idea/mcMod.iml
generated
@@ -1,9 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$" />
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
||||||
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager">
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="ms-21" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
4
.idea/modules.xml
generated
4
.idea/modules.xml
generated
@@ -2,7 +2,9 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/mcMod.iml" filepath="$PROJECT_DIR$/.idea/mcMod.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/modules/mcMod.client.iml" filepath="$PROJECT_DIR$/.idea/modules/mcMod.client.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/modules/mcMod.main.iml" filepath="$PROJECT_DIR$/.idea/modules/mcMod.main.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/modules/mcMod.test.iml" filepath="$PROJECT_DIR$/.idea/modules/mcMod.test.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$/fabric-qi-mod" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.example;
|
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class ExampleMod implements ModInitializer {
|
|
||||||
public static final String MOD_ID = "modid";
|
|
||||||
|
|
||||||
// This logger is used to write text to the console and the log file.
|
|
||||||
// It is considered best practice to use your mod id as the logger's name.
|
|
||||||
// That way, it's clear which mod wrote info, warnings, and errors.
|
|
||||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInitialize() {
|
|
||||||
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
|
||||||
// However, some things (like resources) may still be uninitialized.
|
|
||||||
// Proceed with mild caution.
|
|
||||||
|
|
||||||
LOGGER.info("Hello Fabric world!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.example.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(MinecraftServer.class)
|
|
||||||
public class ExampleMixin {
|
|
||||||
@Inject(at = @At("HEAD"), method = "loadWorld")
|
|
||||||
private void init(CallbackInfo info) {
|
|
||||||
// This code is injected into the start of MinecraftServer.loadWorld()V
|
|
||||||
}
|
|
||||||
}
|
|
||||||
0
fabric-qi-mod/gradlew → gradlew
vendored
0
fabric-qi-mod/gradlew → gradlew
vendored
0
fabric-qi-mod/gradlew.bat → gradlew.bat
vendored
0
fabric-qi-mod/gradlew.bat → gradlew.bat
vendored
15
src/main/java/Init/InitModMain.java
Normal file
15
src/main/java/Init/InitModMain.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package Init;
|
||||||
|
|
||||||
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class InitModMain implements ModInitializer {
|
||||||
|
public static final String MOD_ID = "zzdxxz_qi";
|
||||||
|
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||||
|
@Override
|
||||||
|
public void onInitialize() {
|
||||||
|
LOGGER.info("Hello Fabric world!");
|
||||||
|
Item.LoadItems.initialize();
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/main/java/Item/BigApple.java
Normal file
9
src/main/java/Item/BigApple.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package Item;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
|
public class BigApple extends Item {
|
||||||
|
public BigApple(Settings settings) {
|
||||||
|
super(settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
36
src/main/java/Item/LoadItems.java
Normal file
36
src/main/java/Item/LoadItems.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package Item;
|
||||||
|
|
||||||
|
|
||||||
|
import Init.InitModMain;
|
||||||
|
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemGroups;
|
||||||
|
import net.minecraft.registry.Registries;
|
||||||
|
import net.minecraft.registry.Registry;
|
||||||
|
import net.minecraft.registry.RegistryKey;
|
||||||
|
import net.minecraft.registry.RegistryKeys;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class LoadItems {
|
||||||
|
public static final Item QI = register("qi", Item::new, new Item.Settings());
|
||||||
|
public static void initialize() {
|
||||||
|
ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS)
|
||||||
|
.register((itemGroup) -> itemGroup.add(LoadItems.QI));
|
||||||
|
|
||||||
|
}
|
||||||
|
public static Item register(String name, Function<Item.Settings, Item> itemFactory, Item.Settings settings) {
|
||||||
|
// Create the item key.
|
||||||
|
RegistryKey<Item> itemKey = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(InitModMain.MOD_ID, name));
|
||||||
|
|
||||||
|
// Create the item instance.
|
||||||
|
Item item = itemFactory.apply(settings.registryKey(itemKey));
|
||||||
|
|
||||||
|
// Register the item.
|
||||||
|
Registry.register(Registries.ITEM, itemKey, item);
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
44
src/main/java/com/example/ExampleMod.java
Normal file
44
src/main/java/com/example/ExampleMod.java
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package com.example; // 定义包名,通常遵循反域名命名规范,例如 com.yourcompany.yourmod。
|
||||||
|
|
||||||
|
import net.fabricmc.api.ModInitializer; // 导入 Fabric Mod 初始化接口,所有 Fabric 主 Mod 类都必须实现它。
|
||||||
|
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import org.slf4j.Logger; // 导入 SLF4J (Simple Logging Facade for Java) 的 Logger 接口,用于日志输出。
|
||||||
|
import org.slf4j.LoggerFactory; // 导入 SLF4J 的 LoggerFactory 类,用于获取 Logger 实例。
|
||||||
|
|
||||||
|
public class ExampleMod implements ModInitializer {
|
||||||
|
// 定义主 Mod 类 ExampleMod,并实现 ModInitializer 接口。
|
||||||
|
// 这意味着这个类必须实现 onInitialize() 方法。
|
||||||
|
|
||||||
|
public static final String MOD_ID = "modid";
|
||||||
|
// 定义一个公共静态最终字符串常量 MOD_ID。
|
||||||
|
// 这是一个 Mod 的唯一标识符,通常与 fabric.mod.json 中的 "id" 字段对应。
|
||||||
|
// 最佳实践是将其定义为常量,方便在代码中引用。
|
||||||
|
// 这里使用了 "modid",实际项目中应替换为你的 Mod 的真实 ID,例如 "mymod"。
|
||||||
|
|
||||||
|
// This logger is used to write text to the console and the log file.
|
||||||
|
// 这个记录器(logger)用于将文本写入控制台和日志文件。
|
||||||
|
// It is considered best practice to use your mod id as the logger's name.
|
||||||
|
// 最佳实践是使用你的 Mod ID 作为记录器的名称。
|
||||||
|
// That way, it's clear which mod wrote info, warnings, and errors.
|
||||||
|
// 这样,就能清楚地知道是哪个 Mod 记录了信息、警告和错误。
|
||||||
|
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||||
|
// 创建一个公共静态最终的 Logger 实例。
|
||||||
|
// LoggerFactory.getLogger(MOD_ID) 会创建一个以你的 Mod ID 命名的日志记录器。
|
||||||
|
// 这有助于在日志文件中区分来自不同 Mod 的消息。
|
||||||
|
|
||||||
|
@Override // 这是一个注解,表示 onInitialize 方法是重写了 ModInitializer 接口中的方法。
|
||||||
|
public void onInitialize() {
|
||||||
|
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
||||||
|
// 这段代码在 Minecraft 处于Mod加载就绪状态时立即运行。
|
||||||
|
// However, some things (like resources) may still be uninitialized.
|
||||||
|
// 然而,有些东西(例如资源)可能尚未完全初始化。
|
||||||
|
// Proceed with mild caution.
|
||||||
|
// 请谨慎处理。
|
||||||
|
|
||||||
|
LOGGER.info("Hello Fabric world!");
|
||||||
|
// 使用 LOGGER 实例输出一条信息级别(INFO)的日志消息。
|
||||||
|
// 这条消息会在控制台和 Minecraft 的日志文件中显示,表明你的 Mod 已经成功加载并执行了初始化代码。
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
54
src/main/java/com/example/mixin/ExampleMixin.java
Normal file
54
src/main/java/com/example/mixin/ExampleMixin.java
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package com.example.mixin; // 定义包名。通常 Mixin 文件会被放置在一个单独的 'mixin' 子包中,
|
||||||
|
// 例如 'com.example.mymod.mixin',以便清晰地组织代码。
|
||||||
|
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
// 导入 Minecraft 服务器主类。这是我们希望修改的目标类。
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
// 导入 SpongePowered Mixin 库的 Mixin 注解。
|
||||||
|
// 这个注解用来标记一个类是一个 Mixin 类,它将针对某个目标类进行修改。
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
// 导入 Mixin 的 At 注解。
|
||||||
|
// 这个注解用于精确地指定代码注入的位置(例如,方法的开始、结束、特定的指令之前或之后)。
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
// 导入 Mixin 的 Inject 注解。
|
||||||
|
// 这个注解用于标记一个方法为注入方法,它会将你的代码注入到目标方法中。
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
// 导入 Mixin 的 CallbackInfo 类。
|
||||||
|
// 当你使用 @Inject 注解时,如果需要获取原方法的参数、返回值(或设置返回值)、或者控制原方法的执行流,
|
||||||
|
// 就需要使用 CallbackInfo 对象。它提供了与原方法交互的机制。
|
||||||
|
|
||||||
|
@Mixin(MinecraftServer.class)
|
||||||
|
// @Mixin 注解声明这个 ExampleMixin 类将对 MinecraftServer.class 这个类进行修改(混入)。
|
||||||
|
// 也就是说,ExampleMixin 中的代码会影响 MinecraftServer 类。
|
||||||
|
public class ExampleMixin {
|
||||||
|
// 这是一个 Mixin 类。它本身不会被直接实例化运行,而是通过 Mixin 框架在运行时“混合”到目标类中。
|
||||||
|
|
||||||
|
@Inject(at = @At("HEAD"), method = "loadWorld")
|
||||||
|
// @Inject 注解用来定义一个注入点。
|
||||||
|
// - at = @At("HEAD"):指定注入位置。
|
||||||
|
// "HEAD" 表示我们想把这段代码注入到目标方法的最开始。
|
||||||
|
// Mixins 提供了多种注入点类型,例如 "TAIL" (方法结束前)、"RETURN" (所有 return 语句前)、
|
||||||
|
// 或者更复杂的 ASM 指令匹配。
|
||||||
|
// - method = "loadWorld":指定目标方法。
|
||||||
|
// 这里是指 MinecraftServer 类中的 `loadWorld` 方法。
|
||||||
|
// 注意,这里的方法名是原始的 Java 方法名,而不是 Mixin 本身的方法名。
|
||||||
|
// 如果目标方法有重载,你可能需要提供完整的参数签名(例如 "loadWorld(Ljava/lang/String;J)V")。
|
||||||
|
private void init(CallbackInfo info) {
|
||||||
|
// 这是一个注入方法。它的名称可以随意定义,但参数必须符合 Mixin 的规范。
|
||||||
|
// 对于 @Inject(at = @At("HEAD")) 的情况,
|
||||||
|
// 如果原方法没有参数,CallbackInfo info 是可选的,但通常建议加上。
|
||||||
|
// 如果原方法有参数,这些参数需要按顺序放在 CallbackInfo info 之前。
|
||||||
|
// 例如,如果 loadWorld(String levelName, long seed) 的话,这里可能是 init(String levelName, long seed, CallbackInfo info)。
|
||||||
|
|
||||||
|
// This code is injected into the start of MinecraftServer.loadWorld()V
|
||||||
|
// 这段代码将被注入到 MinecraftServer.loadWorld() 方法的开头。
|
||||||
|
// 在这里,你可以执行任何你希望在 MinecraftServer 加载世界时立即执行的代码,
|
||||||
|
// 例如打印调试信息、修改一些服务器状态等。
|
||||||
|
System.out.println("MinecraftServer.loadWorld() is being called!");
|
||||||
|
// 举例:在这里打印一条消息,确认注入成功。
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 453 B After Width: | Height: | Size: 453 B |
6
src/main/resources/assets/zzdxxz_qi/items/qi.json
Normal file
6
src/main/resources/assets/zzdxxz_qi/items/qi.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"model": {
|
||||||
|
"type": "minecraft:model",
|
||||||
|
"model": "zzdxxz_qi:item/qi"
|
||||||
|
}
|
||||||
|
}
|
||||||
3
src/main/resources/assets/zzdxxz_qi/lang/en_us.json
Normal file
3
src/main/resources/assets/zzdxxz_qi/lang/en_us.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"item.zzdxxz_qi.qi": "Qi"
|
||||||
|
}
|
||||||
3
src/main/resources/assets/zzdxxz_qi/lang/zh_cn.json
Normal file
3
src/main/resources/assets/zzdxxz_qi/lang/zh_cn.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"item.zzdxxz_qi.qi": "气"
|
||||||
|
}
|
||||||
6
src/main/resources/assets/zzdxxz_qi/models/item/qi.json
Normal file
6
src/main/resources/assets/zzdxxz_qi/models/item/qi.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "zzdxxz_qi:item/qi"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
src/main/resources/assets/zzdxxz_qi/textures/item/qi.png
Normal file
BIN
src/main/resources/assets/zzdxxz_qi/textures/item/qi.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 329 B |
@@ -9,14 +9,14 @@
|
|||||||
],
|
],
|
||||||
"contact": {
|
"contact": {
|
||||||
"homepage": "https://fabricmc.net/",
|
"homepage": "https://fabricmc.net/",
|
||||||
"sources": "https://github.com/FabricMC/fabric-example-mod"
|
"sources": "http://111.228.9.32:3000/zzdxxz/mcMod"
|
||||||
},
|
},
|
||||||
"license": "CC0-1.0",
|
"license": "CC0-1.0",
|
||||||
"icon": "assets/modid/icon.png",
|
"icon": "assets/modid/icon.png",
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
"com.example.ExampleMod"
|
"Init.InitModMain"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"com.example.ExampleModClient"
|
"com.example.ExampleModClient"
|
||||||
Reference in New Issue
Block a user