Jump to content

Recommended Posts

Posted

My IResourcePack ask for mcmeta files, instead of images, have done something wrong it is definitely requesting files from my IResourcePack so it wired up right.

 

IResourcePack Class:

 

package dijkstra.wardrobe.client;

import com.google.common.collect.ImmutableSet;
import dijkstra.wardrobe.Logging;
import net.minecraft.client.resources.IResourcePack;
import net.minecraft.client.resources.data.IMetadataSection;
import net.minecraft.client.resources.data.MetadataSerializer;
import net.minecraft.util.ResourceLocation;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Set;

public class ResourceLoader implements IResourcePack {

    public static final Set<String> RESOURCE_DOMAINS = ImmutableSet.<String>of("wardrobe");

    @Override
    public InputStream getInputStream(ResourceLocation location) throws IOException {
        File path = new File("resources/wardrobe/textuers/");
        if(!path.exists()){
            path.mkdirs();
        }
        if(resourceExists(location)){
            String name = location.getResourcePath();
            if(name.contains(".mc"))
                name = name.substring(0, name.indexOf('.'));
            Logging.info(name);
            File file  = new File(String.format("resources/wardrobe/textuers/%s.png", name));
            Logging.info(file.toString());
            return new FileInputStream(file);
        }
        return null;
    }

    @Override
    public boolean resourceExists(ResourceLocation location) {
        return true;
        //return new File(String.format("/resources/wardrobe/textuers/%s.png", location.getResourcePath())).exists();
    }

    @Override
    public Set<String> getResourceDomains() {
        return RESOURCE_DOMAINS;
    }

    @Override
    public <T extends IMetadataSection> T getPackMetadata(MetadataSerializer metadataSerializer, String metadataSectionName) throws IOException {
        return null;
    }

    @Override
    public BufferedImage getPackImage() throws IOException {
        return null;
    }

    @Override
    public String getPackName() {
        return "Wardrobe";
    }
}

 

Posted

Return true is just for testing so i can print the files it is asking for to the log.

So do  i need to make an empty mcmate file for each image I want to load this as it asks for mcmeta files instead of files

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.