Jump to content

[SOLVED]Resourcepack workin in Eclipse but not in minecraft[1.8]


ItsAMysteriousYT

Recommended Posts

I created a resourcepack but it won't load when i compiled my mod and try it in minecraft it wouldn't load.

 

This is my resourcefile:

 

package itsamysterious.mods.reallifemod;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import com.google.common.collect.ImmutableSet;

import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.DefaultResourcePack;
import net.minecraft.client.resources.FolderResourcePack;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraft.client.resources.IResourcePack;
import net.minecraft.client.resources.data.IMetadataSection;
import net.minecraft.client.resources.data.IMetadataSerializer;
import net.minecraft.util.ResourceLocation;

public class RLMPack extends FolderResourcePack implements IResourcePack,IResourceManagerReloadListener{
    public static final Set defaultResourceDomains = ImmutableSet.of("RLM");
    public static List<String> filenames=new ArrayList<String>();
    
public RLMPack() {
	super(new File(RealLifeMod.MinecraftDirectory+"/RLM"));
}

@Override
public InputStream getInputStream(ResourceLocation p_110590_1_) throws IOException {
	return getResourceStream(p_110590_1_);
}

@Override
public boolean resourceExists(ResourceLocation p_110589_1_) {
	return this.getResourceStream(p_110589_1_) != null;
}

    private InputStream getResourceStream(ResourceLocation p_110605_1_)
    {
    	try {
		return new FileInputStream(RealLifeMod.MinecraftDirectory+"/RLM/"+p_110605_1_.getResourcePath());
	} catch (FileNotFoundException e) {
		e.printStackTrace();
	}
	return null;
    
    }

@Override
public Set getResourceDomains() {
	return defaultResourceDomains;
}

@Override
public IMetadataSection getPackMetadata(IMetadataSerializer p_135058_1_, String p_135058_2_) throws IOException {
	return null;
}

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

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

@Override
public void onResourceManagerReload(IResourceManager resourceManager) {
}
}

Link to comment
Share on other sites

1. Forgot to remove it.

2. I do not know whic method to override so the methods automaticly work right

3.Like this:

 

 

@EventHandler

public void preInit(FMLPreInitializationEvent event) {

 

MinecraftDirectory = event.getSourceFile().getPath().toString();

if (MinecraftDirectory.contains("bin")) {

MinecraftDirectory = MinecraftDirectory.replace("bin", "run");

} else if (MinecraftDirectory.contains(".minecraft")) {

}

 

}

 

 

4.With this method in my clientproxy from preinit:

@Override
public void loadCoreModules() {

	List<IResourcePack> defaultResourcePacks = ObfuscationReflectionHelper.getPrivateValue(Minecraft.class,
			Minecraft.getMinecraft(), "defaultResourcePacks", "field_110449_ao");

	defaultResourcePacks.add(new RLMPack());
	File screenshots = new File(Minecraft.getMinecraft().mcDataDir, "screenshots");
	for (File f : screenshots.listFiles()) {
		Screenshotspack.filenames.add(f.getName());
	}
	defaultResourcePacks.add(new Screenshotspack());
	Minecraft.getMinecraft().refreshResources();
}

Link to comment
Share on other sites

Is it possible to load them dynamicly? Without reloading all resources? And i came out with that resourceDir detection because when i tried starting the server with it, it crashed because it tried to acces the client. First i tried to make the method in a clientcheck (if(event.getSide()==Side.CLIENT)) but it crashed too.

Link to comment
Share on other sites

Any Resourcepack related stuff must be client-proxy.

 

Ah - OK. That explaines many things. Now, i don't wanna make a new thread for that problem - so is anything wrong with the method? Somehow the Gui shows up even if i have set the name/surname before.

 

@SubscribeEvent
public void updateRealLifeProps(PlayerTickEvent event) {
	tickrun++;
	if (tickrun>3&&RLMPlayerProps.get(event.player) != null) {
		RLMPlayerProps.get(event.player).circleOfLife();
		if (RLMPlayerProps.get(event.player).getName() == null) {
			BlockPos p = event.player.getPosition();
			event.player.openGui(RealLifeMod.instance, GuiModInit.ID, event.player.worldObj, 0, 0, 0);
		} else {
			if (RLMPlayerProps.get(event.player).getName().isEmpty()) {
				BlockPos p = event.player.getPosition();
				event.player.openGui(RealLifeMod.instance, GuiModInit.ID, event.player.worldObj, p.getX(), p.getY(),
						p.getZ());
			}
		}
	}else
	{
		RLMPlayerProps.register(event.player);
	}

}

@SubscribeEvent
public void onEntityConstructing(EntityConstructing event) {
	if (event.entity instanceof EntityPlayer) {
		if (RLMPlayerProps.get((EntityPlayer) event.entity) == null) {
			RLMPlayerProps.register((EntityPlayer) event.entity);
		}
	}
}

 

PS - i tried the GuiOpen stuff in PlayerLoggedInEvent, but it did not open the gui.

Link to comment
Share on other sites

Anf the resourcepack still does not work outside of the modding workpsace :( These are the methods in which i load additional items/blocks.

private void loadVehicles() {
	System.out.println("loaded vehicles");
	if (vehiclefile.exists()) {
		if (vehiclefile.isDirectory()) {
			for (File vehicle : vehiclefile.listFiles()) {
				if (vehicle.getName().endsWith(".rlm")) {
					Vehicles.addVehicle(new VehicleFile(vehicle));
				}
			}
		}
	} else {
		vehiclefile.mkdirs();
	}
}

 

Thats why i use that weird MCDirectory stuff, cuz i have too define the directory in which the VehicleFiles are located. But when in minecraft, they do not work.

Link to comment
Share on other sites

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.