Skip to content
This repository was archived by the owner on Feb 15, 2026. It is now read-only.

Commit 3ff04fb

Browse files
Merge pull request #5 from OffsetMods538/v2-alpha.2
2 parents 6089f25 + 7549f0b commit 3ff04fb

17 files changed

Lines changed: 314 additions & 66 deletions

.github/workflows/build_artifacts.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ jobs:
1414
- uses: actions/checkout@v4
1515

1616
- name: Set up JDK 21
17-
uses: actions/setup-java@v4
17+
uses: actions/setup-java@v5
1818
with:
1919
java-version: '21'
2020
distribution: 'temurin'
2121

2222
- name: Setup Gradle
23-
uses: gradle/actions/setup-gradle@v4
23+
uses: gradle/actions/setup-gradle@v5
2424
with:
2525
cache-read-only: false
2626

@@ -30,20 +30,23 @@ jobs:
3030
- name: Generate resources with Gradle
3131
run: ./gradlew runDatagenClient
3232
env:
33-
CUSTOM_VERSION: ${{ env.short_commit_hash }}
33+
PRESERVE_PRERELEASE_VERSION: true
3434
DISABLE_PROPERTIES_UPDATE: true
35+
VERSION_SUFFIX: ${{ env.short_commit_hash }}
3536

3637
- name: Build with Gradle
3738
run: ./gradlew build
3839
env:
39-
CUSTOM_VERSION: ${{ env.short_commit_hash }}
40+
PRESERVE_PRERELEASE_VERSION: true
4041
DISABLE_PROPERTIES_UPDATE: true
42+
VERSION_SUFFIX: ${{ env.short_commit_hash }}
4143

4244
- name: Publish to Maven
4345
run: ./gradlew publishMavenPublicationToOffsetMonkey538Repository
4446
env:
45-
CUSTOM_VERSION: ${{ env.short_commit_hash }}
47+
PRESERVE_PRERELEASE_VERSION: true
4648
DISABLE_PROPERTIES_UPDATE: true
49+
VERSION_SUFFIX: ${{ env.short_commit_hash }}
4750
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
4851
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
4952

.github/workflows/publish.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ jobs:
1616
- uses: actions/checkout@v4
1717

1818
- name: Set up JDK 21
19-
uses: actions/setup-java@v4
19+
uses: actions/setup-java@v5
2020
with:
2121
java-version: '21'
2222
distribution: 'temurin'
2323

2424
- name: Setup Gradle
25-
uses: gradle/actions/setup-gradle@v4
25+
uses: gradle/actions/setup-gradle@v5
2626
with:
2727
cache-read-only: false
2828

@@ -32,29 +32,35 @@ jobs:
3232
- name: Generate resources with Gradle
3333
run: ./gradlew runDatagenClient
3434
env:
35+
IS_RELEASE: true
3536
DISABLE_PROPERTIES_UPDATE: true
3637

3738

3839
- name: Build with Gradle
3940
run: ./gradlew build
4041
env:
42+
IS_RELEASE: true
4143
DISABLE_PROPERTIES_UPDATE: true
4244

4345
- name: Upload to Modrinth
4446
run: ./gradlew modrinth
4547
env:
48+
IS_RELEASE: true
49+
DISABLE_PROPERTIES_UPDATE: true
4650
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
4751
VERSION_NAME: ${{ github.event.release.name }}
4852
VERSION_IS_PRERELEASE: ${{ github.event.release.prerelease }}
4953
VERSION_CHANGELOG: ${{ github.event.release.body }}
5054

