Jump to content

[1.8] [CLOSED] Get the actual location of the mod's 'assets' folder.


mGamer426

Recommended Posts

Hello!

I'm kind of new in modding and I would like to know one thing. I'm making a mod for 1.8 and I want to make model creating (you know, writing all those .json files) a bit easier.

I want to make a model maker! I've already made a little preview of it, but there's one thing missing. Get the location of the assets folder, and inside of it, the models/item or models/block folder.

I'm working in the IntellijIDEA IDE and it is possible to do this by creating a separate module in the whole modding project, and set up a custom application launch, where it launches the model maker module before Minecraft runs. Because it's a separate module, it can easily reference the directories in the source folder. But after a good bit of time it is kind of annoying that every time I launch Minecraft the model maker runs, and it's not even needed. I think it is possible to implement all of this into the mod and get the assets folder location while Minecraft is running. Any ideas how to do this?

Link to comment
Share on other sites

Why wouldn't you output to a different folder? Create an output location that you want and access it with an IResourcePack. This will also allow you to 'hotswap' (guessing you'll have to force the ResourceManagers to reload unless you're feeling rather fancy) models in an out with something like a whitelist for the file contents (contained models).

I don't really see the merits of a secondary application launch, either wrap it up inside of a gui in minecraft or create a standalone, as you've mentioned dual launching applications is a PITA

I think its my java of the variables.

Link to comment
Share on other sites

Do you mean you want to read from the existing models, or do you want to write your new model to that location? Also, are you talking about models for entities, or for blocks and items?

 

In 1.8, entity models are defined in Java code (i.e. the classes that extend ModelBase) but blocks are defined in the blockstates JSON files. So I think you'd have to use different approaches for each case.

 

For the entity models, since the model is active code instead of a resource file I think it would be difficult to "parse" directly. Basically your parser would have  to sort through the class file and figure out what it is doing. So for entities I suggest you simply make your own type of resource and copy the information over but in a format that is easier for you to use.

 

For the blockstate and item models, they are already JSON so are fairly easy to parse. However, the vanilla models are going to be in Minecraft JAR, not your mod JAR. There is probably a way to access the vanilla models from your code, but again it might be easier to simply copy all of them over into your mod (you's simply have to cut and paste all the blockstate related asset packages into your project.

 

Reading existing ones is fairly easy, you just can either use standard Java methods for navigating the JAR, or you can use Minecraft helper methods for accessing resources. Parsing JSON files can be done with the GSON library, or you can make your own text-based format with your own parser.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

  • 2 weeks later...

Sorry for the VERRRRY late response, and I'd like to thank both of you for the information.

After re-thinking the whole thing again and I think I'll go with the one that jabelar said. Now, I figured out that making this is VERRRRY complicated or it is not even possible. I don't really want to make that whole IResource thingy, but it is a good information... thanks RANKSHANK!

 

And, again thanks for both of you it really helped finding the solution: Copy + paste!  ;D

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Backup the world and make a test without this mod
    • You allocated too much RAM to the game, so the OS, drivers and other things are fighting for resources. Close as many things as you can when playing, allocate 3GB or 3.5GB max, do not set a min. In task manager go to the startup tab and disable things you don’t need to start and have always running when you turn on your PC, but ignore the AMD ones in the list (they’re needed). Use Java 21 instead of Java 17. Consider removing Alex’s Mobs. Update your Radeon drivers (see the FAQ). Consider buying more physical RAM for your PC
    • Try deliting feur builder  It caused this issue in my modpack
    • I am not using hardcoded recipes, I'm using Vanilla's already existing code for leather armor dying. (via extending and implementing DyeableArmorItem / DyeableLeatherItem respectively) I have actually figured out that it's something to do with registering item colors to the ItemColors instance, but I'm trying to figure out where exactly in my mod's code I would be placing a call to the required event handler. Unfortunately the tutorial is criminally undescriptive. The most I've found is that it has to be done during client initialization. I'm currently trying to do the necessary setup via hijacking the item registry since trying to modify the item classes directly (via using SubscribeEvent in the item's constructor didn't work. Class so far: // mrrp mrow - mcmod item painter v1.0 - catzrule ch package catzadvitems.init; import net.minecraft.client.color.item.ItemColors; import net.minecraft.world.item.Item; import net.minecraftforge.registries.ObjectHolder; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.client.event.ColorHandlerEvent; import catzadvitems.item.DyeableWoolArmorItem; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public class Painter { @ObjectHolder("cai:dyeable_wool_chestplate") public static final Item W_CHEST = null; @ObjectHolder("cai:dyeable_wool_leggings") public static final Item W_LEGS = null; @ObjectHolder("cai:dyeable_wool_boots") public static final Item W_SOCKS = null; public Painter() { // left blank, idk if forge throws a fit if constructors are missing, not taking the chance of it happening. } @SubscribeEvent public static void init(FMLClientSetupEvent event) { new Painter(); } @Mod.EventBusSubscriber private static class ForgeBusEvents { @SubscribeEvent public static void registerItemColors(ColorHandlerEvent.Item event) { ItemColors col = event.getItemColors(); col.register(DyeableUnderArmorItem::getItemDyedColor, W_CHEST, W_LEGS, W_SOCKS); //placeholder for other dye-able items here later.. } } } (for those wondering, i couldn't think of a creative wool helmet name)
    • nvm found out it was because i had create h and not f
  • Topics

×
×
  • Create New...

Important Information

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