diff --git a/common/src/main/java/io/github/moremcmeta/moremcmeta/impl/client/MoreMcmeta.java b/common/src/main/java/io/github/moremcmeta/moremcmeta/impl/client/MoreMcmeta.java index 76d018b7..44e70a46 100644 --- a/common/src/main/java/io/github/moremcmeta/moremcmeta/impl/client/MoreMcmeta.java +++ b/common/src/main/java/io/github/moremcmeta/moremcmeta/impl/client/MoreMcmeta.java @@ -38,7 +38,6 @@ import io.github.moremcmeta.moremcmeta.impl.client.io.TextureData; import io.github.moremcmeta.moremcmeta.impl.client.io.TextureDataAssembler; import io.github.moremcmeta.moremcmeta.impl.client.io.TextureDataReader; -import io.github.moremcmeta.moremcmeta.impl.client.mixin.TextureManagerAccessor; import io.github.moremcmeta.moremcmeta.impl.client.resource.MetadataRegistryImpl; import io.github.moremcmeta.moremcmeta.impl.client.resource.ModRepositorySource; import io.github.moremcmeta.moremcmeta.impl.client.resource.OrderedResourceRepository; @@ -58,6 +57,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.LoadingOverlay; import net.minecraft.client.gui.screens.Overlay; +import net.minecraft.client.renderer.texture.AbstractTexture; import net.minecraft.client.renderer.texture.MipmapGenerator; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -342,6 +342,13 @@ protected abstract StagedResourceReloadListener texManager); + /** + * Get all textures currently registered with the texture manager. + * @param textureManager texture manager containing registered textures + * @return all registered textures + */ + protected abstract Map allRegisteredTextures(TextureManager textureManager); + /** * Divides the collection of all plugins into their separate subtypes. * @param plugins the plugins to divide @@ -635,10 +642,10 @@ private void addCompletedReloadCallback(TextureManagerWrapper reloadInstance = reloadInstance(overlay.get(), logger); reloadInstance.ifPresent((instance) -> instance.done().thenRun(() -> { - TextureManagerAccessor textureManager = (TextureManagerAccessor) Minecraft.getInstance().getTextureManager(); + Map allTextures = allRegisteredTextures(Minecraft.getInstance().getTextureManager()); SpriteFinder spriteFinder = new SpriteFinder( (loc) -> new AtlasAdapter(loc, mipmapLevelGetter(logger)), - textureManager.moremcmeta_byPath().entrySet().stream() + allTextures.entrySet().stream() .filter((entry) -> entry.getValue() instanceof TextureAtlas) .map(Map.Entry::getKey) .collect(Collectors.toSet()) diff --git a/fabric/src/main/java/io/github/moremcmeta/moremcmeta/fabric/impl/client/MoreMcmetaFabric.java b/fabric/src/main/java/io/github/moremcmeta/moremcmeta/fabric/impl/client/MoreMcmetaFabric.java index e9a9f4c1..eb9d6f8b 100644 --- a/fabric/src/main/java/io/github/moremcmeta/moremcmeta/fabric/impl/client/MoreMcmetaFabric.java +++ b/fabric/src/main/java/io/github/moremcmeta/moremcmeta/fabric/impl/client/MoreMcmetaFabric.java @@ -36,6 +36,7 @@ import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.LoadingOverlay; +import net.minecraft.client.renderer.texture.AbstractTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.resources.ResourceLocation; @@ -133,6 +134,11 @@ protected void startTicking(TextureManagerWrapper texManager ClientTickEvents.START_CLIENT_TICK.register((client) -> texManager.tick()); } + @Override + protected Map allRegisteredTextures(TextureManager textureManager) { + return ((TextureManagerAccessor) textureManager).moremcmeta_byPath(); + } + /** * Retrieves all plugins with the given class. * @param pluginClass the class of the plugin diff --git a/forge/src/main/java/io/github/moremcmeta/moremcmeta/forge/impl/client/MoreMcmetaForge.java b/forge/src/main/java/io/github/moremcmeta/moremcmeta/forge/impl/client/MoreMcmetaForge.java index 692e072f..d283bd95 100644 --- a/forge/src/main/java/io/github/moremcmeta/moremcmeta/forge/impl/client/MoreMcmetaForge.java +++ b/forge/src/main/java/io/github/moremcmeta/moremcmeta/forge/impl/client/MoreMcmetaForge.java @@ -23,6 +23,7 @@ import io.github.moremcmeta.moremcmeta.api.client.ClientPlugin; import io.github.moremcmeta.moremcmeta.forge.api.client.MoreMcmetaClientPlugin; import io.github.moremcmeta.moremcmeta.forge.impl.client.event.ClientTicker; +import io.github.moremcmeta.moremcmeta.forge.impl.client.mixin.TextureManagerAccessor; import io.github.moremcmeta.moremcmeta.forge.impl.client.reflection.AnnotatedClassLoader; import io.github.moremcmeta.moremcmeta.impl.client.MoreMcmeta; import io.github.moremcmeta.moremcmeta.impl.client.resource.StagedResourceReloadListener; @@ -31,6 +32,7 @@ import io.github.moremcmeta.moremcmeta.impl.client.texture.TexturePreparer; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.LoadingOverlay; +import net.minecraft.client.renderer.texture.AbstractTexture; import net.minecraft.client.renderer.texture.SpriteContents; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureManager; @@ -169,4 +171,9 @@ protected void startTicking(TextureManagerWrapper texManager new ClientTicker(ImmutableList.of(texManager), MinecraftForge.EVENT_BUS, TickEvent.Phase.START, () -> true); } + @Override + protected Map allRegisteredTextures(TextureManager textureManager) { + return ((TextureManagerAccessor) textureManager).moremcmeta_byPath(); + } + }