Skip to content

Commit

Permalink
feat: 1.20.6 update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamalam360 committed May 1, 2024
1 parent 301e2d4 commit 0063ed2
Show file tree
Hide file tree
Showing 60 changed files with 1,334 additions and 1,986 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,14 @@ jobs:
java-version: 17

- name: Build
run: ./gradlew clean forge:build neoforge:build fabric:build quilt:build
run: ./gradlew clean neoforge:build fabric:build

- name: Capture Fabric Build Artifacts
uses: actions/upload-artifact@v2
with:
name: Fabric Artifacts
path: fabric/build/libs/

- name: Capture Quilt Build Artifacts
uses: actions/upload-artifact@v2
with:
name: Quilt Artifacts
path: quilt/build/libs/

- name: Capture Forge Build Artifacts
uses: actions/upload-artifact@v2
with:
name: Forge Artifacts
path: forge/build/libs/

- name: Capture NeoForge Build Artifacts
uses: actions/upload-artifact@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
- Clean up the ModMenu code, assumes a ModMenu version greater than 9.1.0 is installed otherwise
config screens are dependant on mod load order (fixes #6).
- Port to 1.20.6
- Remove Forge and Quilt support
33 changes: 10 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
<center><img src="https://raw.githubusercontent.com/JamCoreModding/JamLib/1.20.2-multiloader/common/src/main/resources/assets/jamlib/icon.png" align="center" width="128px"/></center>
![JamLib: The platform-agnostic library used in all of JamCore's mods](https://cdn.jamalam.tech/mod-assets/jamlib-banner.png)

<center>
<div align="center">

# JamLib
[Report Issues](https://github.com/JamCoreModding/jamlib)[Chat on Discord](https://discord.jamalam.tech)[CurseForge](https://curseforge.com/minecraft/mc-mods/jamlib)[Modrinth](https://modrinth.com/mod/jamlib)

</center>
</div>

<center>
<img alt="forge" height="20" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/supported/forge_vector.svg">
<img alt="fabric" height="20" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/supported/fabric_vector.svg">
<img alt="quilt" height="20" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/supported/quilt_vector.svg">
</center>
JamLib provides:

JamLib is the platform-agnostic, Architectury based library used in all of our mods.
- Platform abstractions
- A JSON5 config API
- A mod repost (9minecraft etc.) checker

## Features
Comprehensive documentation can be found [here](https://docs.jamalam.tech/jamlib/getting-started/).

- [x] Config using JSON5

## Developers

<center><a href="https://docs.jamalam.tech"><img alt="forge" height="20" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/documentation/generic_vector.svg"></a></center>

You are free to use JamLib in any mod you wish. API breaking changes will only be made between Minecraft versions - I
can't guarantee it will only be with sem-ver minor Minecraft versions though, as Mojang is making a lot of changes in '
patch'
versions at the moment.

<center><a href="https://bisecthosting.com/jamalam"><img src="https://www.bisecthosting.com/partners/custom-banners/982884df-e307-4b8d-b8c2-9f1868a1f13a.webp" height="120"></a></center>
[![Rent a server with Bisect Hosting: Use Code jamalam to get 25% off](https://www.bisecthosting.com/partners/custom-banners/e0cc6668-0d29-40ff-9820-4d4f5433198a.webp)](https://bisecthosting.com/jamalam)
13 changes: 2 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "com.github.breadmoirai.github-release" version "2.4.1"
id "maven-publish"
}
Expand Down Expand Up @@ -67,16 +67,11 @@ allprojects {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}

maven {
name = "Jamalam's Maven"
url = "https://maven.jamalam.tech/releases"
}
}

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 17
options.release = 21
}

tasks.create("prepareWorkspace") {}
Expand All @@ -92,10 +87,6 @@ tasks.publish {
dependsOn("common:publishAllPublicationsToMavenRepository")
dependsOn("fabric:publishUnified")
dependsOn("fabric:publishAllPublicationsToMavenRepository")
dependsOn("quilt:publishUnified")
dependsOn("quilt:publishAllPublicationsToMavenRepository")
dependsOn("forge:publishUnified")
dependsOn("forge:publishAllPublicationsToMavenRepository")
dependsOn("neoforge:publishUnified")
dependsOn("neoforge:publishAllPublicationsToMavenRepository")
}
54 changes: 28 additions & 26 deletions common/src/main/java/io/github/jamalam360/jamlib/JamLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,36 @@
import org.slf4j.LoggerFactory;

public class JamLib {
public static final String MOD_ID = "jamlib";
public static final String MOD_NAME = "JamLib";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_NAME);
protected static final JarRenamingChecker JAR_RENAMING_CHECKER = new JarRenamingChecker();

@ApiStatus.Internal
public static void init() {
LOGGER.info("Initializing JamLib on " + JamLibPlatform.getPlatform());
checkForJarRenaming(JamLib.class);
public static final String MOD_ID = "jamlib";
public static final String MOD_NAME = "JamLib";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_NAME);
protected static final JarRenamingChecker JAR_RENAMING_CHECKER = new JarRenamingChecker();

EnvExecutor.runInEnv(EnvType.CLIENT, () -> () -> ClientPlayerEvent.CLIENT_PLAYER_JOIN.register(JamLibClient::onPlayerJoin));
}
@ApiStatus.Internal
public static void init() {
LOGGER.info("Initializing JamLib on " + JamLibPlatform.getPlatform());
checkForJarRenaming(JamLib.class);

/**
* Check that the jar that the given class is in has not been renamed (mod rehosting sites often do this).
* If the jar has been renamed, a message will be displayed to the player when they join a world.
*
* @param anyModClass any class from the mod
* @see JarRenamingChecker
*/
public static void checkForJarRenaming(Class<?> anyModClass) {
if (!Platform.isDevelopmentEnvironment()) {
JAR_RENAMING_CHECKER.checkJar(anyModClass);
}
}
EnvExecutor.runInEnv(EnvType.CLIENT, () -> () -> ClientPlayerEvent.CLIENT_PLAYER_JOIN.register(JamLibClient::onPlayerJoin));
}

@ApiStatus.Internal
public static ResourceLocation id(String path) {
return new ResourceLocation(MOD_ID, path);
}
/**
* Check that the jar that the given class is in has not been renamed (mod rehosting sites often do this). If the jar has been renamed, a message will be displayed to
* the player when they join a world.
*
* @param anyModClass any class from the mod
*
* @see JarRenamingChecker
*/
public static void checkForJarRenaming(Class<?> anyModClass) {
if (!Platform.isDevelopmentEnvironment()) {
JAR_RENAMING_CHECKER.checkJar(anyModClass);
}
}

@ApiStatus.Internal
public static ResourceLocation id(String path) {
return new ResourceLocation(MOD_ID, path);
}
}
35 changes: 18 additions & 17 deletions common/src/main/java/io/github/jamalam360/jamlib/JamLibClient.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
package io.github.jamalam360.jamlib;

import static io.github.jamalam360.jamlib.JamLib.JAR_RENAMING_CHECKER;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.chat.Component;

import static io.github.jamalam360.jamlib.JamLib.JAR_RENAMING_CHECKER;

@Environment(EnvType.CLIENT)
public class JamLibClient {
public static void onPlayerJoin(LocalPlayer player) {
if (player != Minecraft.getInstance().player) {
return;
}

if (JAR_RENAMING_CHECKER.getSuspiciousJarsToNotifyAbout().isEmpty()) {
return;
}
public static void onPlayerJoin(LocalPlayer player) {
if (player != Minecraft.getInstance().player) {
return;
}

if (JAR_RENAMING_CHECKER.getSuspiciousJarsToNotifyAbout().isEmpty()) {
return;
}

player.displayClientMessage(Component.translatable("text.jamlib.renamed_1", Component.translatable("text.jamlib.renamed_1.1").withStyle(ChatFormatting.RED)), false);
player.displayClientMessage(Component.translatable("text.jamlib.renamed_1", Component.translatable("text.jamlib.renamed_1.1").withStyle(ChatFormatting.RED)), false);

for (String jar : JAR_RENAMING_CHECKER.getSuspiciousJarsToNotifyAbout()) {
player.displayClientMessage(Component.literal(" - " + jar).withStyle(ChatFormatting.GRAY), false);
}
for (String jar : JAR_RENAMING_CHECKER.getSuspiciousJarsToNotifyAbout()) {
player.displayClientMessage(Component.literal(" - " + jar).withStyle(ChatFormatting.GRAY), false);
}

player.displayClientMessage(Component.translatable("text.jamlib.renamed_2", Component.translatable("text.jamlib.renamed_2.1").withStyle(ChatFormatting.YELLOW), Component.translatable("text.jamlib.renamed_2.2").withStyle(ChatFormatting.RED), Component.translatable("text.jamlib.renamed_2.3").withStyle(ChatFormatting.RED), Component.translatable("text.jamlib.renamed_2.4").withStyle(ChatFormatting.GOLD), Component.translatable("text.jamlib.renamed_2.5").withStyle(ChatFormatting.GOLD)), false);
player.displayClientMessage(Component.translatable("text.jamlib.renamed_3", Component.translatable("text.jamlib.renamed_3.1").withStyle(ChatFormatting.GRAY)), false);
JAR_RENAMING_CHECKER.afterNotify();
}
player.displayClientMessage(Component.translatable("text.jamlib.renamed_2", Component.translatable("text.jamlib.renamed_2.1").withStyle(ChatFormatting.YELLOW), Component.translatable("text.jamlib.renamed_2.2").withStyle(ChatFormatting.RED), Component.translatable("text.jamlib.renamed_2.3").withStyle(ChatFormatting.RED), Component.translatable("text.jamlib.renamed_2.4").withStyle(ChatFormatting.GOLD), Component.translatable("text.jamlib.renamed_2.5").withStyle(ChatFormatting.GOLD)), false);
player.displayClientMessage(Component.translatable("text.jamlib.renamed_3", Component.translatable("text.jamlib.renamed_3.1").withStyle(ChatFormatting.GRAY)), false);
JAR_RENAMING_CHECKER.afterNotify();
}
}
103 changes: 46 additions & 57 deletions common/src/main/java/io/github/jamalam360/jamlib/JamLibPlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,51 @@
* @see dev.architectury.platform.Platform
*/
public class JamLibPlatform {
/**
* @return The current mod loader.
*/
public static Platform getPlatform() {
if (dev.architectury.platform.Platform.isModLoaded("quilt_loader")) {
return Platform.QUILT;
} else if (dev.architectury.platform.Platform.isMinecraftForge()) {
return Platform.FORGE;
} else if (dev.architectury.platform.Platform.isNeoForge()) {
return Platform.NEOFORGE;
} else {
return Platform.FABRIC;
}
}

/**
* A mod loader.
*/
public enum Platform {
FABRIC,
FORGE,
NEOFORGE,
QUILT;

public boolean isFabric() {
return this == FABRIC;
}

public boolean isForge() {
return this == FORGE;
}

public boolean isNeoForge() {
return this == NEOFORGE;
}

public boolean isQuilt() {
return this == QUILT;
}

public boolean isFabricLike() {
return this == FABRIC || this == QUILT;
}

public boolean isForgeLike() {
return this == FORGE || this == NEOFORGE;
}

@Override
public String toString() {
return switch (this) {
case FABRIC -> "Fabric";
case FORGE -> "Forge";
case NEOFORGE -> "NeoForge";
case QUILT -> "Quilt";
};
}
}
/**
* @return The current mod loader.
*/
public static Platform getPlatform() {
if (dev.architectury.platform.Platform.isModLoaded("quilt_loader")) {
return Platform.QUILT;
} else if (dev.architectury.platform.Platform.isNeoForge()) {
return Platform.NEOFORGE;
} else {
return Platform.FABRIC;
}
}

/**
* A mod loader.
*/
public enum Platform {
FABRIC,
NEOFORGE,
QUILT;

public boolean isFabric() {
return this == FABRIC;
}

public boolean isNeoForge() {
return this == NEOFORGE;
}

public boolean isQuilt() {
return this == QUILT;
}

public boolean isFabricLike() {
return this == FABRIC || this == QUILT;
}

@Override
public String toString() {
return switch (this) {
case FABRIC -> "Fabric";
case NEOFORGE -> "NeoForge";
case QUILT -> "Quilt";
};
}
}
}
Loading

0 comments on commit 0063ed2

Please sign in to comment.