Add fix for Java 11+ worldgen crash

This commit is contained in:
embeddedt 2023-02-17 21:46:31 -05:00
parent 8f971a2c84
commit 312fb4c6f5
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
3 changed files with 29 additions and 0 deletions

View File

@ -29,6 +29,7 @@ public class ModernFixEarlyConfig {
this.addMixinRule("bugfix.concurrency", true);
this.addMixinRule("bugfix.edge_chunk_not_saved", true);
this.addMixinRule("bugfix.packet_leak", false);
this.addMixinRule("bugfix.structure_manager_crash", true);
this.addMixinRule("perf.async_jei", true);
this.addMixinRule("perf.thread_priorities", true);
this.addMixinRule("perf.preload_block_classes", false);

View File

@ -0,0 +1,27 @@
package org.embeddedt.modernfix.mixin.bugfix.structure_manager_crash;
import com.mojang.datafixers.DataFixer;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import net.minecraft.world.level.storage.LevelStorageSource;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Collections;
import java.util.Map;
@Mixin(StructureManager.class)
public class StructureManagerMixin {
@Shadow @Final private Map<ResourceLocation, StructureTemplate> structureRepository;
@Inject(method = "<init>", at = @At("RETURN"))
private void makeStructuresSafe(ResourceManager arg, LevelStorageSource.LevelStorageAccess arg2, DataFixer dataFixer, CallbackInfo ci) {
this.structureRepository = Collections.synchronizedMap(this.structureRepository);
}
}

View File

@ -7,6 +7,7 @@
"refmap": "modernfix.refmap.json",
"mixins": [
"bugfix.edge_chunk_not_saved.ChunkManagerMixin",
"bugfix.structure_manager_crash.StructureManagerMixin",
"perf.remove_biome_temperature_cache.BiomeMixin",
"perf.resourcepacks.ModFileResourcePackMixin",
"perf.resourcepacks.VanillaPackMixin",