diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/MixinPlugin.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/MixinPlugin.java index 8fbf86d05..dcdae84ca 100644 --- a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/MixinPlugin.java +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/MixinPlugin.java @@ -45,7 +45,7 @@ public void export(MixinEnvironment env, String name, boolean force, ClassNode c } @Override - public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { ASMTransformerMakeVolatile.transform(targetClass); } } diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/asm/ASMTransformerMakeVolatile.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/asm/ASMTransformerMakeVolatile.java index f76fe47fa..539e1efb4 100644 --- a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/asm/ASMTransformerMakeVolatile.java +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/asm/ASMTransformerMakeVolatile.java @@ -2,138 +2,33 @@ import com.ishland.c2me.base.common.util.ASMUtils; import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; import org.objectweb.asm.tree.ClassNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import java.util.stream.Stream; public class ASMTransformerMakeVolatile { static final Logger LOGGER = LoggerFactory.getLogger("C2ME (c2me-fixes-worldgen-threading-issues) ASM Transformer"); - private static final Map> makeVolatileFields = new HashMap<>(); - private static final Map> makeVolatileFieldsMapped; - - static { - makeVolatileFields.put( - "net/minecraft/class_3353$class_3354", // net/minecraft/structure/MineshaftGenerator$MineshaftCorridor - List.of( - "field_14414:Z" // hasSpawner:Z - ) - ); - makeVolatileFields.put( - "net/minecraft/class_3390$class_3402", // net/minecraft/structure/NetherFortressGenerator$BridgePlatform - List.of( - "field_14498:Z" // hasBlazeSpawner:Z - ) - ); - makeVolatileFields.put( - "net/minecraft/class_3390$class_3398", // net/minecraft/structure/NetherFortressGenerator$CorridorLeftTurn - List.of( - "field_14496:Z" // containsChest:Z - ) - ); - makeVolatileFields.put( - "net/minecraft/class_3390$class_3400", // net/minecraft/structure/NetherFortressGenerator$CorridorRightTurn - List.of( - "field_14497:Z" // containsChest:Z - ) - ); - makeVolatileFields.put( - "net/minecraft/class_3390$class_3407", // net/minecraft/structure/NetherFortressGenerator$Start - List.of( - "field_14506:Lnet/minecraft/class_3390$class_3404;" // lastPiece:Lnet/minecraft/structure/NetherFortressGenerator$PieceData; - ) - ); - makeVolatileFields.put( - "net/minecraft/class_3366$class_3388", // net/minecraft/structure/OceanMonumentGenerator$PieceSetting - List.of( - "field_14485:Z", // used:Z - "field_14484:Z", // not mapped by yarn - "field_14483:I" // not mapped by yarn - ) - ); - makeVolatileFields.put( - "net/minecraft/class_3366$class_3374", // net/minecraft/structure/OceanMonumentGenerator$Base - List.of( - "field_14464:Lnet/minecraft/class_3366$class_3388;", // not mapped by yarn - "field_14466:Lnet/minecraft/class_3366$class_3388;" // not mapped by yarn - ) - ); - makeVolatileFields.put( - "net/minecraft/class_3470", // net/minecraft/structure/SimpleStructurePiece - List.of( - "field_15432:Lnet/minecraft/class_2338;" // pos:Lnet/minecraft/util/math/BlockPos; - ) - ); - makeVolatileFields.put( - "net/minecraft/class_3421$class_3422", // net/minecraft/structure/StrongholdGenerator$ChestCorridor - List.of( - "field_15268:Z" // chestGenerated:Z - ) - ); - makeVolatileFields.put( - "net/minecraft/class_3421$class_3428", // net/minecraft/structure/StrongholdGenerator$PortalRoom - List.of( - "field_15279:Z" // spawnerPlaced:Z - ) - ); - makeVolatileFields.put( - "net/minecraft/class_3421$class_3434", // net/minecraft/structure/StrongholdGenerator$Start - List.of( - "field_15284:Lnet/minecraft/class_3421$class_3427;", // lastPiece:Lnet/minecraft/structure/StrongholdGenerator$PieceData; - "field_15283:Lnet/minecraft/class_3421$class_3428;" // portalRoom:Lnet/minecraft/structure/StrongholdGenerator$PortalRoom; - ) - ); - makeVolatileFields.put( - "net/minecraft/class_3418", // net/minecraft/structure/StructurePieceWithDimensions - List.of( - "field_15241:I" // hPos:I - ) - ); - makeVolatileFields.put( - "net/minecraft/class_3447", // net/minecraft/structure/SwampHutGenerator - List.of( - "field_15322:Z", // hasWitch:Z - "field_16445:Z" // hasCat:Z - ) - ); - makeVolatileFields.put( - "net/minecraft/class_3471$class_3476", // net/minecraft/structure/WoodlandMansionGenerator$GenerationPiece - List.of( - "field_15450:Lnet/minecraft/class_2470;", // rotation:Lnet/minecraft/util/BlockRotation; - "field_15449:Lnet/minecraft/class_2338;", // position:Lnet/minecraft/util/math/BlockPos; - "field_15448:Ljava/lang/String;" // template:Ljava/lang/String; - ) - ); - - makeVolatileFieldsMapped = makeVolatileFields.entrySet().stream() - .map(entry -> { - String mappedClassName = ASMUtils.mappingResolver.mapClassName(ASMUtils.INTERMEDIARY, entry.getKey().replace('/', '.')).replace('.', '/'); - List mappedFieldNames = entry.getValue().stream() - .map(fieldName -> { - String[] split = fieldName.split(":"); - return ASMUtils.mappingResolver.mapFieldName(ASMUtils.INTERMEDIARY, entry.getKey().replace('/', '.'), split[0], split[1]) + ":" + ASMUtils.remapFieldDescriptor(split[1]); - }).toList(); - return new KeyValue<>(mappedClassName, mappedFieldNames); - }).collect(Collectors.toMap(KeyValue::key, KeyValue::value)); - } - public static void transform(ClassNode classNode) { - final List pendingFields = makeVolatileFieldsMapped.get(classNode.name); - if (pendingFields != null) { -// LOGGER.debug("Transforming class {}", classNode.name.replace('/', '.')); - classNode.fields.stream() - .filter(fieldNode -> pendingFields.contains(fieldNode.name + ":" + fieldNode.desc)) - .forEach(fieldNode -> { - LOGGER.debug("Making field L{};{}:{} volatile", classNode.name, fieldNode.name, fieldNode.desc); - fieldNode.access |= Opcodes.ACC_VOLATILE; - }); - } + classNode.fields.stream() + .filter(fieldNode -> + Stream.concat(Stream.ofNullable(fieldNode.visibleAnnotations), Stream.ofNullable(fieldNode.invisibleAnnotations)) + .flatMap(Collection::stream) + .anyMatch(annotationNode -> Type.getDescriptor(MakeVolatile.class).equals(annotationNode.desc)) + ) + .forEach(fieldNode -> { + LOGGER.debug("Making field L{};{}:{} volatile", classNode.name, fieldNode.name, fieldNode.desc); + fieldNode.access |= Opcodes.ACC_VOLATILE; + }); } private record KeyValue(K key, V value) { diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/asm/MakeVolatile.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/asm/MakeVolatile.java new file mode 100644 index 000000000..ffa50e8db --- /dev/null +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/asm/MakeVolatile.java @@ -0,0 +1,4 @@ +package com.ishland.c2me.fixes.worldgen.threading_issues.asm; + +public @interface MakeVolatile { +} diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/asm/ASMTargets.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/asm/ASMTargets.java deleted file mode 100644 index f2a9265d6..000000000 --- a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/asm/ASMTargets.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.ishland.c2me.fixes.worldgen.threading_issues.mixin.asm; - -import net.minecraft.structure.MineshaftGenerator; -import net.minecraft.structure.NetherFortressGenerator; -import net.minecraft.structure.OceanMonumentGenerator; -import net.minecraft.structure.PoolStructurePiece; -import net.minecraft.structure.ShiftableStructurePiece; -import net.minecraft.structure.StrongholdGenerator; -import net.minecraft.structure.SwampHutGenerator; -import net.minecraft.structure.WoodlandMansionGenerator; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(value = { - MineshaftGenerator.MineshaftCorridor.class, - NetherFortressGenerator.BridgePlatform.class, - NetherFortressGenerator.CorridorLeftTurn.class, - NetherFortressGenerator.CorridorRightTurn.class, - NetherFortressGenerator.Start.class, - OceanMonumentGenerator.PieceSetting.class, - OceanMonumentGenerator.Base.class, - PoolStructurePiece.class, - StrongholdGenerator.ChestCorridor.class, - StrongholdGenerator.PortalRoom.class, - StrongholdGenerator.Start.class, - ShiftableStructurePiece.class, - SwampHutGenerator.class, - WoodlandMansionGenerator.GenerationPiece.class, -}) -public class ASMTargets { -} diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinMineshaftGeneratorMineshaftCorridor.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinMineshaftGeneratorMineshaftCorridor.java new file mode 100644 index 000000000..eebef8626 --- /dev/null +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinMineshaftGeneratorMineshaftCorridor.java @@ -0,0 +1,14 @@ +package com.ishland.c2me.fixes.worldgen.threading_issues.mixin.threading; + +import com.ishland.c2me.fixes.worldgen.threading_issues.asm.MakeVolatile; +import net.minecraft.structure.MineshaftGenerator; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(MineshaftGenerator.MineshaftCorridor.class) +public class MixinMineshaftGeneratorMineshaftCorridor { + + @MakeVolatile + @Shadow private boolean hasSpawner; + +} diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinNetherFortressGeneratorBridgePlatform.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinNetherFortressGeneratorBridgePlatform.java new file mode 100644 index 000000000..471a5050b --- /dev/null +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinNetherFortressGeneratorBridgePlatform.java @@ -0,0 +1,14 @@ +package com.ishland.c2me.fixes.worldgen.threading_issues.mixin.threading; + +import com.ishland.c2me.fixes.worldgen.threading_issues.asm.MakeVolatile; +import net.minecraft.structure.NetherFortressGenerator; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(NetherFortressGenerator.BridgePlatform.class) +public class MixinNetherFortressGeneratorBridgePlatform { + + @MakeVolatile + @Shadow private boolean hasBlazeSpawner; + +} diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinNetherFortressGeneratorCorridorLeftTurn.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinNetherFortressGeneratorCorridorLeftTurn.java new file mode 100644 index 000000000..28a6d4440 --- /dev/null +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinNetherFortressGeneratorCorridorLeftTurn.java @@ -0,0 +1,14 @@ +package com.ishland.c2me.fixes.worldgen.threading_issues.mixin.threading; + +import com.ishland.c2me.fixes.worldgen.threading_issues.asm.MakeVolatile; +import net.minecraft.structure.NetherFortressGenerator; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(NetherFortressGenerator.CorridorLeftTurn.class) +public class MixinNetherFortressGeneratorCorridorLeftTurn { + + @MakeVolatile + @Shadow private boolean containsChest; + +} diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinNetherFortressGeneratorCorridorRightTurn.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinNetherFortressGeneratorCorridorRightTurn.java new file mode 100644 index 000000000..039969a45 --- /dev/null +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinNetherFortressGeneratorCorridorRightTurn.java @@ -0,0 +1,14 @@ +package com.ishland.c2me.fixes.worldgen.threading_issues.mixin.threading; + +import com.ishland.c2me.fixes.worldgen.threading_issues.asm.MakeVolatile; +import net.minecraft.structure.NetherFortressGenerator; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(NetherFortressGenerator.CorridorRightTurn.class) +public class MixinNetherFortressGeneratorCorridorRightTurn { + + @MakeVolatile + @Shadow private boolean containsChest; + +} diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinNetherFortressGeneratorStart.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinNetherFortressGeneratorStart.java index 1892a37df..f5c7f88b2 100644 --- a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinNetherFortressGeneratorStart.java +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinNetherFortressGeneratorStart.java @@ -1,5 +1,6 @@ package com.ishland.c2me.fixes.worldgen.threading_issues.mixin.threading; +import com.ishland.c2me.fixes.worldgen.threading_issues.asm.MakeVolatile; import com.ishland.c2me.fixes.worldgen.threading_issues.common.INetherFortressGeneratorPieceData; import net.minecraft.structure.NetherFortressGenerator; import org.objectweb.asm.Opcodes; @@ -19,6 +20,9 @@ public class MixinNetherFortressGeneratorStart { @Shadow public List bridgePieces; @Shadow public List corridorPieces; + @MakeVolatile + @Shadow public NetherFortressGenerator.PieceData lastPiece; + @Redirect(method = "(Lnet/minecraft/util/math/random/Random;II)V", at = @At(value = "FIELD", target = "Lnet/minecraft/structure/NetherFortressGenerator$PieceData;generatedCount:I", opcode = Opcodes.PUTFIELD)) private void redirectSetPieceDataGeneratedCount(NetherFortressGenerator.PieceData pieceData, int value) { ((INetherFortressGeneratorPieceData) pieceData).getGeneratedCountAtomic().set(value); diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinOceanMonumentGeneratorBase.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinOceanMonumentGeneratorBase.java new file mode 100644 index 000000000..09b03a087 --- /dev/null +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinOceanMonumentGeneratorBase.java @@ -0,0 +1,17 @@ +package com.ishland.c2me.fixes.worldgen.threading_issues.mixin.threading; + +import com.ishland.c2me.fixes.worldgen.threading_issues.asm.MakeVolatile; +import net.minecraft.structure.OceanMonumentGenerator; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(OceanMonumentGenerator.Base.class) +public class MixinOceanMonumentGeneratorBase { + + @MakeVolatile + @Shadow private OceanMonumentGenerator.PieceSetting entryPieceSetting; + + @MakeVolatile + @Shadow private OceanMonumentGenerator.PieceSetting coreRoomPieceSetting; + +} diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinOceanMonumentGeneratorPieceSetting.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinOceanMonumentGeneratorPieceSetting.java new file mode 100644 index 000000000..ee60e308b --- /dev/null +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinOceanMonumentGeneratorPieceSetting.java @@ -0,0 +1,20 @@ +package com.ishland.c2me.fixes.worldgen.threading_issues.mixin.threading; + +import com.ishland.c2me.fixes.worldgen.threading_issues.asm.MakeVolatile; +import net.minecraft.structure.OceanMonumentGenerator; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(OceanMonumentGenerator.PieceSetting.class) +public class MixinOceanMonumentGeneratorPieceSetting { + + @MakeVolatile + @Shadow private boolean used; + + @MakeVolatile + @Shadow private boolean field_14484; + + @MakeVolatile + @Shadow private int field_14483; + +} diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinShiftableStructurePiece.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinShiftableStructurePiece.java new file mode 100644 index 000000000..1b5fe2fac --- /dev/null +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinShiftableStructurePiece.java @@ -0,0 +1,14 @@ +package com.ishland.c2me.fixes.worldgen.threading_issues.mixin.threading; + +import com.ishland.c2me.fixes.worldgen.threading_issues.asm.MakeVolatile; +import net.minecraft.structure.ShiftableStructurePiece; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(ShiftableStructurePiece.class) +public class MixinShiftableStructurePiece { + + @MakeVolatile + @Shadow protected int hPos; + +} diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinStrongholdGeneratorChestCorridor.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinStrongholdGeneratorChestCorridor.java new file mode 100644 index 000000000..c9be37288 --- /dev/null +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinStrongholdGeneratorChestCorridor.java @@ -0,0 +1,14 @@ +package com.ishland.c2me.fixes.worldgen.threading_issues.mixin.threading; + +import com.ishland.c2me.fixes.worldgen.threading_issues.asm.MakeVolatile; +import net.minecraft.structure.StrongholdGenerator; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(StrongholdGenerator.ChestCorridor.class) +public class MixinStrongholdGeneratorChestCorridor { + + @MakeVolatile + @Shadow private boolean chestGenerated; + +} diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinStrongholdGeneratorPortalRoom.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinStrongholdGeneratorPortalRoom.java new file mode 100644 index 000000000..a9baca801 --- /dev/null +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinStrongholdGeneratorPortalRoom.java @@ -0,0 +1,14 @@ +package com.ishland.c2me.fixes.worldgen.threading_issues.mixin.threading; + +import com.ishland.c2me.fixes.worldgen.threading_issues.asm.MakeVolatile; +import net.minecraft.structure.StrongholdGenerator; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(StrongholdGenerator.PortalRoom.class) +public class MixinStrongholdGeneratorPortalRoom { + + @MakeVolatile + @Shadow private boolean spawnerPlaced; + +} diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinStrongholdGeneratorStart.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinStrongholdGeneratorStart.java index 82a615221..cef3490f8 100644 --- a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinStrongholdGeneratorStart.java +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinStrongholdGeneratorStart.java @@ -1,7 +1,9 @@ package com.ishland.c2me.fixes.worldgen.threading_issues.mixin.threading; +import com.ishland.c2me.fixes.worldgen.threading_issues.asm.MakeVolatile; import net.minecraft.structure.StrongholdGenerator; import net.minecraft.structure.StructurePiece; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; @@ -19,6 +21,12 @@ public class MixinStrongholdGeneratorStart { @Mutable @Shadow @Final public List pieces; + @MakeVolatile + @Shadow public volatile StrongholdGenerator.PieceData lastPiece; + + @MakeVolatile + @Shadow @Nullable public StrongholdGenerator.@Nullable PortalRoom portalRoom; + @Inject(method = "*", at = @At("RETURN")) private void onInit(CallbackInfo info) { this.pieces = Collections.synchronizedList(pieces); diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinSwampHutGenerator.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinSwampHutGenerator.java new file mode 100644 index 000000000..8509f7110 --- /dev/null +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinSwampHutGenerator.java @@ -0,0 +1,17 @@ +package com.ishland.c2me.fixes.worldgen.threading_issues.mixin.threading; + +import com.ishland.c2me.fixes.worldgen.threading_issues.asm.MakeVolatile; +import net.minecraft.structure.SwampHutGenerator; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(SwampHutGenerator.class) +public class MixinSwampHutGenerator { + + @MakeVolatile + @Shadow private boolean hasWitch; + + @MakeVolatile + @Shadow private boolean hasCat; + +} diff --git a/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinWoodlandMansionGeneratorGenerationPiece.java b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinWoodlandMansionGeneratorGenerationPiece.java new file mode 100644 index 000000000..9f45c2fcb --- /dev/null +++ b/c2me-fixes-worldgen-threading-issues/src/main/java/com/ishland/c2me/fixes/worldgen/threading_issues/mixin/threading/MixinWoodlandMansionGeneratorGenerationPiece.java @@ -0,0 +1,22 @@ +package com.ishland.c2me.fixes.worldgen.threading_issues.mixin.threading; + +import com.ishland.c2me.fixes.worldgen.threading_issues.asm.MakeVolatile; +import net.minecraft.structure.WoodlandMansionGenerator; +import net.minecraft.util.BlockRotation; +import net.minecraft.util.math.BlockPos; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(WoodlandMansionGenerator.GenerationPiece.class) +public class MixinWoodlandMansionGeneratorGenerationPiece { + + @MakeVolatile + @Shadow public BlockRotation rotation; + + @MakeVolatile + @Shadow public BlockPos position; + + @MakeVolatile + @Shadow public String template; + +} diff --git a/c2me-fixes-worldgen-threading-issues/src/main/resources/c2me-fixes-worldgen-threading-issues.mixins.json b/c2me-fixes-worldgen-threading-issues/src/main/resources/c2me-fixes-worldgen-threading-issues.mixins.json index 905d5817a..c18c3525b 100644 --- a/c2me-fixes-worldgen-threading-issues/src/main/resources/c2me-fixes-worldgen-threading-issues.mixins.json +++ b/c2me-fixes-worldgen-threading-issues/src/main/resources/c2me-fixes-worldgen-threading-issues.mixins.json @@ -4,19 +4,27 @@ "package": "com.ishland.c2me.fixes.worldgen.threading_issues.mixin", "plugin": "com.ishland.c2me.fixes.worldgen.threading_issues.MixinPlugin", "mixins": [ - "asm.ASMTargets", "deadlocks.MixinDataFixerType", "threading.MixinChunk", "threading.MixinDesertTempleGenerator", "threading.MixinJungleTempleGenerator", + "threading.MixinMineshaftGeneratorMineshaftCorridor", "threading.MixinMineshaftGeneratorMineshaftRoom", + "threading.MixinNetherFortressGeneratorBridgePlatform", + "threading.MixinNetherFortressGeneratorCorridorLeftTurn", + "threading.MixinNetherFortressGeneratorCorridorRightTurn", "threading.MixinNetherFortressGeneratorPiece", "threading.MixinNetherFortressGeneratorPieceData", "threading.MixinNetherFortressGeneratorStart", "threading.MixinNoiseChunkGenerator", + "threading.MixinOceanMonumentGeneratorBase", + "threading.MixinOceanMonumentGeneratorPieceSetting", "threading.MixinOrder", "threading.MixinRandomizedIntBlockStateProvider", + "threading.MixinShiftableStructurePiece", "threading.MixinStrongholdGenerator", + "threading.MixinStrongholdGeneratorChestCorridor", + "threading.MixinStrongholdGeneratorPortalRoom", "threading.MixinStrongholdGeneratorSpiralStaircase", "threading.MixinStrongholdGeneratorStart", "threading.MixinStructure", @@ -24,7 +32,9 @@ "threading.MixinStructurePalettedBlockInfoList", "threading.MixinStructurePlacementData", "threading.MixinStructureStart", + "threading.MixinSwampHutGenerator", "threading.MixinWeightedList", + "threading.MixinWoodlandMansionGeneratorGenerationPiece", "threading.MixinWoodlandMansionGeneratorMansionParameters", "threading.math.MixinAffineTransformation", "threading.math.MixinDirectionTransformation",