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

Is this possible? I've created a TextResource class as detailed below:

 

package com.nosrick.masterofmagic.text;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import net.minecraft.client.resources.IResource;
import net.minecraft.client.resources.data.IMetadataSection;
import net.minecraft.util.ResourceLocation;

public class TextResource implements IResource 
{
protected ResourceLocation m_ResourceLocation;

public TextResource(String location)
{
	m_ResourceLocation = new ResourceLocation(location);
}

@Override
public ResourceLocation getResourceLocation() 
{
	return m_ResourceLocation;
}

@Override
public InputStream getInputStream()
{
	try 
	{
		return new FileInputStream(m_ResourceLocation.getResourceDomain() + "/" + m_ResourceLocation.getResourcePath());
	} 
	catch (FileNotFoundException e) 
	{
		// TODO Auto-generated catch block
		e.printStackTrace();
		return null;
	}
}

@Override
public boolean hasMetadata() 
{
	return false;
}

@Override
public <T extends IMetadataSection> T getMetadata(String p_110526_1_) 
{
	return null;
}

@Override
public String getResourcePackName() 
{
	return null;
}

}

 

 

But I have no idea where it's looking for these files, or if it's doing it correctly. Every time I run it, it throws the exception saying the file can't be found, even though the path appears to be correct.

 

Does anyone know anything about this, or is it better to load a file from outside of the jar?

InputStream is = Schematic.class.getResourceAsStream("/assets/extendedvillages/schematics/"+name+".schematic");

This is my code to access everything inside assets/extendedvillages/schematics/VARIABLENAME.schematic

You can replace the Schematic.class with TextResource.class if im not mistaken

  • Author

I know this is more of a Java problem now (and I am truly thankful for the help), but it always seems to fail to find the asset, even though I appear to be pointing it to the correct path.

 

InputStream stream = TextResource.class.getResourceAsStream("assets/" + MoMMod.MODID + "/text/life_magic.txt");

 

Now, I went into the .jar and looked for this file; it's there, so I don't know why it isn't finding it.

Guest
This topic is now closed to further replies.

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.