This commit is contained in:
Cameron Reed 2024-07-01 00:04:16 -06:00
parent 563ac4a06e
commit 371f5effad
25 changed files with 172 additions and 69 deletions

View File

@ -1,11 +1,15 @@
plugins { plugins {
id 'fabric-loom' version '1.1-SNAPSHOT' id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish' id 'maven-publish'
} }
version = project.mod_version version = project.mod_version
group = project.maven_group group = project.maven_group
base {
archivesName = project.archives_base_name
}
repositories { repositories {
// Add repositories to retrieve artifacts from in here. // Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because // You should only use this when depending on other mods because
@ -18,6 +22,17 @@ repositories {
} }
} }
loom {
splitEnvironmentSourceSets()
mods {
"cmods" {
sourceSet sourceSets.client
sourceSet sourceSets.main
}
}
}
dependencies { dependencies {
// To change the versions see the gradle.properties file // To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}" minecraft "com.mojang:minecraft:${project.minecraft_version}"
@ -31,47 +46,37 @@ dependencies {
processResources { processResources {
inputs.property "version", project.version inputs.property "version", project.version
filteringCharset "UTF-8"
filesMatching("fabric.mod.json") { filesMatching("fabric.mod.json") {
expand "version": project.version expand "version": project.version
} }
} }
def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is it.options.release = 21
// 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"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
it.options.release = targetJavaVersion
}
} }
java { java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
archivesBaseName = project.archives_base_name
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present. // if it is present.
// If you remove this line, sources will not be generated. // If you remove this line, sources will not be generated.
withSourcesJar() withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
} }
jar { jar {
from("LICENSE") { from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" } rename { "${it}_${project.base.archivesName.get()}"}
} }
} }
// configure the maven publication // configure the maven publication
publishing { publishing {
publications { publications {
mavenJava(MavenPublication) { create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java from components.java
} }
} }
@ -84,3 +89,91 @@ publishing {
// retrieving dependencies. // retrieving dependencies.
} }
} }
//plugins {
// id 'fabric-loom' version '1.7-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.
// maven {
// name = 'TerraformersMC'
// url = 'https://maven.terraformersmc.com/releases'
// }
//}
//
//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}"
// modCompileOnly "com.terraformersmc:modmenu:4.1.1"
//}
//
//processResources {
// inputs.property "version", project.version
// filteringCharset "UTF-8"
//
// filesMatching("fabric.mod.json") {
// expand "version": project.version
// }
//}
//
//def targetJavaVersion = 21
//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"
// if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
// it.options.release = targetJavaVersion
// }
//}
//
//java {
// def javaVersion = JavaVersion.toVersion(targetJavaVersion)
// if (JavaVersion.current() < javaVersion) {
// toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
// }
// archivesBaseName = project.archives_base_name
// // 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.
// }
//}

View File

@ -1,14 +1,15 @@
# Done to increase the memory available to gradle. # Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true
# Fabric Properties # Fabric Properties
# check these on https://modmuss50.me/fabric.html # check these on https://modmuss50.me/fabric.html
minecraft_version=1.20.4 minecraft_version=1.21
yarn_mappings=1.20.4+build.3 yarn_mappings=1.21+build.7
loader_version=0.15.6 loader_version=0.15.11
# Mod Properties # Mod Properties
mod_version=1.2.1 mod_version=1.2.2
maven_group=cmods maven_group=cmods
archives_base_name=cmods archives_base_name=cmods
# Dependencies # Dependencies
# check this on https://modmuss50.me/fabric.html # check this on https://modmuss50.me/fabric.html
fabric_version=0.96.1+1.20.4 fabric_version=0.100.4+1.21

View File

@ -1,5 +1,6 @@
#Sun Jun 30 01:31:47 MDT 2024
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -1,4 +1,4 @@
package cmods.cmods.client; package cmods.cmods;
import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;

View File

@ -1,6 +1,6 @@
package cmods.cmods.client; package cmods.cmods;
import cmods.cmods.client.ui.CmodsOptionsScreen; import cmods.cmods.ui.CmodsOptionsScreen;
import com.terraformersmc.modmenu.api.ConfigScreenFactory; import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi; import com.terraformersmc.modmenu.api.ModMenuApi;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;

View File

