Jump to content

Recommended Posts

Posted (edited)

Is there a way to load files in the ./assets/ and ./data/ directory of any mod, including your own?

I'd imagine it to work with resource locations, but skimming over the usages of net.minecraft.util.ResourceLocation and net.minecraftforge.registries.ForgeRegistryEntry#getRegistryName didn't help me much.

 

If you're wondering why I want to load files: I'm working on a Pokemon-style mod, except it uses mobs from Minecraft and other mods, and I want other mods to be able to add thier own mobs (or "Fighters" as I call them) to my mod that you can then capture and fight with. And since adding such a Fighter would also mean adding moves it can learn, i want other modders to be able to write it in a .json file where they just list the registry names of the moves and my mod picks out the correct moves, so the actual code of the mod stays rather short and isn't littered with chained methods of adding moves.

 

Edit: I want to load the asset data during mod setup.

Edited by Keheck
Posted

Yes. That's what a ResourceLocation represents, a domain ("mod ID") and location. You ask for new ResourceLocation("NotMyMod","SomeAsset") and you'll get it.

 

Of course, if you're writing a json loading system for a type of asset, I recommend looking into the JsonReloadListener system. As an example,

https://github.com/MinecraftForge/MinecraftForge/blob/d4b6540746ce5676a9a2efe24b87debb3f79dfe7/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java#L38

Note that you need to register it with the MinecraftServer instance, which will require some reflection.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 5/10/2020 at 4:40 PM, Draco18s said:

Of course, if you're writing a json loading system for a type of asset, I recommend looking into the JsonReloadListener system. As an example,

https://github.com/MinecraftForge/MinecraftForge/blob/d4b6540746ce5676a9a2efe24b87debb3f79dfe7/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java#L38

Note that you need to register it with the MinecraftServer instance, which will require some reflection.

Expand  

I'm afraid this won't work for me... I want the data for the Fighter during mod setup, specifically during the registraion of the Fighters.

Here's how I invisioned it (this will all happen inside a registry handler for the Fighter Registry with lowest event priority, so it is (likely) the last one to get called):

 

  • Get a list of all the registered fighters.
  • Loop the following for every entry (and account for errors):
    • Get the registry name of the entry
    • Is the domain empty or does it equal "minecraft"?
      • Yes: Look into "./data/mobfighters/"  ("mobfighters" is the modid of my mod)
      • No: Look into "./data/<domain>"/
    • Search in the data directory for "./fighter/<path>"
    • Read the .json
    • Pass the read data onto the entry.

 

Does the way I want to do it even make sense, or is it safe to do that?

If you want to look at my code, I have a repo here.

(The important classes are io.github.keheck.mobfighters.registry.entries.FighterEntry and io.github.keheck.mobfighters.registry.Registry)

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Title: Understanding ASM, Coremods, and Why Some Mods Break on Refactoring Post text: Hey everyone! I’ve been learning Minecraft modding for a while and ran into a question that I can’t figure out on my own. Hoping someone more experienced can help or give me some guidance. Here’s my issue: With most “normal” Forge mods — for example, those that just add new blocks or items — it’s fairly straightforward to refactor them. I can rename packages, move classes around, or reorganize the project without too much trouble. But as soon as I look at more complex cheat-style mods that use ASM, coremods, or deep game hooks — like Xray or Entity Xray — even a simple refactor breaks everything. For instance, just renaming classes or changing the package structure is enough to stop these kinds of mods from working at all. My question is: What’s fundamentally different about the architecture of these kinds of mods that makes them so fragile when refactoring? Is it the way they use bytecode manipulation, classloading tricks, or mappings that ties them to their original structure? And how can I better understand these kinds of mods so that I can reorganize or refactor them without breaking the core functionality? I’d really appreciate any insights into ASM, coremods, or classloaders — or any guides/resources that could help me understand this better. If you’ve successfully refactored or dissected mods like Xray or Entity Xray before, I’d love to hear your thoughts! Thanks in advance for any advice — I’m looking to deepen my understanding of these kinds of mods. ✌️
    • I can't figure out if you're looking for help trying to steal someone elses work, or cheat at the game....
    • Title: Why Is It So Hard to Rename and Restructure Mods Like Xray or AntiXray? 🤔 Post text: Hey everyone! I’ve been digging into Minecraft modding for a while and have one big question that I can’t figure out on my own. Maybe someone with more experience could help or give me some advice. Here’s the issue: When I take a “normal” Minecraft mod — for example, one that just adds some blocks or new items — I can easily change its structure, package names, or even rebrand it entirely. It’s straightforward. But as soon as I try this with cheat-type mods like XrayMod or AntiXray, everything falls apart. Even if I just rename the classes, refactor the packages, or hide its identity somehow, the mod either breaks or stops working properly. XrayMod in particular is proving to be a nightmare to modify without losing its core function. So my question is — why is this so much harder with cheat mods like Xray? Is there something fundamentally different about how they’re coded, loaded, or protected that prevents simple renaming or restructuring? And if so, how can I actually learn to understand someone else’s cheat mod enough to safely refactor it without breaking the core features? I’ve already been spending over two months trying to figure this out and haven’t gotten anywhere. It feels like there must be some trick or knowledge I’m missing. Would really appreciate any thoughts, tips, or references — maybe there are guides or techniques for understanding cheat-mod internals? Or if you’ve successfully “disguised” a cheat mod like Xray before, I’d love to hear how you did it. Thanks in advance for any help or discussion. ✌️
    • just started making cinamatic contect check it out on my channel or check out my facebook page    Humbug City Minecraft Youtube https://www.youtube.com/watch?v=v2N6OveKwno https://www.facebook.com/profile.php?id=61575866982337  
    • Where did you get the schematic? Source/Link? And do use an own modpack or a pre-configured from curseforge? If yes, which one On a later time, I can make some tests on my own - but I need the schematic and the modpack name
  • Topics

×
×
  • Create New...

Important Information

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