port 1.19.2 changes

This commit is contained in:
Relentless 2023-06-14 11:48:49 +02:00
parent a0b3a6bcf6
commit e2edbac4b0
No known key found for this signature in database
GPG key ID: 50C5FD225130D790
25 changed files with 421 additions and 153 deletions

View file

@ -11,33 +11,23 @@ env:
JAVA_VERSION: 17
MOD_ID: 'almostunified'
MOD_NAME: 'AlmostUnified'
CURSEFORGE_ID: '633823'
MODRINTH_ID: 'sdaSaQEz'
jobs:
release:
name: Release
build:
name: Build, collect info, parse changelog
runs-on: ubuntu-latest
outputs:
JAR_FILE: ${{ steps.collect_info.outputs.JAR_FILE }}
MINECRAFT_VERSION: ${{ steps.collect_info.outputs.MINECRAFT_VERSION }}
MOD_VERSION: ${{ steps.collect_info.outputs.MOD_VERSION }}
RELEASE_TYPE: ${{ steps.collect_info.outputs.RELEASE_TYPE }}
steps:
- name: Clone Repository
uses: actions/checkout@v3
- name: Check Secrets
run: |
if [ -z "${{ secrets.MODRINTH_TOKEN }}" ]; then
echo "MODRINTH_TOKEN is not set"
exit 1
fi
if [ -z "${{ secrets.CURSEFORGE_TOKEN }}" ]; then
echo "CURSEFORGE_TOKEN is not set"
exit 1
fi
- name: Validate Modrinth Token
run: |
if [ -n "$(curl -s -H "Authorization: ${{ secrets.MODRINTH_TOKEN }}" https://api.modrinth.com/v2/user | grep "unauthorized")" ]; then
echo "Modrinth Token is invalid!"
exit 1
fi
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v3
with:
@ -59,21 +49,22 @@ jobs:
- name: Assemble the JARs
run: ./gradlew assemble
- name: Move JARs to build directory
- name: Move JARs to central directory
run: |
mkdir -p build/libs
mv -f Forge/build/libs/*.jar build/libs
mv -f Fabric/build/libs/*.jar build/libs
mkdir output
mv -f Forge/build/libs/*.jar Fabric/build/libs/*.jar output/
rm -f output/*-dev-shadow.jar output/*-sources.jar
- name: Collect version information
id: collect_info
run: |
shopt -s failglob # print a warning if a glob does not match anything
set_var() {
echo $1="$2"
echo $1="$2" >> $GITHUB_ENV
echo $1="$2" >> $GITHUB_OUTPUT
declare -g $1="$2"
}
set_var JAR_FILE $(eval echo build/libs/${{ env.MOD_ID }}-*-*-*.jar)
set_var JAR_FILE $(eval echo output/${{ env.MOD_ID }}-*-*-*.jar)
set_var MINECRAFT_VERSION $(echo ${JAR_FILE%.*} | cut -d- -f3)
set_var MOD_VERSION $(echo ${JAR_FILE%.*} | cut -d- -f4)
set_var RELEASE_TYPE "$(echo ${GITHUB_REF##*/} | cut -d- -f3)"
@ -83,68 +74,188 @@ jobs:
uses: taiki-e/install-action@parse-changelog
- name: Parse changelog
run: parse-changelog CHANGELOG.md ${{ env.MOD_VERSION }} > changes.md
run: parse-changelog CHANGELOG.md ${{ steps.collect_info.outputs.MOD_VERSION }} > output/changelog.md
- name: Release Fabric to CF and MR
uses: Kir-Antipov/mc-publish@v3.2
- name: Archive results
run: tar -zcvf build.tar.gz output
- name: Upload results
uses: actions/upload-artifact@v3
with:
curseforge-id: 633823
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
modrinth-id: sdaSaQEz
name: build-artifacts
path: build.tar.gz
if-no-files-found: error
retention-days: 3
- name: Job Summary
run: |
echo "# Version Information" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- Minecraft Version: ${{ steps.collect_info.outputs.MINECRAFT_VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "- Mod Version: ${{ steps.collect_info.outputs.MOD_VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "- Release Type: ${{ steps.collect_info.outputs.RELEASE_TYPE }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "# Build Information" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- JAR files: $(find output -maxdepth 1 -type f -name '*.jar' | wc -c)" >> $GITHUB_STEP_SUMMARY
echo "- Folder size: $(du -sh output | cut -f1)" >> $GITHUB_STEP_SUMMARY
echo "- Archive size: $(du -sh build.tar.gz | cut -f1)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "# Changelog" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat output/changelog.md >> $GITHUB_STEP_SUMMARY
mr-fabric-release:
name: Modrinth Fabric Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Extract build artifacts
run: tar -zxvf build.tar.gz
- name: Release Fabric on Modrinth
uses: Kir-Antipov/mc-publish@v3.3
with:
modrinth-id: ${{ env.MODRINTH_ID }}
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
files: build/libs/${{ env.MOD_ID }}-fabric-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}.jar
name: ${{ env.MOD_NAME }}-Fabric-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}
version: ${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}+fabric
version-type: ${{ env.RELEASE_TYPE }}
changelog-file: changes.md
files: output/*fabric*.jar
name: ${{ env.MOD_NAME }}-Fabric-${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}
version: ${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}+fabric
version-type: ${{ needs.build.outputs.RELEASE_TYPE }}
changelog-file: output/changelog.md
loaders: fabric
game-versions: ${{ env.MINECRAFT_VERSION }}
version-resolver: exact
game-versions: ${{ needs.build.outputs.MINECRAFT_VERSION }}
java: ${{ env.JAVA_VERSION }}
dependencies: |
roughly-enough-items | suggests | *
jei | suggests | *
jei(optional){curseforge:238222}{modrinth:u6dRKJwZ}
rei(optional){curseforge:310111}{modrinth:nfn13YXA}
retry-attempts: 2
retry-delay: 10000
- name: Release Forge to CF and MR
uses: Kir-Antipov/mc-publish@v3.2
cf-fabric-release:
name: CurseForge Fabric Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
curseforge-id: 633823
name: build-artifacts
- name: Extract build artifacts
run: tar -zxvf build.tar.gz
- name: Release Fabric on CurseForge
uses: Kir-Antipov/mc-publish@v3.3
with:
curseforge-id: ${{ env.CURSEFORGE_ID }}
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
modrinth-id: sdaSaQEz
files: output/*fabric*.jar
name: ${{ env.MOD_NAME }}-Fabric-${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}
version: ${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}+fabric
version-type: ${{ needs.build.outputs.RELEASE_TYPE }}
changelog-file: output/changelog.md
loaders: fabric
game-versions: ${{ needs.build.outputs.MINECRAFT_VERSION }}
java: ${{ env.JAVA_VERSION }}
dependencies: |
jei(optional){curseforge:238222}{modrinth:u6dRKJwZ}
rei(optional){curseforge:310111}{modrinth:nfn13YXA}
mr-forge-release:
name: Modrinth Forge Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Extract build artifacts
run: tar -zxvf build.tar.gz
- name: Release Forge on Modrinth
uses: Kir-Antipov/mc-publish@v3.3
with:
modrinth-id: ${{ env.MODRINTH_ID }}
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
files: build/libs/${{ env.MOD_ID }}-forge-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}.jar
name: ${{ env.MOD_NAME }}-Forge-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}
version: ${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}+forge
version-type: ${{ env.RELEASE_TYPE }}
changelog-file: changes.md
files: output/*forge*.jar
name: ${{ env.MOD_NAME }}-Forge-${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}
version: ${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}+forge
version-type: ${{ needs.build.outputs.RELEASE_TYPE }}
changelog-file: output/changelog.md
loaders: forge
game-versions: ${{ env.MINECRAFT_VERSION }}
version-resolver: exact
game-versions: ${{ needs.build.outputs.MINECRAFT_VERSION }}
java: ${{ env.JAVA_VERSION }}
dependencies: |
roughly-enough-items | suggests | *
jei | suggests | *
jei(optional){curseforge:238222}{modrinth:u6dRKJwZ}
rei(optional){curseforge:310111}{modrinth:nfn13YXA}
retry-attempts: 2
retry-delay: 10000
cf-forge-release:
name: CurseForge Forge Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Release to GitHub
uses: Kir-Antipov/mc-publish@v3.2
- name: Extract build artifacts
run: tar -zxvf build.tar.gz
- name: Release Forge on CurseForge
uses: Kir-Antipov/mc-publish@v3.3
with:
curseforge-id: ${{ env.CURSEFORGE_ID }}
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
files: output/*forge*.jar
name: ${{ env.MOD_NAME }}-Forge-${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}
version: ${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}+forge
version-type: ${{ needs.build.outputs.RELEASE_TYPE }}
changelog-file: output/changelog.md
loaders: forge
game-versions: ${{ needs.build.outputs.MINECRAFT_VERSION }}
java: ${{ env.JAVA_VERSION }}
dependencies: |
jei(optional){curseforge:238222}{modrinth:u6dRKJwZ}
rei(optional){curseforge:310111}{modrinth:nfn13YXA}
github-release:
name: GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Extract build artifacts
run: tar -zxvf build.tar.gz
- name: Release on GitHub
uses: Kir-Antipov/mc-publish@v3.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
files: build/libs/${{ env.MOD_ID }}-*-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}.jar
name: v${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}
version: ${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}
version-type: ${{ env.RELEASE_TYPE }}
changelog-file: changes.md
retry-attempts: 2
retry-delay: 10000
files: output/*.jar
name: v${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}
version: ${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}
version-type: ${{ needs.build.outputs.RELEASE_TYPE }}
changelog-file: output/changelog.md

1
.gitignore vendored
View file

@ -24,3 +24,4 @@ extra-mods-*
*.log.gz
eclipse
run
.architectury-transformer

View file

@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog],
and this project adheres to [Semantic Versioning].
## [0.5.0] - 2023-06-14
### Added
- repair unification for `TieredItems` (tools) and `ArmorItems` ([#53])
- supports vanilla Anvil
- works for all mods as long as they properly call the super method
- simplified Chinese translation ([#49])
- shaped recipe type from Cucumber lib for Fabric to ignored types ([#52])
<!-- Links -->
[#49]: https://github.com/AlmostReliable/almostunified/issues/49
[#52]: https://github.com/AlmostReliable/almostunified/pull/52
[#53]: https://github.com/AlmostReliable/almostunified/issues/53
## [0.4.4] - 2023-05-04
### Added
@ -81,6 +95,7 @@ Initial 1.19.4 release!
[semantic versioning]: https://semver.org/spec/v2.0.0.html
<!-- Versions -->
[0.5.0]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.19.3-0.5.0-beta
[0.4.4]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.19.4-0.4.4-beta
[0.4.3]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.19.4-0.4.3-beta
[0.4.2]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.19.4-0.4.2-beta

View file

@ -11,7 +11,7 @@ val junitVersion: String by project
val minecraftVersion: String by project
plugins {
id("com.github.gmazzo.buildconfig") version ("3.1.0")
id("com.github.gmazzo.buildconfig") version ("4.0.4")
}
architectury {
@ -26,17 +26,19 @@ loom {
}
dependencies {
// loader
// required here for the @Environment annotations and the mixin dependencies
// Do NOT use other classes from the Fabric loader!
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
// compile time mods
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:$reiVersion") // required for common rei plugin
compileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+") // required to disable rei compat layer on jei plugin
testCompileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+") // don't question this, it's required for compiling
modCompileOnly("mezz.jei:jei-$minecraftVersion-lib:$jeiVersion") // required for common jei plugin and mixin
modCompileOnly("mezz.jei:jei-$minecraftVersion-common-api:$jeiVersion") // required for common jei plugin and mixin
// The Fabric loader is required here to use the @Environment annotations and to get the mixin dependencies.
// Do NOT use other classes from the Fabric loader!
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
// JUnit Tests
// tests
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
}
@ -46,6 +48,7 @@ buildConfig {
buildConfigField("String", "MOD_NAME", "\"$modName\"")
buildConfigField("String", "MOD_VERSION", "\"$version\"")
packageName(modPackage)
useJavaOutput()
}
// TODO reactivate when specific mod is not annoying anymore

View file

@ -131,8 +131,7 @@ public final class Defaults {
public static List<String> getIgnoredRecipeTypes(Platform platform) {
return switch (platform) {
case FORGE -> List.of("cucumber:shaped_tag");
case FABRIC -> List.of();
default -> List.of("cucumber:shaped_tag");
};
}

View file

@ -17,7 +17,7 @@ public class AlmostMixinPlugin implements IMixinConfigPlugin {
private static final BooleanSupplier TRUE = () -> true;
private static final Map<String, BooleanSupplier> CONDITIONS = ImmutableMap.of(
"com.almostreliable.unified.mixin.JeiRecipeLayoutMixin", modLoaded(ModConstants.JEI)
"com.almostreliable.unified.mixin.compat.JeiRecipeLayoutMixin", modLoaded(ModConstants.JEI)
);
private static BooleanSupplier modLoaded(String id) {

View file

@ -1,4 +1,4 @@
package com.almostreliable.unified.mixin;
package com.almostreliable.unified.mixin.compat;
import com.almostreliable.unified.compat.AlmostJEI;
import com.almostreliable.unified.compat.RecipeIndicator;

View file

@ -0,0 +1,6 @@
@ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault
package com.almostreliable.unified.mixin.compat;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -1,4 +1,4 @@
package com.almostreliable.unified.mixin;
package com.almostreliable.unified.mixin.runtime;
import com.almostreliable.unified.ClientTagUpdateEvent;
import net.minecraft.client.multiplayer.ClientPacketListener;

View file

@ -1,4 +1,4 @@
package com.almostreliable.unified.mixin;
package com.almostreliable.unified.mixin.runtime;
import com.almostreliable.unified.AlmostUnified;
import com.google.gson.JsonElement;

View file

@ -1,4 +1,4 @@
package com.almostreliable.unified.mixin;
package com.almostreliable.unified.mixin.runtime;
import com.almostreliable.unified.AlmostUnified;
import com.almostreliable.unified.utils.Utils;

View file

@ -1,4 +1,4 @@
package com.almostreliable.unified.mixin;
package com.almostreliable.unified.mixin.runtime;
import com.almostreliable.unified.AlmostUnified;
import net.minecraft.server.packs.resources.PreparableReloadListener;

View file

@ -0,0 +1,6 @@
@ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault
package com.almostreliable.unified.mixin.runtime;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -0,0 +1,27 @@
package com.almostreliable.unified.mixin.unifier;
import com.almostreliable.unified.AlmostUnified;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ArmorItem.class)
public class ArmorItemMixin {
@Shadow @Final protected ArmorMaterial material;
@Inject(method = "isValidRepairItem", at = @At("HEAD"), cancellable = true)
private void unified$repairUnification(ItemStack stack, ItemStack repairCandidate, CallbackInfoReturnable<Boolean> cir) {
AlmostUnified.getRuntime().getReplacementMap().ifPresent(replacementMap -> {
if (replacementMap.isItemInUnifiedIngredient(material.getRepairIngredient(), repairCandidate)) {
cir.setReturnValue(true);
}
});
}
}

View file

@ -0,0 +1,27 @@
package com.almostreliable.unified.mixin.unifier;
import com.almostreliable.unified.AlmostUnified;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.TieredItem;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(TieredItem.class)
public class TieredItemMixin {
@Shadow @Final private Tier tier;
@Inject(method = "isValidRepairItem", at = @At("HEAD"), cancellable = true)
private void unified$repairUnification(ItemStack stack, ItemStack repairCandidate, CallbackInfoReturnable<Boolean> cir) {
AlmostUnified.getRuntime().getReplacementMap().ifPresent(replacementMap -> {
if (replacementMap.isItemInUnifiedIngredient(tier.getRepairIngredient(), repairCandidate)) {
cir.setReturnValue(true);
}
});
}
}

View file

@ -0,0 +1,6 @@
@ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault
package com.almostreliable.unified.mixin.unifier;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -3,8 +3,13 @@ package com.almostreliable.unified.utils;
import com.almostreliable.unified.AlmostUnified;
import com.almostreliable.unified.api.StoneStrataHandler;
import com.almostreliable.unified.config.UnifyConfig;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import javax.annotation.Nullable;
import java.util.*;
@ -89,6 +94,33 @@ public class ReplacementMap {
return null;
}
/**
* Gets all unify tags of the items within the given ingredient and checks
* whether the given item is in one of those tags.
*
* @param ingred The ingredient to get the unify tags from.
* @param item The item to check.
* @return Whether the item is in one of the unify tags of the ingredient.
*/
public boolean isItemInUnifiedIngredient(Ingredient ingred, ItemStack item) {
Set<UnifyTag<Item>> checkedTags = new HashSet<>();
for (ItemStack ingredItem : ingred.getItems()) {
ResourceLocation itemId = BuiltInRegistries.ITEM.getKey(ingredItem.getItem());
var preferredTag = getPreferredTagForItem(itemId);
if (preferredTag == null || checkedTags.contains(preferredTag)) continue;
checkedTags.add(preferredTag);
var preferredTagKey = TagKey.create(Registries.ITEM, preferredTag.location());
if (item.is(preferredTagKey)) {
return true;
}
}
return false;
}
@Nullable
private ResourceLocation getOverrideForTag(UnifyTag<Item> tag, List<ResourceLocation> items) {
String priorityOverride = unifyConfig.getPriorityOverrides().get(tag.location());

View file

@ -5,13 +5,15 @@
"compatibilityLevel": "JAVA_17",
"plugin": "com.almostreliable.unified.mixin.AlmostMixinPlugin",
"mixins": [
"RecipeManagerMixin",
"TagLoaderMixin",
"TagManagerMixin"
"runtime.RecipeManagerMixin",
"runtime.TagLoaderMixin",
"runtime.TagManagerMixin",
"unifier.ArmorItemMixin",
"unifier.TieredItemMixin"
],
"client": [
"ClientPacketListenerMixin",
"JeiRecipeLayoutMixin"
"compat.JeiRecipeLayoutMixin",
"runtime.ClientPacketListenerMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -0,0 +1,8 @@
{
"almostunified.description": "此版本由Almost Unified修改",
"almostunified.warning": "请不要提交问题给原作者!",
"almostunified.unified": "大一统!",
"almostunified.duplicate": "存在重复的?!",
"almostunified.yes": "是!",
"almostunified.no": "否!"
}

View file

@ -6,7 +6,7 @@ val reiVersion: String by project
val jeiVersion: String by project
plugins {
id("com.github.johnrengelman.shadow") version ("7.1.2")
id("com.github.johnrengelman.shadow") version ("8.1.1")
}
architectury {
@ -24,19 +24,28 @@ loom {
val common by configurations
val shadowCommon by configurations
dependencies {
// loader
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
modApi("net.fabricmc.fabric-api:fabric-api:$fabricApiVersion+$minecraftVersion")
// common module
common(project(":Common", "namedElements")) { isTransitive = false }
shadowCommon(project(":Common", "transformProductionFabric")) { isTransitive = false }
// compile time mods
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:$reiVersion") // required for common rei plugin
compileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+") // required to disable rei compat layer on jei plugin
testCompileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+") // don't question this, it's required for compiling
modCompileOnly("mezz.jei:jei-$minecraftVersion-fabric-api:$jeiVersion") // required for common jei plugin and mixin
when (fabricRecipeViewer) { // runtime only
"rei" -> modLocalRuntime("me.shedaniel:RoughlyEnoughItems-fabric:$reiVersion")
"jei" -> modLocalRuntime("mezz.jei:jei-$minecraftVersion-fabric:$jeiVersion")
else -> throw GradleException("Invalid fabricRecipeViewer value: $fabricRecipeViewer")
// runtime dependencies
modLocalRuntime(
when (fabricRecipeViewer) {
"rei" -> "me.shedaniel:RoughlyEnoughItems-fabric:$reiVersion"
"jei" -> "mezz.jei:jei-$minecraftVersion-fabric:$jeiVersion"
else -> throw GradleException("Invalid fabricRecipeViewer value: $fabricRecipeViewer")
}
) {
exclude("net.fabricmc", "fabric-loader")
}
}

View file

@ -8,7 +8,7 @@ val jeiVersion: String by project
plugins {
id("com.github.johnrengelman.shadow") version ("7.1.2")
id("com.github.johnrengelman.shadow") version ("8.1.1")
}
architectury {
@ -35,25 +35,29 @@ val common by configurations
val shadowCommon by configurations
val commonTests: SourceSetOutput = project(":Common").sourceSets["test"].output
dependencies {
// loader
forge("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")
// common module
common(project(":Common", "namedElements")) { isTransitive = false }
shadowCommon(project(":Common", "transformProductionForge")) { isTransitive = false }
// Mod dependencies
// compile time mods
modCompileOnly("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion") // required for common rei plugin | api does not work here
compileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+") // required to disable rei compat layer on jei plugin
testCompileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+") // don't question this, it's required for compiling
modCompileOnly("mezz.jei:jei-$minecraftVersion-forge-api:$jeiVersion") {
isTransitive = false
} // required for common jei plugin and mixin, transitivity is off because it breaks the forge runtime
when (forgeRecipeViewer) { // runtime only
modCompileOnly("mezz.jei:jei-$minecraftVersion-forge-api:$jeiVersion") { // required for common jei plugin and mixin
isTransitive = false // prevents breaking the forge runtime
}
// runtime mods
when (forgeRecipeViewer) {
"rei" -> modLocalRuntime("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion")
"jei" -> modLocalRuntime("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion") { isTransitive = false }
else -> throw GradleException("Invalid forgeRecipeViewer value: $forgeRecipeViewer")
}
// JUnit Tests
// tests
testImplementation(project(":Common"))
testImplementation(commonTests)
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")

View file

@ -11,35 +11,35 @@ displayName = "${modName}"
authors = "${modAuthor}"
description = '''${modDescription}'''
[[dependencies.${modId}]]
[[dependencies."${modId}"]]
modId = "forge"
mandatory = true
versionRange = "[${forgeVersion},)"
ordering = "NONE"
side = "BOTH"
[[dependencies.${modId}]]
[[dependencies."${modId}"]]
modId = "minecraft"
mandatory = true
versionRange = "[${minecraftVersion},)"
ordering = "NONE"
side = "BOTH"
[[dependencies.${modId}]]
[[dependencies."${modId}"]]
modId = "jei"
mandatory = false
versionRange = "[${jeiVersion},)"
ordering = "BEFORE"
side = "BOTH"
[[dependencies.${modId}]]
[[dependencies."${modId}"]]
modId = "roughlyenoughitems"
mandatory = false
versionRange = "[${reiVersion},)"
ordering = "BEFORE"
side = "BOTH"
[[dependencies.${modId}]]
[[dependencies."${modId}"]]
modId = "rei_plugin_compatibilities"
mandatory = false
versionRange = "[9.0.43,)"

View file

@ -18,16 +18,18 @@ val modAuthor: String by project
val githubRepo: String by project
val githubUser: String by project
val sharedRunDir: String by project
val autoServiceVersion: String by project
val parchmentVersion: String by project
val jeiVersion: String by project
val reiVersion: String by project
plugins {
java
`maven-publish`
id("architectury-plugin") version ("3.4-SNAPSHOT")
id("io.github.juuxel.loom-quiltflower") version "1.8.0" apply false
id("dev.architectury.loom") version ("1.0.302") apply false
id("com.github.johnrengelman.shadow") version "7.1.2" apply false
id("architectury-plugin") version ("3.4.+")
id("io.github.juuxel.loom-quiltflower") version "1.10.0" apply false
id("dev.architectury.loom") version ("1.2.+") apply false
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
}
architectury {
@ -44,8 +46,9 @@ allprojects {
repositories {
mavenLocal()
mavenCentral()
maven("https://maven.shedaniel.me")
maven("https://maven.blamejared.com/")
maven("https://maven.parchmentmc.org") // Parchment
maven("https://maven.shedaniel.me") // REI
maven("https://maven.blamejared.com/") // JEI
flatDir {
name = extraModsPrefix
dir(file("$extraModsPrefix-$minecraftVersion"))
@ -71,7 +74,7 @@ subprojects {
apply(plugin = "maven-publish")
apply(plugin = "io.github.juuxel.loom-quiltflower")
base.archivesName.set("$modId-${project.name.toLowerCase()}")
base.archivesName.set("$modId-${project.name.lowercase()}")
version = "$minecraftVersion-$modVersion"
val loom = project.extensions.getByName<LoomGradleExtensionAPI>("loom")
@ -85,19 +88,22 @@ subprojects {
* Kotlin accessor methods are not generated in this gradle, they can be accessed through quoted names.
*/
"minecraft"("com.mojang:minecraft:$minecraftVersion")
"mappings"(loom.officialMojangMappings())
"mappings"(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-1.19.3:$parchmentVersion@zip")
})
/**
* Helps to load mods in development through an extra directory. Sadly this does not support transitive dependencies. :-(
*/
fileTree("$extraModsPrefix-$minecraftVersion") { include("**/*.jar") }
.forEach { f ->
val sepIndex = f.nameWithoutExtension.lastIndexOf('-');
val sepIndex = f.nameWithoutExtension.lastIndexOf('-')
if (sepIndex == -1) {
throw IllegalArgumentException("Invalid mod name: '${f.nameWithoutExtension}'. Expected format: 'modName-version.jar'")
}
val mod = f.nameWithoutExtension.substring(0, sepIndex);
val version = f.nameWithoutExtension.substring(sepIndex + 1);
val mod = f.nameWithoutExtension.substring(0, sepIndex)
val version = f.nameWithoutExtension.substring(sepIndex + 1)
println("Extra mod ${f.nameWithoutExtension} detected.")
"modLocalRuntime"("extra-mods:$mod:$version")
}
@ -105,8 +111,8 @@ subprojects {
/**
* Non-Minecraft dependencies
*/
compileOnly("com.google.auto.service:auto-service:1.0.1")
annotationProcessor("com.google.auto.service:auto-service:1.0.1")
compileOnly("com.google.auto.service:auto-service:$autoServiceVersion")
annotationProcessor("com.google.auto.service:auto-service:$autoServiceVersion")
}
/**
@ -114,7 +120,7 @@ subprojects {
*/
publishing {
publications {
val mpm = project.properties["maven-publish-method"] as String;
val mpm = project.properties["maven-publish-method"] as String
println("[Publish Task] Publishing method for project '${project.name}: $mpm")
register(mpm, MavenPublication::class) {
artifactId = base.archivesName.get()
@ -140,35 +146,37 @@ subprojects {
compileOnly()
}
/**
* Resource processing for defined targets. This will replace `${key}` with the specified values from the map below.
*/
tasks.processResources {
val resourceTargets = listOf("META-INF/mods.toml", "pack.mcmeta", "fabric.mod.json")
tasks {
/**
* Resource processing for defined targets. This will replace `${key}` with the specified values from the map below.
*/
processResources {
val resourceTargets = listOf("META-INF/mods.toml", "pack.mcmeta", "fabric.mod.json")
val replaceProperties = mapOf(
"version" to project.version as String,
"license" to license,
"modId" to modId,
"modName" to modName,
"minecraftVersion" to minecraftVersion,
"modAuthor" to modAuthor,
"modDescription" to modDescription,
"fabricApiVersion" to fabricApiVersion,
"forgeVersion" to forgeVersion,
"forgeFMLVersion" to forgeVersion.substringBefore("."), // Only use major version as FML error message sucks. The error message for wrong Forge version is way better.
"jeiVersion" to jeiVersion,
"reiVersion" to reiVersion,
"githubUser" to githubUser,
"githubRepo" to githubRepo
)
val replaceProperties = mapOf(
"version" to project.version as String,
"license" to license,
"modId" to modId,
"modName" to modName,
"minecraftVersion" to minecraftVersion,
"modAuthor" to modAuthor,
"modDescription" to modDescription,
"fabricApiVersion" to fabricApiVersion,
"forgeVersion" to forgeVersion,
"forgeFMLVersion" to forgeVersion.substringBefore("."), // Only use major version as FML error message sucks. The error message for wrong Forge version is way better.
"jeiVersion" to jeiVersion,
"reiVersion" to reiVersion,
"githubUser" to githubUser,
"githubRepo" to githubRepo
)
println("[Process Resources] Replacing properties in resources: ")
replaceProperties.forEach { (key, value) -> println("\t -> $key = $value") }
println("[Process Resources] Replacing properties in resources: ")
replaceProperties.forEach { (key, value) -> println("\t -> $key = $value") }
inputs.properties(replaceProperties)
filesMatching(resourceTargets) {
expand(replaceProperties)
inputs.properties(replaceProperties)
filesMatching(resourceTargets) {
expand(replaceProperties)
}
}
}
}
@ -185,7 +193,7 @@ subprojects {
extensions.configure<LoomGradleExtensionAPI> {
runs {
forEach { it ->
forEach {
it.runDir(if (sharedRunDir.toBoolean()) "../run" else "run")
// Allows DCEVM hot-swapping when using the JetBrains Runtime (https://github.com/JetBrains/JetBrainsRuntime).
it.vmArgs("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
@ -224,7 +232,7 @@ subprojects {
named<RemapJarTask>("remapJar") {
inputFile.set(named<ShadowJar>("shadowJar").get().archiveFile)
dependsOn("shadowJar")
classifier = null
archiveClassifier.set(null as String?)
}
named<Jar>("jar") {

View file

@ -11,24 +11,28 @@ junitVersion = 5.9.0
minecraftVersion = 1.19.4
# Mod
modVersion = 0.4.4
modVersion = 0.5.0
modPackage = com.almostreliable.unified
modId = almostunified
modName = AlmostUnified
modAuthor = Almost Reliable
modDescription = Unify all resources.
# Project Dependencies
autoServiceVersion = 1.1.0
parchmentVersion = 2023.03.12
# Mod Dependencies
reiVersion = 11.0.597
jeiVersion = 13.1.0.3
# Fabric Settings
fabricLoaderVersion = 0.14.18
fabricApiVersion = 0.76.0
# Fabric Dependencies
fabricLoaderVersion = 0.14.21
fabricApiVersion = 0.83.0
fabricRecipeViewer = rei
# Forge Settings
forgeVersion = 45.0.24
# Forge Dependencies
forgeVersion = 45.1.0
forgeRecipeViewer = jei
# Github

View file

@ -1,5 +1,5 @@
distributionBase = GRADLE_USER_HOME
distributionPath = wrapper/dists
distributionUrl = https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl = https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase = GRADLE_USER_HOME
zipStorePath = wrapper/dists