From 20a15a587cfb1066aa22f0deff5de26546101308 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Wed, 30 Aug 2023 19:22:15 -0400 Subject: [PATCH 1/2] Create CONTRIBUTING.md [skip ci] --- CONTRIBUTING.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..bc3b5c91 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,22 @@ +ModernFix is a standard Minecraft-style Gradle project powered by Architectury Loom. To build the mod for all platforms, +run the `build` task (e.g. via `./gradlew build`). You can also use `./gradlew forge:build` or `./gradlew fabric:build` +to build for just one loader (e.g. when debugging and wanting to rebuild quickly). + +You must use Java 17 to develop ModernFix as the toolchain requires it. Nonetheless, the 1.16 mod JARs will work on +a Minecraft instance with Java 8. + +## Submitting pull requests + +Code or documentation contributions are welcome. Please keep the following points in mind: + +* This project supports many Minecraft versions. Ideally, contributions should be made to the oldest relevant MC version. +For instance, a PR optimizing new worldgen should be made to 1.18 (not 1.19 or 1.20) while a PR optimizing something +like recipes should be made to 1.16 (the oldest supported version). + + This somewhat unconventional policy ensures that all supported versions are treated equal when it comes to development, +rather than the onus being on other modders and players to backport changes that are needed. Changes to older versions are +quickly ported up to the latest one as part of the regular development cycle. You are still welcome to open PRs against +a newer branch if desired - but the change will likely be applied manually and not merged as a regular PR. + +* Please ensure your code is reasonably neat and sufficiently documented. Remember that self-documenting code is always +better. From fcde6104eb774acce18747ed75dd6130544986cf Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Wed, 30 Aug 2023 18:49:25 -0400 Subject: [PATCH 2/2] Possible NPE fixes for KubeJS --- .../forge/mixin/perf/kubejs/IDFilterMixin.java | 7 +++++-- .../forge/mixin/perf/kubejs/TagWrapperMixin.java | 15 +++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/forge/src/main/java/org/embeddedt/modernfix/forge/mixin/perf/kubejs/IDFilterMixin.java b/forge/src/main/java/org/embeddedt/modernfix/forge/mixin/perf/kubejs/IDFilterMixin.java index 1278203b..98ccf9a8 100644 --- a/forge/src/main/java/org/embeddedt/modernfix/forge/mixin/perf/kubejs/IDFilterMixin.java +++ b/forge/src/main/java/org/embeddedt/modernfix/forge/mixin/perf/kubejs/IDFilterMixin.java @@ -24,8 +24,11 @@ public class IDFilterMixin { @Overwrite(remap = false) public boolean test(RecipeJS recipe) { if(!_targetSearched) { - _target = KubeUtil.originalRecipesByHash.get(this.id); - _targetSearched = true; + if(KubeUtil.originalRecipesByHash.size() > 0) { + _target = KubeUtil.originalRecipesByHash.get(this.id); + _targetSearched = true; + } else + return recipe.getOrCreateId().equals(this.id); // fallback } return recipe == _target; } diff --git a/forge/src/main/java/org/embeddedt/modernfix/forge/mixin/perf/kubejs/TagWrapperMixin.java b/forge/src/main/java/org/embeddedt/modernfix/forge/mixin/perf/kubejs/TagWrapperMixin.java index ada7a4e2..bfc23bf8 100644 --- a/forge/src/main/java/org/embeddedt/modernfix/forge/mixin/perf/kubejs/TagWrapperMixin.java +++ b/forge/src/main/java/org/embeddedt/modernfix/forge/mixin/perf/kubejs/TagWrapperMixin.java @@ -4,6 +4,7 @@ import dev.latvian.kubejs.server.TagEventJS; import dev.latvian.kubejs.util.UtilsJS; import me.shedaniel.architectury.registry.Registry; import net.minecraft.resources.ResourceLocation; +import org.embeddedt.modernfix.ModernFix; import org.embeddedt.modernfix.annotation.RequiresMod; import org.embeddedt.modernfix.forge.util.KubeUtil; import org.spongepowered.asm.mixin.Mixin; @@ -29,15 +30,21 @@ public class TagWrapperMixin { @Redirect(method = "add", at = @At(value = "INVOKE", target = "Lme/shedaniel/architectury/registry/Registry;getIds()Ljava/util/Set;", ordinal = 0), remap = false) private Set getCachedIds(Registry registryIn) { + String currentPatternStr = this.currentPatternStr; if(currentPatternStr == null) throw new AssertionError(); Set cachedSet = KubeUtil.matchedIdsForRegex.get(currentPatternStr); if(cachedSet == null) { Pattern thePattern = UtilsJS.parseRegex(currentPatternStr); - ArrayList locations = new ArrayList<>(registryIn.getIds()); - cachedSet = locations.parallelStream() - .filter(rLoc -> thePattern.matcher(rLoc.toString()).find()) - .collect(Collectors.toSet()); + if(thePattern != null) { + ArrayList locations = new ArrayList<>(registryIn.getIds()); + cachedSet = locations.parallelStream() + .filter(rLoc -> thePattern.matcher(rLoc.toString()).find()) + .collect(Collectors.toSet()); + } else { + ModernFix.LOGGER.error("Empty pattern for '{}' somehow... ignoring...", currentPatternStr); + cachedSet = new HashSet<>(); + } KubeUtil.matchedIdsForRegex.put(currentPatternStr, cachedSet); } return cachedSet;