Skip to content

Commit

Permalink
Changed recipe decoding to not return immutables (#1995)
Browse files Browse the repository at this point in the history
  • Loading branch information
krossgg committed Sep 22, 2024
1 parent c829115 commit eb89f6e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gradle/scripts/publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ publishing {
repositories {
// Add repositories to publish to here.
maven {
url "https://maven.firstdarkdev.xyz/snapshots"
url "https://maven.gtceu.com"
credentials {
username System.getenv("MAVEN_USER")
password System.getenv("MAVEN_PASS")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.gregtechceu.gtceu.GTCEu;

import com.google.common.collect.ImmutableMap;
import com.mojang.datafixers.util.Pair;
import com.mojang.datafixers.util.Unit;
import com.mojang.serialization.*;
Expand Down Expand Up @@ -44,7 +43,7 @@ public <T> DataResult<Pair<Map<K, V>, T>> decode(final DynamicOps<T> ops, final
(result, entry) -> parseEntry(result, ops, entry, entries, failed),
(r1, r2) -> r1.apply2stable((u1, u2) -> u1, r2));

final Pair<Map<K, V>, T> pair = Pair.of(ImmutableMap.copyOf(entries), input);
final Pair<Map<K, V>, T> pair = Pair.of(new Object2ObjectArrayMap<>(entries), input);
final T errors = ops.createMap(failed.build());

return finalResult.map(ignored -> pair).setPartial(pair)
Expand Down
26 changes: 15 additions & 11 deletions src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,21 @@ private void fillContent(IRecipeCapabilityHolder holder, Map.Entry<RecipeCapabil
}
}

int recipeTier = RecipeHelper.getPreOCRecipeEuTier(recipe);
int holderTier = holder.getChanceTier();
var cache = this.chanceCaches.get(cap);
chancedContents = logic.roll(chancedContents, function, recipeTier, holderTier, cache, recipe.parallels, cap);

if (chancedContents == null) return;
for (Content cont : chancedContents) {
if (cont.slotName == null) {
this.content.content.add(cont.content);
} else {
this.content.slots.computeIfAbsent(cont.slotName, s -> new ArrayList<>()).add(cont.content);
// Only roll if there's anything to roll for
if (!chancedContents.isEmpty()) {
int recipeTier = RecipeHelper.getPreOCRecipeEuTier(recipe);
int holderTier = holder.getChanceTier();
var cache = this.chanceCaches.get(cap);
chancedContents = logic.roll(chancedContents, function, recipeTier, holderTier, cache, recipe.parallels,
cap);

if (chancedContents == null) return;
for (Content cont : chancedContents) {
if (cont.slotName == null) {
this.content.content.add(cont.content);
} else {
this.content.slots.computeIfAbsent(cont.slotName, s -> new ArrayList<>()).add(cont.content);
}
}
}
}
Expand Down

0 comments on commit eb89f6e

Please sign in to comment.