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

Not sure if this is possible but what I'd like is to generate Strings in a json format within code, and then register that as the model, so instead of having an actual file, it's just done on launch. These will be cached if the user wishes to save them, it basically saves the effort of having to create model files for every block/item. If this is possible could I get some insight on how to do so?

  • Author

Thanks, I think I got most of it done however one issue I'm having is getting the field.

 

@SuppressWarnings({"rawtypes", "unchecked"}) public synchronized static void assembleResources() {
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
	try {
		Field field = Minecraft.getMinecraft().getClass().getDeclaredField("defaultResourcePacks");
		field.setAccessible(true);
		Field modField = Field.class.getDeclaredField("modifiers");
		modField.setAccessible(true);
		modField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
		List rPacks = (List) field.get(Lists.newArrayList());
		rPacks.add(new EasyModResourcePack());
		field.set(field, rPacks);
	} catch (Exception e) {
		LogHelper.warn("An exception was thrown creating resource pack");
		LogHelper.warn(e.getMessage() != null ? e.getMessage() : "");
		e.printStackTrace();
	}
}
}

 

The line "List rPacks = (List) field.get(Lists.newArrayList());" Throws an error, Can not set java.util.List field net.minecraft.client.Minecraft.defaultResourcePacks to java.util.ArrayList

 

If someone knows how to fix this issue, that would really help. I'm no reflection expert, I wouldn't even consider myself at the level of beginner yet, so I'm probably doing something wrong.

  • Author

private final DefaultResourcePack mcDefaultResourcePack;

It's not a static field but it's final, and I get illegal access exception's without it.

 

The only things I've changed are

Field field = Minecraft.class.getDeclaredField("defaultResourcePacks");

List rPacks = (List) field.get(Minecraft.getMinecraft());

 

Now if I don't set the field how am I supposed to add to the default resource packs? Does calling rPacks.add do it?

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.