Skip to content

Commit cd9adbd

Browse files
committed
Merge 1.18 into 1.19.2
2 parents affb24f + 6efa7f3 commit cd9adbd

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

forge/src/main/java/org/embeddedt/modernfix/forge/config/ConfigFixer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public void accept(IConfigEvent modConfigEvent) {
5050
this.actualHandler.accept(modConfigEvent);
5151
}
5252
} else {
53-
ModernFix.LOGGER.warn("Unable to sync on a {} config object", modConfigEvent.getConfig().getConfigData().getClass().getName());
53+
if(modConfigEvent.getConfig().getConfigData() != null)
54+
ModernFix.LOGGER.warn("Unable to sync on a {} config object", modConfigEvent.getConfig().getConfigData().getClass().getName());
5455
this.actualHandler.accept(modConfigEvent);
5556
}
5657
}

forge/src/main/java/org/embeddedt/modernfix/forge/config/NightConfigFixer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ public Object computeIfAbsent(Path key, Function<? super Path, ?> mappingFunctio
8585
private static final Set<Class<?>> UNKNOWN_FILE_CONFIG_CLASSES = Collections.synchronizedSet(new ReferenceOpenHashSet<>());
8686

8787
public static Object toWriteSyncConfig(Object config) {
88+
if(config == null)
89+
return null;
8890
try {
8991
if(WRITE_SYNC_CONFIG.isAssignableFrom(config.getClass())) {
9092
return config;

forge/src/main/java/org/embeddedt/modernfix/forge/dynresources/ModelBakeEventHelper.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
import org.embeddedt.modernfix.dynamicresources.ModelLocationCache;
1818
import org.jetbrains.annotations.Nullable;
1919

20-
import java.util.HashSet;
21-
import java.util.Map;
22-
import java.util.Optional;
23-
import java.util.Set;
20+
import java.util.*;
2421

2522
/**
2623
* Stores a list of all known default block/item models in the game, and provides a namespaced version
@@ -54,7 +51,9 @@ public ModelBakeEventHelper(Map<ResourceLocation, BakedModel> modelRegistry) {
5451
Optional<? extends ModContainer> mContainer = ModList.get().getModContainerById(id);
5552
if(mContainer.isPresent()) {
5653
for(IModInfo.ModVersion version : mContainer.get().getModInfo().getDependencies()) {
57-
this.dependencyGraph.putEdge(id, version.getModId());
54+
// avoid self-loops
55+
if(!Objects.equals(id, version.getModId()))
56+
this.dependencyGraph.putEdge(id, version.getModId());
5857
}
5958
}
6059
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.embeddedt.modernfix.forge.mixin.bugfix.cofh_core_crash;
2+
3+
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
4+
import org.embeddedt.modernfix.annotation.RequiresMod;
5+
import org.spongepowered.asm.mixin.*;
6+
import org.spongepowered.asm.mixin.injection.At;
7+
import org.spongepowered.asm.mixin.injection.Coerce;
8+
import org.spongepowered.asm.mixin.injection.Redirect;
9+
10+
import java.util.function.BooleanSupplier;
11+
12+
/**
13+
* Fix getOrCreateFlag accessing the FLAGS map without synchronization by wrapping all calls to it
14+
* in a synchronized block.
15+
*/
16+
@Pseudo
17+
@Mixin(targets = { "cofh/lib/util/flags/FlagManager" }, remap = false)
18+
@RequiresMod("cofh_core")
19+
public class FlagManagerMixin {
20+
@Shadow @Final
21+
private static Object2ObjectOpenHashMap<String, BooleanSupplier> FLAGS;
22+
23+
@Shadow
24+
private BooleanSupplier getOrCreateFlag(String flag) {
25+
throw new AssertionError();
26+
}
27+
28+
@Redirect(method = "*", at = @At(value = "INVOKE", target = "getOrCreateFlag"), require = 0)
29+
private BooleanSupplier getFlag(@Coerce Object flagHandler, String flag) {
30+
if(flagHandler != this)
31+
throw new AssertionError("Redirect targeted bad getOrCreateFlag invocation");
32+
synchronized (FLAGS) {
33+
return this.getOrCreateFlag(flag);
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)