Skip to content

Commit

Permalink
[Port] Update to special/flint-1.21.1 (v2.5.3)
Browse files Browse the repository at this point in the history
  • Loading branch information
CDAGaming committed Jan 9, 2025
1 parent 065e644 commit 4f0c2cc
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 21 deletions.
12 changes: 10 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ val extIsMCPJar = extIsJarMod && "mc_mappings_type"() == "mcp"

// Only apply ATs to forge on non-legacy builds, or on Legacy Protocols above 1.5
// due to the way Forge requires core-mods for lower version usage
val extAWFile = file("$rootDir/fabric/src/main/resources/$extModId.accesswidener")
val extAWFile = file("$rootDir/flint/src/main/resources/$extModId.accesswidener")
val extCanUseATs = extAWFile.exists() && (!extIsLegacy || extProtocol > 60)

// Setup Game Versions to upload for
Expand Down Expand Up @@ -143,6 +143,7 @@ subprojects {
maven("https://maven.legacyfabric.net/") {
name = "Legacy Fabric"
}
maven("https://maven.flintloader.net/releases")
// WagYourTail Mavens
maven("https://maven.wagyourtail.xyz/releases")
maven("https://maven.wagyourtail.xyz/snapshots")
Expand Down Expand Up @@ -170,6 +171,13 @@ subprojects {
side(if (isJarMod) "client" else "combined")
version(mcVersion)

flint {
if (accessWidenerFile.exists()) {
accessWidener(accessWidenerFile)
}
loader("flint_version"()!!)
}

mappings {
val mcMappings = "mc_mappings"()!!
when (mcMappingsType) {
Expand Down Expand Up @@ -296,7 +304,7 @@ subprojects {

// Setup UniLib attachment data
val libPrefix = "unilib_name"()!!
val libName = if (!isLoaderSource) "fabric" else name
val libName = if (!isLoaderSource) "flint" else name
val libVersion = "unilib_build_version"()!!
val libFile = "$libName${if (canDowngrade) "-native" else ""}"

Expand Down
15 changes: 0 additions & 15 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import xyz.wagyourtail.unimined.api.minecraft.patch.fabric.FabricLikePatcher
import java.util.regex.Pattern

/**
Expand All @@ -24,20 +23,6 @@ val fileFormat: String by extra

unimined.minecraft {
defaultRemapJar = false
if (!isJarMod) {
val fabricData: FabricLikePatcher.() -> Unit = {
if (accessWidenerFile.exists()) {
accessWidener(accessWidenerFile)
}
loader("fabric_loader_version"()!!)
customIntermediaries = true
}
if (isModern) {
fabric(fabricData)
} else {
legacyFabric(fabricData)
}
}
}

val shadeOnly: Configuration by configurations.creating
Expand Down
97 changes: 97 additions & 0 deletions flint/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import xyz.wagyourtail.unimined.api.mapping.task.ExportMappingsTask
import xyz.wagyourtail.unimined.api.minecraft.task.RemapJarTask

/**
* Retrieve a Project Property
*/
operator fun String.invoke(): String? {
return project.properties[this] as String?
}

val modName: String by extra
val modId: String by extra

val isLegacy: Boolean by extra
val protocol: Int by extra
val isJarMod: Boolean by extra
val accessWidenerFile: File by extra
val isMCPJar: Boolean by extra
val isModern: Boolean by extra
val versionFormat: String by extra
val versionLabel: String by extra
val mcVersionLabel: String by extra
val mcMappingsType: String by extra
val canUseATs: Boolean by extra
val baseVersionLabel: String by extra

unimined.minecraft {
// N/A
}

val common: Configuration by configurations.creating
val shadowCommon: Configuration by configurations.creating

configurations.compileClasspath.get().extendsFrom(common)
configurations.runtimeClasspath.get().extendsFrom(common)

dependencies {
// Flint API Implementation
"modImplementation"("net.flintloader:flint-api:${"flint_api_version"()}")
// Mod Menu API Implementation
"modImplementation"("${"modmenu_group"()}:ModMenu:${"modmenu_version"()}")

"common"(project(path = ":common")) { isTransitive = false }
"common"(project(path = ":common", configuration = "shade")) {
exclude(group = "com.google.code.gson")
}
"common"(project(path = ":common", configuration = "runtime"))
"shadowCommon"(project(path = ":common", configuration = "shadeOnly"))
"shadowCommon"(project(path = ":common")) { isTransitive = false }
}

val resourceTargets = listOf(
"flintmodule.json",
"pack.mcmeta"
)
val replaceProperties = mapOf(
"mod_id" to modId,
"mod_name" to modName,
"version" to baseVersionLabel,
"mcversion" to mcVersionLabel,
"loader_version_range" to "flint_loader_version_range"()
)

tasks.processResources {
inputs.properties(replaceProperties)

filesMatching(resourceTargets) {
expand(replaceProperties)
}
}

tasks.shadowJar {
mustRunAfter(project(":common").tasks.shadowJar)
dependsOn(project(":common").tasks.shadowJar)
from(zipTree(project(":common").tasks.shadowJar.get().archiveFile))
configurations = listOf(shadowCommon)
archiveClassifier.set("dev-shadow")
}

tasks.named<RemapJarTask>("remapJar") {
dependsOn(tasks.shadowJar.get())
asJar {
inputFile.set(tasks.shadowJar.get().archiveFile)
archiveClassifier.set(project.name)
}
}

tasks.jar {
archiveClassifier.set("dev")
}

tasks.sourcesJar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
val commonSources = project(":common").tasks.sourcesJar
dependsOn(commonSources.get())
from(commonSources.get().archiveFile.map { zipTree(it) })
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* MIT License
*
* Copyright (c) 2018 - 2025 CDAGaming ([email protected])
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.gitlab.cdagaming.craftpresence.flint;

import com.gitlab.cdagaming.craftpresence.CraftPresence;
import io.github.cdagaming.unicore.utils.OSUtils;
import net.flintloader.loader.api.FlintModule;

/**
* The Primary Application Class and Utilities
*
* @author CDAGaming
*/
public class CraftPresenceFlint implements FlintModule {
@Override
public void initializeModule() {
try {
if (OSUtils.JAVA_SPEC < 1.8f) {
throw new UnsupportedOperationException("Incompatible JVM!!! @MOD_NAME@ requires Java 8 or above to work properly!");
}
new CraftPresence(this::setupIntegrations);
} catch (NoClassDefFoundError ex) {
throw new UnsupportedOperationException("Unable to initialize @MOD_NAME@! @UNILIB_NAME@ (unilib) is required to run this mod (Requires @UNILIB_MIN_VERSION@ or above)", ex);
}
}

/**
* Setup external integrations and attachments to the primary application
*/
public void setupIntegrations() {
// N/A
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* MIT License
*
* Copyright (c) 2018 - 2025 CDAGaming ([email protected])
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.gitlab.cdagaming.craftpresence.flint.impl;

import com.gitlab.cdagaming.craftpresence.config.gui.MainGui;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;

/**
* Hook to provide Integration with ProspectorDev's ModMenu
*
* @author CDAGaming
*/
public class ModMenuImpl implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return MainGui::new;
}
}
4 changes: 4 additions & 0 deletions flint/src/main/resources/craftpresence.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessWidener v2 named

accessible field net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl postDisconnectScreen Lnet/minecraft/client/gui/screens/Screen;
accessible method com/mojang/realmsclient/RealmsMainScreen getSelectedServer ()Lcom/mojang/realmsclient/dto/RealmsServer;
15 changes: 15 additions & 0 deletions flint/src/main/resources/flintmodule.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"id": "${mod_id}",
"version": "${version}",
"name": "${mod_name}",
"description": "Completely Customize the way others see you play in Discord!",
"authors": [
"CDAGaming"
],
"license": "MIT",
"icon": "logo.png",
"entryPoints": {
"main": "com.gitlab.cdagaming.craftpresence.flint.CraftPresenceFlint",
"modmenu": "com.gitlab.cdagaming.craftpresence.flint.impl.ModMenuImpl"
}
}
Binary file added flint/src/main/resources/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions flint/src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"pack": {
"description": "${mod_name} Resources",
"pack_format": 34
}
}
12 changes: 8 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ org.gradle.daemon=false
mod_name=CraftPresence
mod_id=craftpresence
group=com.gitlab.cdagaming
enabled_platforms=fabric,forge,quilt,neoforge
enabled_platforms=flint
# Critical Info
isLegacy=false
isJarMod=false
Expand All @@ -15,7 +15,7 @@ mc_mappings=
mc_mappings_type=mojmap
mc_version=1.21.1
mc_protocol=767
display_version=
display_version=0.0.8
# Fabric Info
fabric_loader_version=0.16.9
fabric_api_version=0.114.0+1.21.1
Expand All @@ -37,6 +37,10 @@ neoforge_version=93
neo_fml_version_range=[1.0,)
neoforge_game_version_range=[1.21, 1.21.2)
neoforge_loader_version_range=[21.0.0-beta,)
# Flint Info
flint_version=0.0.8
flint_api_version=0.0.4+1.21
flint_loader_version_range=>=0.0.8
# Deployment Info
versionId=2.5.3
deploymentType=Release
Expand All @@ -56,5 +60,5 @@ unilib_name=UniLib
unilib_build_version=1.0.5
unilib_minimum_version=1.0.2
# Dependency Info
modmenu_group=com.terraformersmc
modmenu_version=11.0.3
modmenu_group=net.flintloader.modules
modmenu_version=1.0.2

0 comments on commit 4f0c2cc

Please sign in to comment.