Skip to content

Commit

Permalink
[Port] Update to 1.20.2 (v2.5.3)
Browse files Browse the repository at this point in the history
  • Loading branch information
CDAGaming committed Jan 9, 2025
1 parent 41795c6 commit 957cfa4
Show file tree
Hide file tree
Showing 13 changed files with 279 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public void preTick() {
*/
private RealmsServer findRealmData(final ClientPacketListener connection) {
try {
if (connection.callbackScreen instanceof RealmsScreen realmsProxy &&
if (connection.postDisconnectScreen instanceof RealmsScreen realmsProxy &&
realmsProxy instanceof RealmsMainScreen realmsMainScreen) {
return realmsMainScreen.getSelectedServer();
}
Expand All @@ -297,7 +297,7 @@ public void updateData() {
// Note: A Realm is only checked for *once* under set conditions
if (!hasCheckedRealm) {
final boolean canCheckRealm = newServerData != null && newConnection != null;
if (canCheckRealm && CraftPresence.instance.isConnectedToRealms()) {
if (canCheckRealm && newServerData.isRealm()) {
currentRealmData = findRealmData(newConnection);
isOnRealm = currentRealmData != null;
}
Expand Down Expand Up @@ -586,7 +586,7 @@ public void verifyAndJoin(final String secret) {
final boolean isValidSecret = boolParts.length <= 4 && stringParts.length <= 3 && containsValidClientID;

if (isValidSecret) {
ModUtils.executeOnMainThread(CraftPresence.instance, () -> joinServer(new ServerData(serverName, serverIP, false)));
ModUtils.executeOnMainThread(CraftPresence.instance, () -> joinServer(new ServerData(serverName, serverIP, ServerData.Type.OTHER)));
} else {
Constants.LOG.error(Constants.TRANSLATOR.translate("craftpresence.logger.error.discord.join", secret));
}
Expand Down Expand Up @@ -847,7 +847,7 @@ public void initPresence() {
// Attempt to find alternative icons, if no overrides are present
if (StringUtils.isNullOrEmpty(currentServerIcon)) {
// Logic cloned from ScrollableListControl#renderSlotItem
final String originalName = currentRealmData.ownerUUID;
final String originalName = currentRealmData.ownerUUID.toString();
final boolean isValidUuid = StringUtils.isValidUuid(originalName);
if (!CraftPresence.CONFIG.hasChanged() && CraftPresence.CONFIG.advancedSettings.allowEndpointIcons &&
!StringUtils.isNullOrEmpty(CraftPresence.CONFIG.advancedSettings.playerSkinEndpoint)) {
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/resources/craftpresence.accesswidener
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessWidener v2 named

accessible field net/minecraft/client/multiplayer/ClientPacketListener callbackScreen Lnet/minecraft/client/gui/screens/Screen;
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;
2 changes: 1 addition & 1 deletion fabric/src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"description": "${mod_name} Resources",
"pack_format": 15
"pack_format": 18
}
}
2 changes: 1 addition & 1 deletion forge/src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
public net.minecraft.client.multiplayer.ClientPacketListener callbackScreen
public net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl postDisconnectScreen
public com.mojang.realmsclient.RealmsMainScreen getSelectedServer()Lcom/mojang/realmsclient/dto/RealmsServer;
2 changes: 1 addition & 1 deletion forge/src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"description": "${mod_name} Resources",
"pack_format": 15
"pack_format": 18
}
}
34 changes: 19 additions & 15 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,42 @@ org.gradle.daemon=false
mod_name=CraftPresence
mod_id=craftpresence
group=com.gitlab.cdagaming
enabled_platforms=fabric,forge,quilt
enabled_platforms=fabric,forge,quilt,neoforge
# Critical Info
isLegacy=false
isJarMod=false
# Mapping Info
mc_mappings=
mc_mappings_type=mojmap
mc_version=1.20.1
mc_protocol=763
mc_version=1.20.2
mc_protocol=764
display_version=
# Fabric Info
fabric_loader_version=0.16.9
fabric_api_version=0.92.2+1.20.1
fabric_game_version_range=>=1.20 <1.20.2
fabric_api_version=0.91.6+1.20.2
fabric_game_version_range=>=1.20.2 <1.20.3
fabric_loader_version_range=>=0.13.0
# Quilt Info
quilt_loader_version=0.26.3
quilt_api_version=6.2.0+1.20.1
quilt_fabric_api_version=7.6.0+0.92.2-1.20.1
quilt_game_version_range=>=1.20,<1.20.2
quilt_api_version=7.0.0-alpha.13+1.20.2
quilt_fabric_api_version=8.0.0-alpha.6+0.91.6-1.20.2
quilt_game_version_range=>=1.20.2,<1.20.3
quilt_loader_version_range=>=0.19.2
# Forge Info
forge_version=47.1.0
fml_version_range=[46,)
forge_game_version_range=[1.20, 1.20.2)
forge_loader_version_range=[46.0.0,)
additional_forge_loaders=neoforge
forge_version=48.1.0
fml_version_range=[48,)
forge_game_version_range=[1.20.2, 1.20.3)
forge_loader_version_range=[48.0.0,)
# NeoForge Info
neoforge_version=88
neo_fml_version_range=[1.0,)
neoforge_game_version_range=[1.20.2, 1.20.3)
neoforge_loader_version_range=[20.2,)
# Deployment Info
versionId=2.5.3
deploymentType=Release
versionLabel=Release
additional_mc_versions=1.20
additional_mc_versions=
# Integration Info
source_java_version=21
build_java_version=17
Expand All @@ -53,4 +57,4 @@ unilib_build_version=1.0.5
unilib_minimum_version=1.0.1
# Dependency Info
modmenu_group=com.terraformersmc
modmenu_version=7.2.2
modmenu_version=8.0.1
121 changes: 121 additions & 0 deletions neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
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

val forgeVersion = "neoforge_version"()!!

unimined.minecraft {
if (!isJarMod) {
neoForge {
if (canUseATs) {
accessTransformer(aw2at(accessWidenerFile))
}
loader(forgeVersion)
customSearge = (mcMappingsType != "mojmap" && mcMappingsType != "parchment")
}
} else {
jarMod {}
}
}

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

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

dependencies {
if (isJarMod) {
"jarMod"("risugami:modloader:$forgeVersion")
}

common(project(path = ":common")) { isTransitive = false }
common(project(path = ":common", configuration = "shade"))
common(project(path = ":common", configuration = "runtime"))
shadowCommon(project(path = ":common", configuration = "shadeOnly"))
shadowCommon(project(path = ":common")) { isTransitive = false }
}

val resourceTargets = listOf(
"mcmod.info",
"META-INF/mods.toml",
"META-INF/neoforge.mods.toml",
"mod_$modName.info",
"pack.mcmeta"
)
val replaceProperties = mapOf(
"mod_id" to modId,
"mod_name" to modName,
"version" to baseVersionLabel,
"mcversion" to mcVersionLabel,
"forge_id" to name,
"fml_version_range" to "neo_fml_version_range"(),
"game_version_range" to "neoforge_game_version_range"(),
"loader_version_range" to "neoforge_loader_version_range"(),
"unilib_min_version" to "unilib_minimum_version"()!!
)

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 {
if (canUseATs) {
manifest {
attributes(
mapOf(
"FMLAT" to "accesstransformer.cfg"
)
)
}
}
archiveClassifier.set("dev")
}

tasks.sourcesJar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
val commonSources = project(":common").tasks.sourcesJar
dependsOn(commonSources)
from(commonSources.get().archiveFile.map { zipTree(it) })
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* 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.neoforge;

import com.gitlab.cdagaming.craftpresence.CraftPresence;
import com.gitlab.cdagaming.craftpresence.config.gui.MainGui;
import com.gitlab.cdagaming.unilib.core.CoreUtils;
import io.github.cdagaming.unicore.utils.OSUtils;
import net.neoforged.fml.IExtensionPoint;
import net.neoforged.fml.ModList;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.neoforge.client.ConfigScreenHandler;

/**
* The Primary Application Class and Utilities
*
* @author CDAGaming
*/
@Mod("@MOD_ID@")
public class CraftPresenceNeoForge {
/**
* Begins Scheduling Ticks on Class Initialization
*/
public CraftPresenceNeoForge() {
try {
if (OSUtils.JAVA_SPEC < 1.8f) {
throw new UnsupportedOperationException("Incompatible JVM!!! @MOD_NAME@ requires Java 8 or above to work properly!");
}

try {
// Workaround: Client-side only fix for Forge Clients
// - Reference => https://gitlab.com/CDAGaming/CraftPresence/-/issues/99
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> IExtensionPoint.DisplayTest.IGNORESERVERONLY, (a, b) -> true));
} catch (Throwable ignored) {
// before forge-1.13.2-25.0.103
}

try {
// Register The Config GUI Factory, used in Forge for Mod Menu integration
ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory((mc, parentScreen) -> new MainGui(parentScreen)));
} catch (Throwable ex) {
CoreUtils.LOG.error("Failed to register Config GUI Factory for @MOD_NAME@.", ex);
}

if (FMLEnvironment.dist.isClient()) {
new CraftPresence(this::setupIntegrations);
} else {
CoreUtils.LOG.info("Disabling @MOD_NAME@, as it is client side only.");
}
} 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
}
}
2 changes: 2 additions & 0 deletions neoforge/src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl postDisconnectScreen
public com.mojang.realmsclient.RealmsMainScreen getSelectedServer()Lcom/mojang/realmsclient/dto/RealmsServer;
37 changes: 37 additions & 0 deletions neoforge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
modLoader="javafml"
loaderVersion="${fml_version_range}"
license="MIT"
issueTrackerURL="https://gitlab.com/CDAGaming/CraftPresence/issues"
[[mods]]
modId="${mod_id}"
version="${version}"
displayName="${mod_name}"
updateJSONURL="https://raw.githubusercontent.com/CDAGaming/VersionLibrary/master/CraftPresence/update.json"
displayURL="https://www.curseforge.com/minecraft/mc-mods/craftpresence"
logoFile="logo.png"
credits=""
authors="CDAGaming"
description='''
Completely Customize the way others see you play in Discord!
'''

[[dependencies.${mod_id}]]
modId="${forge_id}"
mandatory=true
versionRange="${loader_version_range}"
ordering="NONE"
side="BOTH"

[[dependencies.${mod_id}]]
modId="unilib"
mandatory=true
versionRange="[${unilib_min_version},]"
ordering="AFTER"
side="BOTH"

[[dependencies.${mod_id}]]
modId="minecraft"
mandatory=true
versionRange="${game_version_range}"
ordering="NONE"
side="BOTH"
Binary file added neoforge/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 neoforge/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": 18
}
}
2 changes: 1 addition & 1 deletion quilt/src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"description": "${mod_name} Resources",
"pack_format": 15
"pack_format": 18
}
}

0 comments on commit 957cfa4

Please sign in to comment.