aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml2
-rw-r--r--build.gradle27
-rw-r--r--gradle.properties16
-rw-r--r--settings.gradle2
-rw-r--r--src/client/java/com/example/ExampleModClient.java10
-rw-r--r--src/client/java/com/example/mixin/client/ExampleClientMixin.java15
-rw-r--r--src/client/resources/modid.client.mixins.json11
-rw-r--r--src/main/java/com/example/ExampleMod.java22
-rw-r--r--src/main/java/com/example/mixin/ExampleMixin.java (renamed from src/main/java/net/fabricmc/example/mixin/ExampleMixin.java)13
-rw-r--r--src/main/java/net/fabricmc/example/ExampleMod.java21
-rw-r--r--src/main/resources/fabric.mod.json77
-rw-r--r--src/main/resources/modid.mixins.json23
12 files changed, 143 insertions, 96 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e2fa68a..2ca3795 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -37,4 +37,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: Artifacts
- path: build/libs/
+ path: build/libs/ \ No newline at end of file
diff --git a/build.gradle b/build.gradle
index b6cb6c0..a8bdc34 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,6 +6,10 @@ plugins {
version = project.mod_version
group = project.maven_group
+base {
+ archivesName = project.archives_base_name
+}
+
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
@@ -14,6 +18,18 @@ repositories {
// for more information about repositories.
}
+loom {
+ splitEnvironmentSourceSets()
+
+ mods {
+ "modid" {
+ sourceSet sourceSets.main
+ sourceSet sourceSets.client
+ }
+ }
+
+}
+
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
@@ -22,17 +38,13 @@ dependencies {
// 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
@@ -42,7 +54,6 @@ processResources {
}
tasks.withType(JavaCompile).configureEach {
- // Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
}
@@ -58,7 +69,7 @@ java {
jar {
from("LICENSE") {
- rename { "${it}_${base.archivesName.get()}"}
+ rename { "${it}_${project.archivesBaseName}"}
}
}
@@ -77,4 +88,4 @@ publishing {
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
-}
+} \ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index d9f5bbe..2934244 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G
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
+# check these on https://fabricmc.net/develop
+minecraft_version=1.20
+yarn_mappings=1.20+build.1
+loader_version=0.14.21
# Mod Properties
- mod_version = 1.0.0
- maven_group = com.example
- archives_base_name = fabric-example-mod
+mod_version=1.0.0
+maven_group=com.example
+archives_base_name=modid
# Dependencies
- fabric_version=0.79.0+1.19.4
+fabric_version=0.83.0+1.20 \ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index b02216b..56266b4 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -7,4 +7,4 @@ pluginManagement {
mavenCentral()
gradlePluginPortal()
}
-}
+} \ No newline at end of file
diff --git a/src/client/java/com/example/ExampleModClient.java b/src/client/java/com/example/ExampleModClient.java
new file mode 100644
index 0000000..12c3502
--- /dev/null
+++ b/src/client/java/com/example/ExampleModClient.java
@@ -0,0 +1,10 @@
+package com.example;
+
+import net.fabricmc.api.ClientModInitializer;
+
+public class ExampleModClient implements ClientModInitializer {
+ @Override
+ public void onInitializeClient() {
+ // This entrypoint is suitable for setting up client-specific logic, such as rendering.
+ }
+} \ No newline at end of file
diff --git a/src/client/java/com/example/mixin/client/ExampleClientMixin.java b/src/client/java/com/example/mixin/client/ExampleClientMixin.java
new file mode 100644
index 0000000..061b0ef
--- /dev/null
+++ b/src/client/java/com/example/mixin/client/ExampleClientMixin.java
@@ -0,0 +1,15 @@
+package com.example.mixin.client;
+
+import net.minecraft.client.MinecraftClient;
+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(MinecraftClient.class)
+public class ExampleClientMixin {
+ @Inject(at = @At("HEAD"), method = "run")
+ private void run(CallbackInfo info) {
+ // This code is injected into the start of MinecraftClient.run()V
+ }
+} \ No newline at end of file
diff --git a/src/client/resources/modid.client.mixins.json b/src/client/resources/modid.client.mixins.json
new file mode 100644
index 0000000..21b0fc1
--- /dev/null
+++ b/src/client/resources/modid.client.mixins.json
@@ -0,0 +1,11 @@
+{
+ "required": true,
+ "package": "com.example.mixin.client",
+ "compatibilityLevel": "JAVA_17",
+ "client": [
+ "ExampleClientMixin"
+ ],
+ "injectors": {
+ "defaultRequire": 1
+ }
+} \ No newline at end of file
diff --git a/src/main/java/com/example/ExampleMod.java b/src/main/java/com/example/ExampleMod.java
new file mode 100644
index 0000000..4cbb0cb
--- /dev/null
+++ b/src/main/java/com/example/ExampleMod.java
@@ -0,0 +1,22 @@
+package com.example;
+
+import net.fabricmc.api.ModInitializer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ExampleMod implements ModInitializer {
+ // 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("modid");
+
+ @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!");
+ }
+} \ No newline at end of file
diff --git a/src/main/java/net/fabricmc/example/mixin/ExampleMixin.java b/src/main/java/com/example/mixin/ExampleMixin.java
index 356cb38..3c4212c 100644
--- a/src/main/java/net/fabricmc/example/mixin/ExampleMixin.java
+++ b/src/main/java/com/example/mixin/ExampleMixin.java
@@ -1,16 +1,15 @@
-package net.fabricmc.example.mixin;
+package com.example.mixin;
-import net.fabricmc.example.ExampleMod;
-import net.minecraft.client.gui.screen.TitleScreen;
+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(TitleScreen.class)
+@Mixin(MinecraftServer.class)
public class ExampleMixin {
- @Inject(at = @At("HEAD"), method = "init()V")
+ @Inject(at = @At("HEAD"), method = "loadWorld")
private void init(CallbackInfo info) {
- ExampleMod.LOGGER.info("This line is printed by an example mod mixin!");
+ // This code is injected into the start of MinecraftServer.loadWorld()V
}
-}
+} \ No newline at end of file
diff --git a/src/main/java/net/fabricmc/example/ExampleMod.java b/src/main/java/net/fabricmc/example/ExampleMod.java
deleted file mode 100644
index a964189..0000000
--- a/src/main/java/net/fabricmc/example/ExampleMod.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package net.fabricmc.example;
-
-import net.fabricmc.api.ModInitializer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ExampleMod implements ModInitializer {
- // 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("modid");
-
- @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!");
- }
-}
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
index e2176c7..8b5ac34 100644
--- a/src/main/resources/fabric.mod.json
+++ b/src/main/resources/fabric.mod.json
@@ -1,38 +1,41 @@
{
- "schemaVersion": 1,
- "id": "modid",
- "version": "${version}",
-
- "name": "Example Mod",
- "description": "This is an example description! Tell everyone what your mod is about!",
- "authors": [
- "Me!"
- ],
- "contact": {
- "homepage": "https://fabricmc.net/",
- "sources": "https://github.com/FabricMC/fabric-example-mod"
- },
-
- "license": "CC0-1.0",
- "icon": "assets/modid/icon.png",
-
- "environment": "*",
- "entrypoints": {
- "main": [
- "net.fabricmc.example.ExampleMod"
- ]
- },
- "mixins": [
- "modid.mixins.json"
- ],
-
- "depends": {
- "fabricloader": ">=0.14.19",
- "fabric-api": "*",
- "minecraft": "~1.19.4",
- "java": ">=17"
- },
- "suggests": {
- "another-mod": "*"
- }
-}
+ "schemaVersion": 1,
+ "id": "modid",
+ "version": "${version}",
+ "name": "Example mod",
+ "description": "This is an example description! Tell everyone what your mod is about!",
+ "authors": [
+ "Me!"
+ ],
+ "contact": {
+ "homepage": "https://fabricmc.net/",
+ "sources": "https://github.com/FabricMC/fabric-example-mod"
+ },
+ "license": "CC0-1.0",
+ "icon": "assets/modid/icon.png",
+ "environment": "*",
+ "entrypoints": {
+ "main": [
+ "com.example.ExampleMod"
+ ],
+ "client": [
+ "com.example.ExampleModClient"
+ ]
+ },
+ "mixins": [
+ "modid.mixins.json",
+ {
+ "config": "modid.client.mixins.json",
+ "environment": "client"
+ }
+ ],
+ "depends": {
+ "fabricloader": ">=0.14.21",
+ "minecraft": "~1.20",
+ "java": ">=17",
+ "fabric-api": "*"
+ },
+ "suggests": {
+ "another-mod": "*"
+ }
+} \ No newline at end of file
diff --git a/src/main/resources/modid.mixins.json b/src/main/resources/modid.mixins.json
index 7c42cb4..166e787 100644
--- a/src/main/resources/modid.mixins.json
+++ b/src/main/resources/modid.mixins.json
@@ -1,14 +1,11 @@
{
- "required": true,
- "minVersion": "0.8",
- "package": "net.fabricmc.example.mixin",
- "compatibilityLevel": "JAVA_17",
- "mixins": [
- ],
- "client": [
- "ExampleMixin"
- ],
- "injectors": {
- "defaultRequire": 1
- }
-}
+ "required": true,
+ "package": "com.example.mixin",
+ "compatibilityLevel": "JAVA_17",
+ "mixins": [
+ "ExampleMixin"
+ ],
+ "injectors": {
+ "defaultRequire": 1
+ }
+} \ No newline at end of file