Example mod
This commit is contained in:
parent
787b0403d7
commit
d2f9ca787c
55
exampleMod/build.gradle
Normal file
55
exampleMod/build.gradle
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
plugins {
|
||||||
|
id 'java'
|
||||||
|
id 'maven-publish'
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_16
|
||||||
|
targetCompatibility = JavaVersion.VERSION_16
|
||||||
|
|
||||||
|
version = "1.2.0"
|
||||||
|
group = "com.elitemastereric"
|
||||||
|
archivesBaseName = "examplemod"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
url 'https://jitpack.io'
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
url "https://repo.spongepowered.org/maven/"
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
url "https://maven.fabricmc.net/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// Dependency on the Hello World app
|
||||||
|
implementation project(':app')
|
||||||
|
implementation project(':modLoader')
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
inputs.property "version", project.version
|
||||||
|
filteringCharset "UTF-8"
|
||||||
|
|
||||||
|
filesMatching("fabric.mod.json") {
|
||||||
|
expand "version": project.version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||||
|
// this fixes some edge cases with special characters not displaying correctly
|
||||||
|
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||||
|
// If Javadoc is generated, this must be specified in that task too.
|
||||||
|
it.options.encoding = "UTF-8"
|
||||||
|
it.options.release = 16
|
||||||
|
}
|
||||||
|
|
||||||
|
task buildAndCopy(type: Copy) {
|
||||||
|
group 'build'
|
||||||
|
dependsOn 'assemble'
|
||||||
|
from "build/libs/"
|
||||||
|
into "../run/mods"
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.elitemastereric.examplemod;
|
||||||
|
|
||||||
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class ExampleMod implements ModInitializer {
|
||||||
|
public static final String MOD_ID = "examplemod";
|
||||||
|
public static final Logger LOGGER = Logger.getLogger(MOD_ID);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInitialize() {
|
||||||
|
// System.out.println("Hello Fabric world!");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.elitemastereric.examplemod.mixin;
|
||||||
|
|
||||||
|
import com.elitemastereric.helloworld.Main;
|
||||||
|
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.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(Main.class)
|
||||||
|
public class MainMixin {
|
||||||
|
@Inject(method = "getGreeting*", at = @At("RETURN"), cancellable = true)
|
||||||
|
public void injectGetGreeting(CallbackInfoReturnable<String> callbackInfo) {
|
||||||
|
callbackInfo.setReturnValue("Goodbye World!");
|
||||||
|
}
|
||||||
|
}
|
13
exampleMod/src/main/resources/examplemod.mixins.json
Normal file
13
exampleMod/src/main/resources/examplemod.mixins.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"package": "com.elitemastereric.examplemod.mixin",
|
||||||
|
"mixins": [
|
||||||
|
"MainMixin"
|
||||||
|
],
|
||||||
|
"client": [],
|
||||||
|
"server": [],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
27
exampleMod/src/main/resources/fabric.mod.json
Normal file
27
exampleMod/src/main/resources/fabric.mod.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"id": "examplemod",
|
||||||
|
"version": "${version}",
|
||||||
|
"name": "Hello World Example Mod",
|
||||||
|
"description": "An example mod for Hello World app",
|
||||||
|
"authors": [
|
||||||
|
"EliteMasterEric"
|
||||||
|
],
|
||||||
|
"contact": {
|
||||||
|
"homepage": "https://elitemastereric.com"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"environment": "*",
|
||||||
|
"entrypoints": {
|
||||||
|
"main": [
|
||||||
|
"com.elitemastereric.examplemod.ExampleMod"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"mixins": [
|
||||||
|
"examplemod.mixins.json"
|
||||||
|
],
|
||||||
|
"depends": {
|
||||||
|
"fabricloader": ">=0.13.3",
|
||||||
|
"helloworld": "1.0.*"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user