mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-16 01:15:08 +01:00
Compare commits
8 Commits
architectu
...
d954b32461
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d954b32461 | ||
|
|
a940a96bc7 | ||
|
|
b7c9d83078 | ||
|
|
9602736335 | ||
|
|
30d213b92c | ||
|
|
b61b2cdf12 | ||
|
|
bcde119f23 | ||
|
|
b08e38ae11 |
@@ -3,7 +3,7 @@ import groovy.json.JsonOutput
|
||||
|
||||
plugins {
|
||||
id "architectury-plugin" version "3.4-SNAPSHOT"
|
||||
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
|
||||
id "dev.architectury.loom" version "1.10.+" apply false
|
||||
id "me.shedaniel.unified-publishing" version "0.1.+" apply false
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
}
|
||||
|
||||
architectury {
|
||||
common(rootProject.enabled_platforms.split(","))
|
||||
}
|
||||
@@ -21,3 +25,16 @@ publishing {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
testOutput.extendsFrom(testImplementation)
|
||||
}
|
||||
|
||||
tasks.register('testJar', Jar) {
|
||||
from sourceSets.test.output
|
||||
archiveClassifier = 'tests'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
testOutput testJar
|
||||
}
|
||||
@@ -45,6 +45,6 @@ public class MidnightConfigOverviewScreen extends Screen {
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
this.list.render(context, mouseX, mouseY, delta);
|
||||
context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 10, 0xFFFFFF);
|
||||
context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 10, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,13 @@ import com.google.common.collect.Lists;
|
||||
import com.google.gson.*; import com.google.gson.stream.*;
|
||||
import eu.midnightdust.lib.util.PlatformFunctions;
|
||||
import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gl.RenderPipelines;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.Element; import net.minecraft.client.gui.Selectable;
|
||||
import net.minecraft.client.gui.screen.ConfirmLinkScreen; import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.tab.GridScreenTab; import net.minecraft.client.gui.tab.Tab; import net.minecraft.client.gui.tab.TabManager;
|
||||
import net.minecraft.client.gui.tooltip.Tooltip; import net.minecraft.client.gui.widget.*;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.screen.ScreenTexts;
|
||||
@@ -131,7 +132,7 @@ public abstract class MidnightConfig {
|
||||
entries.values().forEach(info -> {
|
||||
if (info.field != null && info.entry != null) {
|
||||
try {
|
||||
info.value = info.field.get(null);
|
||||
info.value = info.field.get(null) == null ? info.defaultValue : info.field.get(null);
|
||||
info.tempValue = info.toTemporaryValue();
|
||||
info.updateConditions();
|
||||
} catch (IllegalAccessException ignored) {}
|
||||
@@ -446,7 +447,7 @@ public abstract class MidnightConfig {
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
this.list.render(context, mouseX, mouseY, delta);
|
||||
if (tabs.size() < 2) context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 10, 0xFFFFFF);
|
||||
if (tabs.size() < 2) context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 10, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
@Environment(EnvType.CLIENT)
|
||||
@@ -458,7 +459,7 @@ public abstract class MidnightConfig {
|
||||
@Override
|
||||
protected void drawHeaderAndFooterSeparators(DrawContext context) {
|
||||
if (renderHeaderSeparator) super.drawHeaderAndFooterSeparators(context);
|
||||
else context.drawTexture(RenderLayer::getGuiTextured, this.client.world == null ? Screen.FOOTER_SEPARATOR_TEXTURE : Screen.INWORLD_FOOTER_SEPARATOR_TEXTURE, this.getX(), this.getBottom(), 0, 0, this.getWidth(), 2, 32, 2);
|
||||
else context.drawTexture(RenderPipelines.GUI_TEXTURED, this.client.world == null ? Screen.FOOTER_SEPARATOR_TEXTURE : Screen.INWORLD_FOOTER_SEPARATOR_TEXTURE, this.getX(), this.getBottom(), 0, 0, this.getWidth(), 2, 32, 2);
|
||||
}
|
||||
public void addButton(List<ClickableWidget> buttons, Text text, EntryInfo info) { this.addEntry(new ButtonEntry(buttons, text, info)); }
|
||||
public void clear() { this.clearEntries(); }
|
||||
@@ -479,18 +480,16 @@ public abstract class MidnightConfig {
|
||||
|
||||
if (text != null && (!text.getString().contains("spacer") || !buttons.isEmpty())) {
|
||||
title = new MultilineTextWidget((centered) ? (scaledWidth / 2 - (textRenderer.getWidth(text) / 2)) : 12, 0, Text.of(text), textRenderer);
|
||||
title.setCentered(centered);
|
||||
if (info != null) title.setTooltip(info.getTooltip(false));
|
||||
title.setMaxWidth(buttons.size() > 1 ? buttons.get(1).getX() - 24 : scaledWidth - 24);
|
||||
title.setMaxWidth(!buttons.isEmpty() ? buttons.get(buttons.size() > 2 ? buttons.size()-1 : 0).getX() - 16 : scaledWidth - 24);
|
||||
}
|
||||
}
|
||||
public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
|
||||
buttons.forEach(b -> { b.setY(y); b.render(context, mouseX, mouseY, tickDelta);});
|
||||
if (title != null) {
|
||||
title.setY(y+5);
|
||||
title.renderWidget(context, mouseX, mouseY, tickDelta);
|
||||
|
||||
boolean tooltipVisible = mouseX >= title.getX() && mouseX < title.getWidth() + title.getX() && mouseY >= title.getY() && mouseY < title.getHeight() + title.getY();
|
||||
if (tooltipVisible && title.getTooltip() != null) context.drawOrderedTooltip(textRenderer, title.getTooltip().getLines(MinecraftClient.getInstance()), mouseX, mouseY);
|
||||
title.render(context, mouseX, mouseY, tickDelta);
|
||||
|
||||
if (info.entry != null && !this.buttons.isEmpty() && this.buttons.getFirst() instanceof ClickableWidget widget) {
|
||||
int idMode = this.info.entry.idMode();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package eu.midnightdust.fabric.example;
|
||||
package eu.midnightdust.test;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import eu.midnightdust.lib.config.MidnightConfig;
|
||||
@@ -1,7 +1,7 @@
|
||||
package eu.midnightdust.fabric.example.config;
|
||||
package eu.midnightdust.test.config;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import eu.midnightdust.fabric.example.MidnightLibExtras;
|
||||
import eu.midnightdust.test.MidnightLibExtras;
|
||||
import eu.midnightdust.lib.config.MidnightConfig;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
@@ -11,7 +11,27 @@ architectury {
|
||||
fabric()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
test {
|
||||
compileClasspath += main.compileClasspath
|
||||
runtimeClasspath += main.runtimeClasspath
|
||||
java {
|
||||
srcDirs.add('src/test/java' as File)
|
||||
}
|
||||
resources {
|
||||
srcDirs.add('src/test/resources' as File)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loom {
|
||||
runs {
|
||||
testClient {
|
||||
client()
|
||||
configName = "Test Minecraft Client"
|
||||
source sourceSets.test
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
@@ -27,10 +47,12 @@ configurations {
|
||||
dependencies {
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
||||
modCompileOnly ("com.terraformersmc:modmenu:${rootProject.mod_menu_version}")
|
||||
modCompileOnly("com.terraformersmc:modmenu:${rootProject.mod_menu_version}")
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
|
||||
|
||||
testImplementation common(project(path: ':common', configuration: 'testOutput'))
|
||||
}
|
||||
|
||||
processResources {
|
||||
@@ -41,6 +63,14 @@ processResources {
|
||||
}
|
||||
}
|
||||
|
||||
processTestResources {
|
||||
inputs.property "version", rootProject.version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": rootProject.version
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
exclude "architectury.common.json"
|
||||
|
||||
@@ -71,7 +101,7 @@ unifiedPublishing {
|
||||
releaseType = "$project.release_type"
|
||||
changelog = releaseChangelog()
|
||||
gameVersions = []
|
||||
gameLoaders = ["fabric","quilt"]
|
||||
gameLoaders = ["fabric", "quilt"]
|
||||
mainPublication remapJar
|
||||
relations {
|
||||
depends {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package eu.midnightdust.test.fabric;
|
||||
|
||||
import eu.midnightdust.test.config.MidnightConfigExample;
|
||||
import eu.midnightdust.lib.config.MidnightConfig;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
|
||||
public class MLExampleFabric implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
MidnightConfig.init("modid", MidnightConfigExample.class);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "midnightlib-example",
|
||||
"id": "testmod",
|
||||
"version": "${version}",
|
||||
|
||||
"name": "MidnightLib Example",
|
||||
@@ -13,7 +13,7 @@
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"eu.midnightdust.fabric.example.MLExampleFabric"
|
||||
"eu.midnightdust.test.fabric.MLExampleFabric"
|
||||
]
|
||||
},
|
||||
"depends": {
|
||||
@@ -1,21 +1,21 @@
|
||||
org.gradle.jvmargs=-Xmx4096M
|
||||
|
||||
minecraft_version=1.21.4
|
||||
supported_versions=1.21.5
|
||||
yarn_mappings=1.21.4+build.1
|
||||
minecraft_version=1.21.6
|
||||
supported_versions=
|
||||
yarn_mappings=1.21.6+build.1
|
||||
enabled_platforms=fabric,neoforge
|
||||
|
||||
archives_base_name=midnightlib
|
||||
mod_version=1.7.3
|
||||
mod_version=1.7.6-rc.1
|
||||
maven_group=eu.midnightdust
|
||||
release_type=release
|
||||
curseforge_id=488090
|
||||
modrinth_id=codAaoxh
|
||||
|
||||
fabric_loader_version=0.16.9
|
||||
fabric_api_version=0.110.5+1.21.4
|
||||
fabric_loader_version=0.16.14
|
||||
fabric_api_version=0.127.0+1.21.6
|
||||
|
||||
neoforge_version=21.4.3-beta
|
||||
neoforge_version=21.6.0-beta
|
||||
yarn_mappings_patch_neoforge_version = 1.21+build.4
|
||||
|
||||
mod_menu_version = 9.0.0
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
distributionUrl=https://mirrors.aliyun.com/gradle/distributions/v8.14.3/gradle-8.14.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -13,11 +13,44 @@ repositories {
|
||||
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
neoForge()
|
||||
neoForge {
|
||||
platformPackage = "neoforge"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
test {
|
||||
compileClasspath += main.compileClasspath
|
||||
runtimeClasspath += main.runtimeClasspath
|
||||
java {
|
||||
srcDirs.add('src/test/java' as File)
|
||||
}
|
||||
resources {
|
||||
srcDirs.add('src/test/resources' as File)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = project(":common").loom.accessWidenerPath
|
||||
|
||||
runs {
|
||||
testClient {
|
||||
client()
|
||||
name = "Test Minecraft Client"
|
||||
|
||||
mods {
|
||||
create('midnightlib') {
|
||||
sourceSet sourceSets.main
|
||||
}
|
||||
create('testmod') {
|
||||
sourceSet sourceSets.test
|
||||
}
|
||||
}
|
||||
source sourceSets.test
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
configurations {
|
||||
@@ -44,6 +77,10 @@ dependencies {
|
||||
|
||||
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
|
||||
shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge')
|
||||
|
||||
// testImplementation common(project(path: ':common', configuration: 'namedElements')) { transitive false }
|
||||
testImplementation common(project(path: ':common', configuration: 'testOutput')) { transitive false }
|
||||
testImplementation sourceSets.main.output
|
||||
}
|
||||
|
||||
processResources {
|
||||
@@ -54,6 +91,14 @@ processResources {
|
||||
}
|
||||
}
|
||||
|
||||
processTestResources {
|
||||
inputs.property 'version', rootProject.version
|
||||
|
||||
filesMatching('META-INF/neoforge.mods.toml') {
|
||||
expand version: rootProject.version
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadowBundle]
|
||||
archiveClassifier = 'dev-shadow'
|
||||
@@ -105,4 +150,4 @@ unifiedPublishing {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package eu.midnightdust.test.neoforge;
|
||||
|
||||
import eu.midnightdust.test.config.MidnightConfigExample;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
|
||||
@Mod("testmod")
|
||||
public class MLExampleNeoForge {
|
||||
public MLExampleNeoForge() {
|
||||
MidnightConfigExample.init("modid", MidnightConfigExample.class);
|
||||
}
|
||||
}
|
||||
34
neoforge/src/test/resources/META-INF/neoforge.mods.toml
Normal file
34
neoforge/src/test/resources/META-INF/neoforge.mods.toml
Normal file
@@ -0,0 +1,34 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "[2,)"
|
||||
#issueTrackerURL = ""
|
||||
license = "MIT License"
|
||||
|
||||
[[mods]]
|
||||
modId = "testmod"
|
||||
version = "${version}"
|
||||
displayName = "Example Mod"
|
||||
authors = "TeamMidnightDust, Motschen"
|
||||
description = '''
|
||||
Example Mod for Team MidnightDust's mods.
|
||||
'''
|
||||
|
||||
[[dependencies.testmod]]
|
||||
modId = "neoforge"
|
||||
mandatory = true
|
||||
versionRange = "[20.5,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.testmod]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "[1.20.5,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.testmod]]
|
||||
modId = "midnightlib"
|
||||
mandatory = true
|
||||
versionRange = "[1.0,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
@@ -9,9 +9,7 @@ pluginManagement {
|
||||
|
||||
include("common")
|
||||
include("fabric")
|
||||
include("test-fabric")
|
||||
include("neoforge")
|
||||
include("test-neoforge")
|
||||
//include("quilt")
|
||||
|
||||
rootProject.name = "midnightlib"
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
plugins {
|
||||
id 'com.github.johnrengelman.shadow'
|
||||
id "me.shedaniel.unified-publishing"
|
||||
}
|
||||
repositories {
|
||||
maven { url "https://maven.terraformersmc.com/releases" }
|
||||
}
|
||||
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
fabric()
|
||||
}
|
||||
|
||||
loom {
|
||||
}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentFabric.extendsFrom common
|
||||
archivesBaseName = rootProject.archives_base_name + "-fabric"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
||||
|
||||
implementation project(path: ":fabric", configuration: "namedElements")
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package eu.midnightdust.fabric.example;
|
||||
|
||||
import eu.midnightdust.fabric.example.config.MidnightConfigExample;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
|
||||
public class MLExampleFabric implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
MidnightConfigExample.init("modid", MidnightConfigExample.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user