@ -1,6 +1,6 @@
package cmods.cmods.api; package cmods.cmods.api;
import cmods.cmods.client.ui.Line; import cmods.cmods.ui.Line;
import net.minecraft.util.Pair; import net.minecraft.util.Pair;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,9 +1,9 @@
package cmods.cmods.api; package cmods.cmods.api;
import cmods.cmods.client.options.CmodsOptions; import cmods.cmods.options.CmodsOptions;
import cmods.cmods.client.ui.CmodsOptionsScreen; import cmods.cmods.ui.CmodsOptionsScreen;
import cmods.cmods.client.ui.Line; import cmods.cmods.ui.Line;
import cmods.cmods.client.ui.UIOptionsScreen; import cmods.cmods.ui.UIOptionsScreen;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,13 +1,14 @@
package cmods.cmods.mixin; package cmods.cmods.mixin;
import cmods.cmods.api.HudRenderCallback; import cmods.cmods.api.HudRenderCallback;
import cmods.cmods.client.options.CmodsOptions; import cmods.cmods.options.CmodsOptions;
import cmods.cmods.client.ui.Line; import cmods.cmods.ui.Line;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer; import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.DebugHud; import net.minecraft.client.gui.hud.DebugHud;
import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Pair; import net.minecraft.util.Pair;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -31,7 +32,7 @@ public abstract class HudMixin {
@Shadow @Final private DebugHud debugHud; @Shadow @Final private DebugHud debugHud;
@Inject(at = @At("TAIL"), method = "render") @Inject(at = @At("TAIL"), method = "render")
private void render(DrawContext context, float tickDelta, CallbackInfo ci) { private void render(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
CmodsOptions options = CmodsOptions.getInstance(); CmodsOptions options = CmodsOptions.getInstance();
if (this.debugHud.shouldShowDebugHud() || this.client.isPaused() || client.player == null || if (this.debugHud.shouldShowDebugHud() || this.client.isPaused() || client.player == null ||
@ -41,7 +42,6 @@ public abstract class HudMixin {
TextRenderer textRenderer = this.getTextRenderer(); TextRenderer textRenderer = this.getTextRenderer();
ArrayList<Line> lines = new ArrayList<>(); ArrayList<Line> lines = new ArrayList<>();
this.client.getCurrentFps();
int x = 5; int x = 5;
int y = 5; int y = 5;

View File

@ -1,6 +1,6 @@
package cmods.cmods.mixin; package cmods.cmods.mixin;
import cmods.cmods.client.ui.CmodsOptionsScreen; import cmods.cmods.ui.CmodsOptionsScreen;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.OptionsScreen; import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;

View File

@ -1,7 +1,7 @@
package cmods.cmods.mixin; package cmods.cmods.mixin;
import cmods.cmods.client.ui.CmodsOptionsScreen; import cmods.cmods.ui.CmodsOptionsScreen;
import net.minecraft.client.gui.screen.GameMenuScreen; import net.minecraft.client.gui.screen.GameMenuScreen;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;

View File

@ -1,4 +1,4 @@
package cmods.cmods.client.options; package cmods.cmods.options;
public class BooleanOption extends Option<Boolean> { public class BooleanOption extends Option<Boolean> {
public BooleanOption(Boolean default_value) { public BooleanOption(Boolean default_value) {

View File

@ -1,4 +1,4 @@
package cmods.cmods.client.options; package cmods.cmods.options;
import cmods.cmods.api.ModuleOptions; import cmods.cmods.api.ModuleOptions;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;

View File

@ -1,4 +1,4 @@
package cmods.cmods.client.options; package cmods.cmods.options;
public class IntegerOption extends Option<Integer> { public class IntegerOption extends Option<Integer> {
public IntegerOption(Integer default_value) { public IntegerOption(Integer default_value) {

View File

@ -1,4 +1,4 @@
package cmods.cmods.client.options; package cmods.cmods.options;
public class Option<T> { public class Option<T> {
public T value; public T value;

View File

@ -1,8 +1,8 @@
package cmods.cmods.client.ui; package cmods.cmods.ui;
import cmods.cmods.api.ButtonBuilder; import cmods.cmods.api.ButtonBuilder;
import cmods.cmods.client.CmodsClient; import cmods.cmods.CmodsClient;
import cmods.cmods.client.options.CmodsOptions; import cmods.cmods.options.CmodsOptions;
import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;
@ -14,7 +14,7 @@ import net.minecraft.util.Pair;
import java.util.ArrayList; import java.util.ArrayList;
import static cmods.cmods.client.ui.Constants.*; import static cmods.cmods.ui.Constants.*;
public class CmodsOptionsScreen extends Screen { public class CmodsOptionsScreen extends Screen {
private final CmodsOptions options = CmodsOptions.getInstance(); private final CmodsOptions options = CmodsOptions.getInstance();
@ -68,14 +68,14 @@ public class CmodsOptionsScreen extends Screen {
} }
public void render(DrawContext context, int mouseX, int mouseY, float delta) { public void render(DrawContext context, int mouseX, int mouseY, float delta) {
renderBackground(context, mouseX, mouseY, delta); // renderBackground(context, mouseX, mouseY, delta);
Text versionText = Text.literal("v" + CmodsClient.version); super.render(context, mouseX, mouseY, delta);
Text versionText = Text.literal("v" + CmodsClient.version);
context.drawCenteredTextWithShadow(textRenderer, title, this.width / 2, 15, 0xffffff); context.drawCenteredTextWithShadow(textRenderer, title, this.width / 2, 15, 0xffffff);
context.drawTextWithShadow(textRenderer, versionText, this.width - textRenderer.getWidth(versionText) - 2, context.drawTextWithShadow(textRenderer, versionText, this.width - textRenderer.getWidth(versionText) - 2,
this.height - textRenderer.fontHeight - 2, 0xffffff); this.height - textRenderer.fontHeight - 2, 0xffffff);
super.render(context, mouseX, mouseY, delta);
} }
public void removed() { public void removed() {

View File

@ -1,4 +1,4 @@
package cmods.cmods.client.ui; package cmods.cmods.ui;
public class Constants { public class Constants {
public static final int buttonWidth = 150; public static final int buttonWidth = 150;

View File

@ -1,6 +1,6 @@
package cmods.cmods.client.ui; package cmods.cmods.ui;
import cmods.cmods.client.options.IntegerOption; import cmods.cmods.options.IntegerOption;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.Widget; import net.minecraft.client.gui.widget.Widget;
import net.minecraft.client.gui.widget.WrapperWidget; import net.minecraft.client.gui.widget.WrapperWidget;

View File

@ -1,4 +1,4 @@
package cmods.cmods.client.ui; package cmods.cmods.ui;
import net.minecraft.text.Text; import net.minecraft.text.Text;

View File

@ -1,6 +1,6 @@
package cmods.cmods.client.ui; package cmods.cmods.ui;
import cmods.cmods.client.options.BooleanOption; import cmods.cmods.options.BooleanOption;
import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text; import net.minecraft.text.Text;
@ -15,7 +15,7 @@ public class ToggleButton extends ButtonWidget {
public ToggleButton(int x, int y, int width, int height, Text name, BooleanOption option) { public ToggleButton(int x, int y, int width, int height, Text name, BooleanOption option) {
this(x, y, width, height, name, option, ButtonWidget.DEFAULT_NARRATION_SUPPLIER); this(x, y, width, height, name, option, DEFAULT_NARRATION_SUPPLIER);
} }
public ToggleButton(int x, int y, int width, int height, Text name, BooleanOption option, public ToggleButton(int x, int y, int width, int height, Text name, BooleanOption option,

View File

@ -1,7 +1,7 @@
package cmods.cmods.client.ui; package cmods.cmods.ui;
import cmods.cmods.api.ButtonBuilder; import cmods.cmods.api.ButtonBuilder;
import cmods.cmods.client.options.CmodsOptions; import cmods.cmods.options.CmodsOptions;
import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;
@ -13,7 +13,7 @@ import net.minecraft.util.Pair;
import java.util.ArrayList; import java.util.ArrayList;
import static cmods.cmods.client.ui.Constants.*; import static cmods.cmods.ui.Constants.*;
public class UIOptionsScreen extends Screen { public class UIOptionsScreen extends Screen {
private final Screen parent; private final Screen parent;
@ -73,9 +73,9 @@ public class UIOptionsScreen extends Screen {
} }
public void render(DrawContext context, int mouseX, int mouseY, float delta) { public void render(DrawContext context, int mouseX, int mouseY, float delta) {
this.renderBackground(context, mouseX, mouseY, delta); // this.renderBackground(context, mouseX, mouseY, delta);
context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, 15, 0xffffff);
super.render(context, mouseX, mouseY, delta); super.render(context, mouseX, mouseY, delta);
context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, 15, 0xffffff);
} }
public void removed() { public void removed() {

View File

@ -2,7 +2,7 @@
"required": true, "required": true,
"minVersion": "0.8", "minVersion": "0.8",
"package": "cmods.cmods.mixin", "package": "cmods.cmods.mixin",
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_21",
"mixins": [ "mixins": [
], ],
"client": [ "client": [

View File

@ -5,24 +5,32 @@
"name": "Cmods", "name": "Cmods",
"description": "<description>", "description": "<description>",
"authors": [ "authors": [
"CameronReed" "Cameron Reed"
], ],
"contact": { "contact": {
"repo": "https://gitea.cam123.dev/" "sources": "https://gitea.cam123.dev/"
}, },
"license": "MIT", "license": "MIT",
"icon": "assets/cmods/icon.png", "icon": "assets/cmods/icon.png",
"environment": "client", "environment": "client",
"entrypoints": { "entrypoints": {
"client": ["cmods.cmods.client.CmodsClient"], "client": [
"modmenu": ["cmods.cmods.client.ModMenuConfig"] "cmods.cmods.CmodsClient"
],
"modmenu": [
"cmods.cmods.ModMenuConfig"
]
}, },
"mixins": [ "mixins": [
"cmods.mixins.json" {
"config": "cmods.client.mixins.json",
"environment": "client"
}
], ],
"depends": { "depends": {
"fabricloader": ">=0.14.10", "fabricloader": ">=0.14.10",
"fabric": "*", "minecraft": "1.21.0",
"minecraft": "1.20.4" "java": ">=21",
"fabric-api": "*"
} }
} }