diff --git a/common/src/main/resources/pfm-common.mixins.json b/common/src/main/resources/pfm-common.mixins.json index e82398036..06d3d3232 100644 --- a/common/src/main/resources/pfm-common.mixins.json +++ b/common/src/main/resources/pfm-common.mixins.json @@ -6,7 +6,6 @@ "mixins": [ "PFMDataCache$CachedDataMixin", "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 e53eda0c3..1d6ec2f45 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; @@ -26,7 +27,9 @@ private List createReload(List packs) { List resourcePacks = new ArrayList<>(packs); PackResourceMetadata packResourceMetadata = new PackResourceMetadata(Text.literal("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 dad4cdaf5..57ec8fe71 100755 --- a/fabric/src/main/resources/pfm.mixins.json +++ b/fabric/src/main/resources/pfm.mixins.json @@ -10,7 +10,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..8ee9d74c5 --- /dev/null +++ b/forge/src/main/java/com/unlikepaladin/pfm/mixin/forge/PFMSaveLoaderMixin.java @@ -0,0 +1,25 @@ +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 net.minecraft.server.SaveLoading; +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(SaveLoading.DataPacks.class) +public class PFMSaveLoaderMixin { + + @ModifyArg(method = "load", 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 ba715cdba..46eac2678 100755 --- a/forge/src/main/resources/pfm.mixins.json +++ b/forge/src/main/resources/pfm.mixins.json @@ -10,8 +10,9 @@ "mixins": [ "PFMAbstractTagProvider$ObjectBuilderMixin", "PFMCookingPotBlockEntityMixin", + "PFMMinecraftServerMixin", "PFMReloadableResourceManagerImplMixin", - "PFMMinecraftServerMixin" + "PFMSaveLoaderMixin" ], "injectors": { "defaultRequire": 1