Posted February 19, 201510 yr 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?
February 20, 201510 yr 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.
February 20, 201510 yr 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.