1
0
mirror of https://github.com/GeyserMC/Rainbow.git synced 2025-12-19 14:59:16 +00:00

Only stitch/export first frame of animation

This commit is contained in:
Eclipse
2025-10-18 11:57:32 +00:00
parent bf07311112
commit 14329fbb13
6 changed files with 70 additions and 24 deletions

View File

@@ -2,31 +2,33 @@ package org.geysermc.rainbow.client;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.item.ClientItem;
import net.minecraft.client.renderer.texture.SpriteContents;
import net.minecraft.client.resources.model.AtlasManager;
import net.minecraft.client.resources.model.EquipmentAssetManager;
import net.minecraft.client.resources.model.EquipmentClientInfo;
import net.minecraft.client.resources.model.ModelManager;
import net.minecraft.client.resources.model.ResolvedModel;
import net.minecraft.data.AtlasIds;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.world.item.equipment.EquipmentAsset;
import org.geysermc.rainbow.client.accessor.ResolvedModelAccessor;
import org.geysermc.rainbow.client.mixin.EntityRenderDispatcherAccessor;
import org.geysermc.rainbow.mapping.AssetResolver;
import org.geysermc.rainbow.mapping.texture.TextureResource;
import org.geysermc.rainbow.mixin.SpriteContentsAccessor;
import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;
public class MinecraftAssetResolver implements AssetResolver {
private final ModelManager modelManager;
private final EquipmentAssetManager equipmentAssetManager;
private final ResourceManager resourceManager;
private final AtlasManager atlasManager;
public MinecraftAssetResolver(Minecraft minecraft) {
modelManager = minecraft.getModelManager();
equipmentAssetManager = ((EntityRenderDispatcherAccessor) minecraft.getEntityRenderDispatcher()).getEquipmentAssets();
resourceManager = minecraft.getResourceManager();
atlasManager = minecraft.getAtlasManager();
}
@Override
@@ -45,7 +47,8 @@ public class MinecraftAssetResolver implements AssetResolver {
}
@Override
public InputStream openAsset(ResourceLocation location) throws IOException {
return resourceManager.open(location);
public Optional<TextureResource> getBlockTexture(ResourceLocation location) {
SpriteContents contents = atlasManager.getAtlasOrThrow(AtlasIds.BLOCKS).getSprite(location).contents();
return Optional.of(new TextureResource(((SpriteContentsAccessor) contents).getOriginalImage(), contents.width(), contents.height()));
}
}