diff --git a/common/src/main/resources/pfm-common.mixins.json b/common/src/main/resources/pfm-common.mixins.json index ead3a615a..5ca318abc 100644 --- a/common/src/main/resources/pfm-common.mixins.json +++ b/common/src/main/resources/pfm-common.mixins.json @@ -7,7 +7,6 @@ "PFMAbstractTagProvider$ObjectBuilderMixin", "PFMMixinPointOfInterestTypeFactory", "PFMPlayerInventoryMixin", - "PFMSaveLoaderMixin", "PFMTextureKeyFactory" ], "server": [ diff --git a/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMSaveLoaderMixin.java b/fabric/src/main/java/com/unlikepaladin/pfm/mixin/fabric/PFMSaveLoaderMixin.java similarity index 91% rename from common/src/main/java/com/unlikepaladin/pfm/mixin/PFMSaveLoaderMixin.java rename to fabric/src/main/java/com/unlikepaladin/pfm/mixin/fabric/PFMSaveLoaderMixin.java index e2a26bc64..dab56903c 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMSaveLoaderMixin.java +++ b/fabric/src/main/java/com/unlikepaladin/pfm/mixin/fabric/PFMSaveLoaderMixin.java @@ -1,4 +1,5 @@ -package com.unlikepaladin.pfm.mixin; +package com.unlikepaladin.pfm.mixin.fabric; + import com.google.common.base.Suppliers; import com.mojang.bridge.game.PackType; @@ -25,7 +26,9 @@ private static List createReload(List packs) { List resourcePacks = new ArrayList<>(packs); PackResourceMetadata packResourceMetadata = new PackResourceMetadata(new LiteralText("pfm-runtime-resources"), SharedConstants.getGameVersion().getPackVersion(PackType.RESOURCE)); resourcePacks.add(new PathPackRPWrapper(Suppliers.memoize(() -> { - PFMRuntimeResources.prepareAndRunResourceGen(false); return PFMRuntimeResources.ASSETS_PACK;}), packResourceMetadata)); + PFMRuntimeResources.prepareAndRunResourceGen(false); + return PFMRuntimeResources.ASSETS_PACK; + }), packResourceMetadata)); return resourcePacks; } -} +} \ No newline at end of file diff --git a/fabric/src/main/resources/pfm.mixins.json b/fabric/src/main/resources/pfm.mixins.json index e0229b939..57e469c13 100755 --- a/fabric/src/main/resources/pfm.mixins.json +++ b/fabric/src/main/resources/pfm.mixins.json @@ -9,7 +9,8 @@ "PFMCookingPotBlockEntityMixin", "PFMMinecraftServerMixin", "PFMMixinPointOfInterestType", - "PFMReloadableResourceManagerImplMixin" + "PFMReloadableResourceManagerImplMixin", + "PFMSaveLoaderMixin" ], "injectors": { "defaultRequire": 1 diff --git a/forge/src/main/java/com/unlikepaladin/pfm/mixin/forge/PFMSaveLoaderMixin.java b/forge/src/main/java/com/unlikepaladin/pfm/mixin/forge/PFMSaveLoaderMixin.java new file mode 100644 index 000000000..d14e66edc --- /dev/null +++ b/forge/src/main/java/com/unlikepaladin/pfm/mixin/forge/PFMSaveLoaderMixin.java @@ -0,0 +1,24 @@ +package com.unlikepaladin.pfm.mixin.forge; + +import com.unlikepaladin.pfm.client.PathPackRPWrapper; +import com.unlikepaladin.pfm.runtime.PFMRuntimeResources; +import net.minecraft.resource.ResourcePack; +import net.minecraft.server.SaveLoader; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +import java.util.ArrayList; +import java.util.List; + +@Mixin(SaveLoader.class) +public class PFMSaveLoaderMixin { + + @ModifyArg(method = "ofLoaded", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/LifecycledResourceManagerImpl;(Lnet/minecraft/resource/ResourceType;Ljava/util/List;)V"), index = 1) + private static List createReload(List packs) { + List resourcePacks = new ArrayList<>(packs); + resourcePacks.removeIf(pack -> pack instanceof PathPackRPWrapper); + PFMRuntimeResources.RESOURCE_PACK_LIST = resourcePacks; + return packs; + } +} diff --git a/forge/src/main/resources/pfm.mixins.json b/forge/src/main/resources/pfm.mixins.json index f41e8f098..05886d39d 100755 --- a/forge/src/main/resources/pfm.mixins.json +++ b/forge/src/main/resources/pfm.mixins.json @@ -9,8 +9,9 @@ ], "mixins": [ "PFMCookingPotBlockEntityMixin", + "PFMMinecraftServerMixin", "PFMReloadableResourceManagerImplMixin", - "PFMMinecraftServerMixin" + "PFMSaveLoaderMixin" ], "injectors": { "defaultRequire": 1