Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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) {
}
}

  • Author

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();
}

  • Author

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.

  • Author

I have the method in the clientproxy and call it under a client check. Is that enough or do i have to call it in the constructor of the clientproxy?

  • Author

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.

  • Author

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.