Skip to content

Commit 1728de0

Browse files
committed
Fix CME in BiomeDictionary.Type
Thanks @Asek3 for noticing this
1 parent 06878c6 commit 1728de0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.embeddedt.modernfix.forge.mixin.bugfix.biome_dictionary_cme;
2+
3+
import net.minecraftforge.common.BiomeDictionary;
4+
import org.objectweb.asm.Opcodes;
5+
import org.spongepowered.asm.mixin.Final;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.Mutable;
8+
import org.spongepowered.asm.mixin.Shadow;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
import org.spongepowered.asm.mixin.injection.Redirect;
11+
12+
import java.util.Map;
13+
import java.util.concurrent.ConcurrentSkipListMap;
14+
15+
@Mixin(value = BiomeDictionary.Type.class, remap = false)
16+
public class BiomeDictionaryTypeMixin {
17+
@Shadow
18+
@Mutable
19+
@Final
20+
private static Map<String, BiomeDictionary.Type> byName;
21+
22+
/**
23+
* @author embeddedt
24+
* @reason Biome types are created concurrently so the backing map needs to be thread-safe
25+
*/
26+
@Redirect(method = "<clinit>", at = @At(value = "FIELD", target = "Lnet/minecraftforge/common/BiomeDictionary$Type;byName:Ljava/util/Map;", opcode = Opcodes.PUTSTATIC))
27+
private static void useConcurrentMap(Map<String, BiomeDictionary.Type> treeMap) {
28+
byName = new ConcurrentSkipListMap<>();
29+
}
30+
}

0 commit comments

Comments
 (0)