Skip to content

Commit

Permalink
Fixed another possible issue with reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Nov 5, 2023
1 parent 85a5be8 commit 8fb3fe5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
1 change: 0 additions & 1 deletion common/src/main/resources/pfm-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"PFMAbstractTagProvider$ObjectBuilderMixin",
"PFMMixinPointOfInterestTypeFactory",
"PFMPlayerInventoryMixin",
"PFMSaveLoaderMixin",
"PFMTextureKeyFactory"
],
"server": [
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -25,7 +26,9 @@ private static List<ResourcePack> createReload(List<ResourcePack> packs) {
List<ResourcePack> 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;
}
}
}
3 changes: 2 additions & 1 deletion fabric/src/main/resources/pfm.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"PFMCookingPotBlockEntityMixin",
"PFMMinecraftServerMixin",
"PFMMixinPointOfInterestType",
"PFMReloadableResourceManagerImplMixin"
"PFMReloadableResourceManagerImplMixin",
"PFMSaveLoaderMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down
Original file line number Diff line number Diff line change
@@ -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;<init>(Lnet/minecraft/resource/ResourceType;Ljava/util/List;)V"), index = 1)
private static List<ResourcePack> createReload(List<ResourcePack> packs) {
List<ResourcePack> resourcePacks = new ArrayList<>(packs);
resourcePacks.removeIf(pack -> pack instanceof PathPackRPWrapper);
PFMRuntimeResources.RESOURCE_PACK_LIST = resourcePacks;
return packs;
}
}
3 changes: 2 additions & 1 deletion forge/src/main/resources/pfm.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
],
"mixins": [
"PFMCookingPotBlockEntityMixin",
"PFMMinecraftServerMixin",
"PFMReloadableResourceManagerImplMixin",
"PFMMinecraftServerMixin"
"PFMSaveLoaderMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 8fb3fe5

Please sign in to comment.