diff --git a/modules/base/src/main/java/io/github/fabricators_of_create/porting_lib/mixin/common/PackRepositoryMixin.java b/modules/base/src/main/java/io/github/fabricators_of_create/porting_lib/mixin/common/PackRepositoryMixin.java new file mode 100644 index 00000000..725427c5 --- /dev/null +++ b/modules/base/src/main/java/io/github/fabricators_of_create/porting_lib/mixin/common/PackRepositoryMixin.java @@ -0,0 +1,25 @@ +package io.github.fabricators_of_create.porting_lib.mixin.common; + +import com.google.common.collect.ImmutableSet; +import io.github.fabricators_of_create.porting_lib.extensions.PackRepositoryExtension; +import net.minecraft.server.packs.repository.PackRepository; +import net.minecraft.server.packs.repository.RepositorySource; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.Shadow; + +import java.util.HashSet; +import java.util.Set; + +@Mixin(PackRepository.class) +public class PackRepositoryMixin implements PackRepositoryExtension { + @Mutable + @Shadow @Final private Set<RepositorySource> sources; + + public void pl$addPackFinder(RepositorySource packFinder) { + if (sources instanceof ImmutableSet<RepositorySource>) + sources = new HashSet<>(sources); + sources.add(packFinder); + } +} diff --git a/modules/base/src/main/resources/porting_lib_base.mixins.json b/modules/base/src/main/resources/porting_lib_base.mixins.json index 02986263..d4f315e3 100644 --- a/modules/base/src/main/resources/porting_lib_base.mixins.json +++ b/modules/base/src/main/resources/porting_lib_base.mixins.json @@ -56,6 +56,7 @@ "common.MainMixin", "common.MapDecorationMixin", "common.MushroomCowMixin", + "common.PackRepositoryMixin", "common.PiglinAiMixin", "common.PistonMovingBlockEntityMixin", "common.PistonStructureResolverMixin",