Skip to content

Commit

Permalink
[Port] Update to 1.18.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 1a45d84 commit 3620b41
Show file tree
Hide file tree
Showing 11 changed files with 308 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
package com.gitlab.cdagaming.craftpresence.core;

import com.gitlab.cdagaming.unilib.core.CoreUtils;
import com.gitlab.cdagaming.unilib.core.integrations.logging.ApacheLogger;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.github.cdagaming.unicore.integrations.logging.JavaLogger;
import io.github.cdagaming.unicore.integrations.logging.LoggingImpl;
import io.github.cdagaming.unicore.integrations.logging.SLF4JLogger;
import io.github.cdagaming.unicore.utils.FileUtils;
import io.github.cdagaming.unicore.utils.OSUtils;
import io.github.cdagaming.unicore.utils.TranslationUtils;
Expand Down Expand Up @@ -87,7 +86,7 @@ public class Constants {
/**
* The Application's Instance of {@link LoggingImpl} for Logging Information
*/
public static final LoggingImpl LOG = CoreUtils.IS_LEGACY_SOFT ? new JavaLogger(MOD_ID) : new ApacheLogger(MOD_ID);
public static final LoggingImpl LOG = new SLF4JLogger(MOD_ID);

/**
* The Application's Instance of {@link TranslationUtils} for Localization and Translating Data Strings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
import com.gitlab.cdagaming.craftpresence.core.impl.ExtendedModule;
import com.gitlab.cdagaming.craftpresence.core.impl.discord.DiscordStatus;
import com.gitlab.cdagaming.unilib.ModUtils;
import com.gitlab.cdagaming.unilib.core.integrations.logging.ApacheLogger;
import com.gitlab.cdagaming.unilib.utils.GameUtils;
import com.gitlab.cdagaming.unilib.utils.WorldUtils;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.mojang.realmsclient.RealmsMainScreen;
import com.mojang.realmsclient.dto.RealmsServer;
import io.github.cdagaming.unicore.impl.Pair;
import io.github.cdagaming.unicore.integrations.logging.SLF4JLogger;
import io.github.cdagaming.unicore.utils.MathUtils;
import io.github.cdagaming.unicore.utils.StringUtils;
import io.github.cdagaming.unicore.utils.TimeUtils;
Expand Down Expand Up @@ -72,7 +72,7 @@ public class ServerUtils implements ExtendedModule {
(new ThreadFactoryBuilder())
.setNameFormat("Server Pinger #%d")
.setDaemon(true)
.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(((ApacheLogger) Constants.LOG).getLogInstance()))
.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(((SLF4JLogger) Constants.LOG).getLogInstance()))
.build()
);
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void clearAttributes() {

@Override
public void updateData() {
final Biome newBiome = CraftPresence.world.getBiome(CraftPresence.player.blockPosition());
final Biome newBiome = CraftPresence.world.getBiome(CraftPresence.player.blockPosition()).value();
final ResourceLocation newIdentifier = CraftPresence.world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getKey(newBiome);
final String newBiomeName = newIdentifier != null ? newIdentifier.toString() : "Plains";

Expand Down
28 changes: 17 additions & 11 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,37 @@ org.gradle.daemon=false
mod_name=CraftPresence
mod_id=craftpresence
group=com.gitlab.cdagaming
enabled_platforms=fabric,forge
enabled_platforms=fabric,forge,quilt
# Critical Info
isLegacy=false
isJarMod=false
# Mapping Info
mc_mappings=
mc_mappings_type=mojmap
mc_version=1.18.1
mc_protocol=757
mc_version=1.18.2
mc_protocol=758
display_version=
# Fabric Info
fabric_loader_version=0.16.9
fabric_api_version=0.46.6+1.18
fabric_game_version_range=>=1.18 <1.18.2
fabric_api_version=0.77.0+1.18.2
fabric_game_version_range=>=1.18.2 <1.19
fabric_loader_version_range=>=0.13.0
# Quilt Info
quilt_loader_version=0.26.3
quilt_api_version=1.1.0-beta.26+1.18.2
quilt_fabric_api_version=1.0.0-beta.28+0.67.0-1.18.2
quilt_game_version_range=>=1.18.2,<1.19
quilt_loader_version_range=>=0.19.2
# Forge Info
forge_version=39.1.0
fml_version_range=[38,)
forge_game_version_range=[1.18, 1.18.2)
forge_loader_version_range=[38.0.0,)
forge_version=40.2.0
fml_version_range=[40,)
forge_game_version_range=[1.18.2, 1.19)
forge_loader_version_range=[40.0.0,)
# Deployment Info
versionId=2.5.3
deploymentType=Release
versionLabel=Release
additional_mc_versions=1.18
additional_mc_versions=
# Integration Info
source_java_version=21
build_java_version=17
Expand All @@ -46,4 +52,4 @@ unilib_build_version=1.0.5
unilib_minimum_version=1.0.1
# Dependency Info
modmenu_group=com.terraformersmc
modmenu_version=3.0.1
modmenu_version=3.2.5
129 changes: 129 additions & 0 deletions quilt/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
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 baseVersionLabel: String by extra

unimined.minecraft {
quilt {
if (accessWidenerFile.exists()) {
accessWidener(accessWidenerFile)
}
loader("quilt_loader_version"()!!)
customIntermediaries = true
}
// Note: Required for ignoring Quilt hassles
mods {
modImplementation {
catchAWNamespaceAssertion()
}
}
}

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

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

dependencies {
// Required for mod loading
val quiltBase = "org.quiltmc.qsl.core:qsl_base:${"quilt_api_version"()!!}"
"modImplementation"(quiltBase)
"include"(quiltBase)

// Required for loading translation data
val resourceLoader = "org.quiltmc.qsl.core:resource_loader:${"quilt_api_version"()!!}"
"modImplementation"(resourceLoader)
"include"(resourceLoader)

// Mod Menu API Implementation
"modImplementation"("${"modmenu_group"()}:modmenu:${"modmenu_version"()}") {
exclude(group = "net.fabricmc.fabric-api")
exclude(group = "net.fabricmc")
}

// Quilt: Replace Fabric APIs with Quilt Equivalents
"modImplementation"("org.quiltmc.qsl.core:lifecycle_events:${"quilt_api_version"()!!}")
"modImplementation"("org.quiltmc.qsl.gui:screen:${"quilt_api_version"()!!}")
"modImplementation"(fabricApi.quiltFabricModule("fabric-api-base", "quilt_fabric_api_version"()!!))
"modImplementation"(fabricApi.quiltFabricModule("fabric-resource-loader-v0", "quilt_fabric_api_version"()!!))
"modImplementation"(fabricApi.quiltFabricModule("fabric-screen-api-v1", "quilt_fabric_api_version"()!!))
"modImplementation"(fabricApi.quiltFabricModule("fabric-key-binding-api-v1", "quilt_fabric_api_version"()!!))
"modImplementation"(fabricApi.quiltFabricModule("fabric-lifecycle-events-v1", "quilt_fabric_api_version"()!!))

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 gameVersionRange = "quilt_game_version_range"()!!.split(',').toList()

val resourceTargets = listOf(
"quilt.mod.json",
"pack.mcmeta"
)
val replaceProperties = mapOf(
"mod_id" to modId,
"mod_name" to modName,
"version" to baseVersionLabel,
"mcversion" to mcVersionLabel,
"game_version_range_start" to gameVersionRange[0],
"game_version_range_end" to gameVersionRange[1],
"loader_version_range" to "quilt_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 {
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,56 @@
/*
* 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.quilt;

import com.gitlab.cdagaming.craftpresence.CraftPresence;
import io.github.cdagaming.unicore.utils.OSUtils;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.client.ClientModInitializer;

/**
* The Primary Application Class and Utilities
*
* @author CDAGaming
*/
public class CraftPresenceQuilt implements ClientModInitializer {
@Override
public void onInitializeClient(ModContainer mod) {
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.quilt.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 quilt/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/ClientPacketListener callbackScreen Lnet/minecraft/client/gui/screens/Screen;
accessible method com/mojang/realmsclient/RealmsMainScreen getSelectedServer ()Lcom/mojang/realmsclient/dto/RealmsServer;
Binary file added quilt/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 quilt/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": 8
}
}
Loading

0 comments on commit 3620b41

Please sign in to comment.