51-
- name: Upload to GitHub
52-
uses: softprops/action-gh-release@v2
53-
with:
54-
files: build/libs/*.jar
55-
5655
- name: Publish to Maven
5756
run: ./gradlew publishMavenPublicationToOffsetMonkey538Repository
5857
env:
58+
IS_RELEASE: true
59+
DISABLE_PROPERTIES_UPDATE: true
5960
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
6061
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
62+
63+
- name: Upload to GitHub
64+
uses: softprops/action-gh-release@v2
65+
with:
66+
files: build/libs/*.jar

build.gradle

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
11
import dex.plugins.outlet.v2.util.ReleaseType
22

3+
import java.nio.file.Files
4+
35
plugins {
46
id 'fabric-loom' version '1.11-SNAPSHOT'
57
id 'io.github.dexman545.outlet' version '1.6.1'
68
id 'com.modrinth.minotaur' version '2.+'
79
id 'maven-publish'
810
}
911

10-
sourceCompatibility = JavaVersion.VERSION_17
11-
targetCompatibility = JavaVersion.VERSION_17
12-
13-
archivesBaseName = "loot-table-modifier"
14-
group = "top.offsetmonkey538.loottablemodifier"
12+
ext {
13+
versionPrefix = rootProject.mod_version
14+
if (!Boolean.parseBoolean(System.getenv("IS_RELEASE"))) {
15+
String preReleaseVersion = System.currentTimeMillis()
1516

17+
if (Boolean.parseBoolean(System.getenv("PRESERVE_PRERELEASE_VERSION"))) {
18+
var preReleaseVersionFile = file("preReleaseVersion.txt").toPath()
19+
if (Files.exists(preReleaseVersionFile)) preReleaseVersion = Files.readString(preReleaseVersionFile)
20+
Files.writeString(preReleaseVersionFile, preReleaseVersion)
21+
}
1622

17-
version = project.mod_version
23+
var separator = "-"
24+
if (versionPrefix.contains("-")) separator = "."
25+
versionPrefix = "${versionPrefix}${separator}${preReleaseVersion}"
26+
}
27+
final String versionSuffix = System.getenv("VERSION_SUFFIX")
28+
if (versionSuffix != null && !versionSuffix.isEmpty()) {
29+
versionPrefix = "${versionPrefix}+${versionSuffix}"
30+
}
1831

19-
if ("true".equalsIgnoreCase(System.getenv("IS_DEBUG"))) {
20-
version = "${version}-${System.currentTimeMillis()}"
32+
System.out.println("Version Prefix: " + versionPrefix)
2133
}
2234

23-
final String customVersion = System.getenv("CUSTOM_VERSION")
24-
if (customVersion != null && !customVersion.isEmpty()) {
25-
version = "${version}-${customVersion}"
35+
allprojects {
36+
group = "top.offsetmonkey538.loottablemodifier"
37+
base.archivesName = "mesh-lib" // todo: move to subprojects and give em different suffixes
38+
version = "${rootProject.versionPrefix}+${project.property("minecraft_version")}" // todo: again, move to subprojects
2639
}
2740

28-
version = "${project.version}+${project.minecraft_version}"
29-
println "Version: ${version}"
30-
3141
outlet {
3242
maintainPropertiesFile = System.getenv("DISABLE_PROPERTIES_UPDATE") == null
3343
mcVersionRange = project.supported_minecraft_versions
34-
allowedReleaseTypes = Set.of(ReleaseType.RELEASE)
44+
allowedReleaseTypes = [ReleaseType.RELEASE]
3545
propertiesData = [
3646
'fapi_version': outlet.fapiVersion(project.minecraft_version),
3747
'yarn_version': outlet.yarnVersion(project.minecraft_version),
@@ -168,8 +178,8 @@ tasks.named("javadoc", Javadoc) {
168178
}
169179

170180
jar {
171-
from("LICENSE") {
172-
rename { "${it}_${project.archivesBaseName}" }
181+
from("${rootProject.projectDir}/LICENSE") {
182+
rename { "${it}" }
173183
}
174184
}
175185

@@ -178,26 +188,26 @@ modrinth {
178188
token = System.getenv("MODRINTH_TOKEN")
179189
projectId = "loot-table-modifier"
180190
gameVersions = outlet.mcVersions()
191+
loaders = ["fabric"]
181192

182193
// Version stuff
183194
def customVersionName = System.getenv("VERSION_NAME")
184195
if (customVersionName != null) versionName = customVersionName
185196

186197
versionNumber = "${project.version}"
187198

188-
def isPreRelease = System.getenv("VERSION_IS_PRERELEASE")
189-
versionType = "true".equalsIgnoreCase(isPreRelease) ? "beta" : "release"
199+
versionType = Boolean.parseBoolean(System.getenv("VERSION_IS_PRERELEASE")) ? "beta" : "release"
190200

191-
if (project.mod_version.contains("beta")) versionType = "beta"
192-
else if (project.mod_version.contains("alpha")) versionType = "alpha"
201+
if (rootProject.mod_version.contains("beta")) versionType = "beta"
202+
if (rootProject.mod_version.contains("alpha")) versionType = "alpha"
193203

194204

195205
// Files
196206
uploadFile = remapJar.archiveFile
197-
//additionalFiles = [sourcesJar.archiveFile, javadocJar.archiveFile]
198207
additionalFiles = [sourcesJar.archiveFile]
199208

200209

210+
// Project info
201211
syncBodyFrom = rootProject.file("README.md").text
202212
def changelogEnv = System.getenv("VERSION_CHANGELOG")
203213
if (changelogEnv != null) changelog = changelogEnv
@@ -227,7 +237,7 @@ publishing {
227237
}
228238
publications {
229239
maven(MavenPublication) {
230-
artifactId = "loot-table-modifier"
240+
artifactId = base.archivesName.get()
231241

232242
from(components["java"])
233243
}

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ minecraft_version = 1.21.8
88

99
# These should be automatically updated, unless the environment
1010
# variable "DISABLE_PROPERTIES_UPDATE" is set.
11-
fapi_version = 0.129.0+1.21.8
11+
fapi_version = 0.136.0+1.21.8
1212
yarn_version = 1.21.8+build.1
13-
loader_version = 0.16.14
13+
loader_version = 0.18.0
1414

1515
# Dependencies
1616
## DevAuth, check at https://github.com/DJtheRedstoner/DevAuth
1717
devauth_version = 1.2.1
1818

1919
# Mod Properties
20-
mod_version = 2.0.0-alpha.1
20+
mod_version = 2.0.0-alpha.2
2121
supported_minecraft_versions = >=1.21.5 <=1.21.8

gradle/wrapper/gradle-wrapper.jar

1.83 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionSha256Sum=bd71102213493060956ec229d946beee57158dbd89d0e62b91bca0fa2c5f3531
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
3+
distributionSha256Sum=df67a32e86e3276d011735facb1535f64d0d88df84fa87521e90becc2d735444
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
55
networkTimeout=10000
66
validateDistributionUrl=true
77
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/top/offsetmonkey538/loottablemodifier/LootTableModifier.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import net.minecraft.util.JsonHelper;
3030
import org.apache.commons.io.file.PathUtils;
3131
import org.jetbrains.annotations.NotNull;
32-
import org.jetbrains.annotations.Nullable;
3332
import org.slf4j.Logger;
3433
import org.slf4j.LoggerFactory;
3534
import top.offsetmonkey538.loottablemodifier.api.resource.action.LootModifierActionTypes;
@@ -94,19 +93,18 @@ public static void runModification(ResourceManager resourceManager, Registry<Loo
9493

9594
tableModified = false;
9695

97-
final List<LootPool> poolsCopy = new LinkedList<>(table.pools);
98-
int poolsSize = Math.max(1, poolsCopy.size());
96+
final LootPool[] poolsCopy = table.pools.toArray(LootPool[]::new);
97+
int poolsSize = Math.max(1, poolsCopy.length); // Run loop at least once
9998
for (int i = 0; i < poolsSize; i++) {
100-
final @Nullable LootPool pool = poolsCopy.isEmpty() ? null : poolsCopy.get(i);
99+
final LootPool pool = poolsCopy.length == 0 ? null : poolsCopy[i];
101100
poolModified = false;
102101

103-
final List<LootPoolEntry> entriesCopy = pool == null ? List.of() : new LinkedList<>(pool.entries);
104-
int entriesSize = Math.max(1, entriesCopy.size());
102+
final LootPoolEntry[] entriesCopy = pool == null ? new LootPoolEntry[]{} : pool.entries.toArray(LootPoolEntry[]::new);
103+
int entriesSize = Math.max(1, entriesCopy.length); // Run loop at least once
105104
for (int j = 0; j < entriesSize; j++) {
106-
final @Nullable LootPoolEntry entry = entriesCopy.isEmpty() ? null : entriesCopy.get(j);
105+
final LootPoolEntry entry = entriesCopy.length == 0 ? null : entriesCopy[j];
107106

108107
for (Map.Entry<Identifier, LootModifier> modifierEntry : modifiers.entrySet()) {
109-
// Everything is so fast anyway that there's probably no point in doing what the to-do here said
110108
final LootModifierContext context = new LootModifierContext(table, tableId, pool, entry, tableModified, poolModified);
111109

112110
final LootModifier modifier = modifierEntry.getValue();
@@ -229,7 +227,7 @@ public static Identifier id(String path) {
229227
}
230228

231229
/*
232-
In 1.21.4, the 'Registry' class extends 'RegistryWrapper' and inherits the 'streamEntries' method from *it*.
230+
In 1.21.4, the 'Registry' class extends 'RegistryWrapper' and inherits the 'streamEntries' method from it.
233231
In 1.20.5, the 'Registry' class *doesn't* extend the 'RegistryWrapper' and implements its own 'streamEntries' method.
234232
Compiling on both versions works, because the names of the methods are the same, but they compile to different intermediary names, thus a jar compiled for 1.20.5 doesn't work on 1.21.4 and vice versa.
235233
Solution: Turn the 'Registry' into a 'RegistryWrapper' as its 'streamEntries' retains the same intermediary on both versions.

src/main/java/top/offsetmonkey538/loottablemodifier/api/resource/action/LootModifierActionTypes.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import net.minecraft.util.Identifier;
66
import org.jetbrains.annotations.ApiStatus;
77
import org.jetbrains.annotations.NotNull;
8+
import top.offsetmonkey538.loottablemodifier.api.resource.action.condition.ConditionAddAction;
89
import top.offsetmonkey538.loottablemodifier.api.resource.action.entry.EntryAddAction;
910
import top.offsetmonkey538.loottablemodifier.api.resource.action.entry.EntryRemoveAction;
1011
import top.offsetmonkey538.loottablemodifier.api.resource.action.pool.PoolAddAction;
@@ -45,6 +46,11 @@ private LootModifierActionTypes() {
4546
*/
4647
public static final LootModifierActionType ENTRY_ITEM_SET = register(id("entry_item_set"), EntryItemSetAction.CODEC);
4748

49+
/**
50+
* Type of {@link ConditionAddAction}
51+
*/
52+
public static final LootModifierActionType CONDITION_ADD = register(id("condition_add"), ConditionAddAction.CODEC);
53+
4854
private static LootModifierActionType register(final @NotNull Identifier id, final @NotNull MapCodec<? extends LootModifierAction> codec) {
4955
return Registry.register(LootModifierActionType.REGISTRY, id, new LootModifierActionType(codec));
5056
}

0 commit comments

Comments
 (0)