Jump to content

[1.12.2] Adding Resources at runtime


TheJays

Recommended Posts

Hi All,

Was hoping to get a bit of help here. Or to know if what i want to do is even possible (which i'm sure it must be).

 

is it at all possible to create mod resources at run-time; that is to say create the blockstate / models / textures at launch. 

 

These will all be based off templates. 

 

From what i gather (looking at ForgeDocs) i will need to create a new ResourceLocation? 

I'm a bit stuck in how I should go about doing this.

Thanks in advanced. 

 

- Jay

 

Link to comment
Share on other sites

What do you want to use these resources for?

Its completely possible to autogenerate your resources using gradle it in your development workspace, but you would never want to do it in production

Edited by Cadiboo
  • Thanks 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

I have been working on a mod for mod-pack developers. See here 

 

The idea is to supply the mod a payload (currently json, eventually zip). And the Block & Items will be added at runtime.

 

The blocks & Items added are just basic ones. mainly used in crafting recipes or decoration. 

I have the bulk of it working. its just adding the resources that I'm struggling with. 

 

Thanks for taking the time to reply ?

Edited by TheJays
Link to comment
Share on other sites

31 minutes ago, Cadiboo said:

Its completely possible to autogenerate your resources using gradle it in your development workspace, but you would never want to do it in production

Is this an implication that it is not possible to do while forge is loading? 

 

Thanks ?

Link to comment
Share on other sites

You’re able to go around the JSON system and directly baked models etc. but the entire point of the JSON system is to make everything accessible to and modifiable by end-users. I think that your users make the jsons themselves would be the best choice. 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Well see.. That was the route i was starting to take; the end user would just supply a resource pack.

 

However (unless I'm doing something else wrong) Upon loading the resource pack the lang entries work, but models & textures do not. 

 

I  cant see if Forge needs to at least initiate some resources before adding a resource pack.  

Link to comment
Share on other sites

Every mod is it’s own resource pack and data pack

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Sorry I should have been clearer. 

I was referring to adding a resourcepack.zip to the games ./resourcepacks folder. 

Doing this has resolved my issue. ( i mush have made an error with the pack format)

I just need to find out how to apply a pack by default now. 

Thanks ?

Link to comment
Share on other sites

I highly recommend not doing what you’re doing.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Why is that? 

I feel its a good idea for those who just want to add blocks and items. And don't want or know how to create an entire mod to add them.

 

The Mod is actually working great now, and doesn't add much to the launch time after the first launch (providing the user doesn't add/change files)

Link to comment
Share on other sites

I'm not against having blocks + items load from JSON, I think that its a great idea and I've been planning on doing something like it that would also allow the blocks/items to be added when the player joins a server. I'm against mods creating json files in production. These files defeat the purpose of the JSON system altogether and do not allow resource packs/data packs from users/modpack makers to change enhance the look of the blocks.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

I'm all about choice, and I completely agree that taking away control from the user is always a bad idea. but i have to stress that my mod wont do everything. and still allows the users to add their own textures etc.

Take a look at the mod its self - https://github.com/TheJaysH/BiarMod

 

It currently it has 2 options in terms of adding the blocks & Items.

1) supply it a zip with the json payload, and textures
2) just supply the json.

The first option will create the ResoricePack.zip from the textures the users supplied - and apply it.
The second will just add the blocks & Items, which leaves the Resources down to the user.

the json is as follows:
 

{
  "TABS": [
    {
      "langName" : "Example Tab",
      "unlocalizedName" : "tabExample",
      "icon" : ""
    }
  ],
  "BLOCKS": [
    {
      "langName" : "Example Block",
      "unlocalizedName": "exampleBlock",
      "registryName" : "example_block",
      "tabIndex" : 0,
      "hardness" : 1.5,
      "soundType" : "STONE",
      "material" : "ROCK"
    }
  ],
  "ITEMS": [
    {
      "langName" : "Example Item",
      "unlocalizedName": "exampleItem",
      "registryName" : "example_item",
      "tabIndex" : 0,
      "maxStackSize" : 16
    }
  ]

 

And this is the Zip file structure (should they choose to use it)

`biar.json` is the aforementioned json file
 

.minecraft/
    |
    |__ biarmod/
        |
        |__ biarmod.zip
            |
            |__biar.json
            |
            |__textures/
                |
                |__items/
                |   |
                |   |__example_item.png
                |
                |__blocks/
                    |
                    |__ example_block.png

 

 

The idea of option 1 is a one size fits all solution for mod pack developers who just want blocks & items with one texture who may not have the know-how to create a full ResourcePack.zip

And my vision down the line, is to have a comunity repo for "block-packs" or "item-packs" so users can download a set of blocks and items made by the community. 

 

The main push for this idea came from a modpack developer i know who wanted me to add a bunch of items to the pack - they were just used for crafting recipes and noting more. That gave me the idea to create this. 

Link to comment
Share on other sites

Looks pretty good.

I would change a couple things - the registry name & unlocalised name should be the same and it looks like you’re only providing English translations.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

currently im only working with English. 

 

Lang will soon be its own node with different entries like so:

 

{
  "lang": {
    "en_us" : "The Blah",
    "br_fr" : "Lé Bláh"
    ...
  }
}

 

 

As for the naming convention; i was considering  having only one name.. however i'd prefer to stick to the convention of snake_case for registry and camelCase for unlocalised

Link to comment
Share on other sites

15 hours ago, TheJays said:

however i'd prefer to stick to the convention of snake_case for registry and camelCase for unlocalised

Unlocalised names/translation keys were made the same as registry names in 1.13.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Er no, snake case. It’s done automatically - setUnlocalisedName/setTranslationKey no longer exists

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

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

    • im stuck in a problem whit BlockEntities i cannot solve so im trying to work around it but in the less complex way possible  i think is posible to store data to the minecraft world  in older versions people talk about  WordDataSave i dont find anything about it for 1.20.4  i find a tutorial for player capability in 1.19    here is an event      //########## ########## ########## ##########     @SubscribeEvent     public static void onAttachCapabilitiesPlayer(AttachCapabilitiesEvent<Entity> event) {         if(event.getObject() instanceof Player) {             if(!event.getObject().getCapability(PlayerThirstProvider.PLAYER_THIRST).isPresent()) {                 event.addCapability(new ResourceLocation(mercmod.MOD_ID, "properties"), new PlayerThirstProvider());             }         }     }  soo i made this      //########## ########## ########## ##########     @SubscribeEvent     public static void onAttachCapabilitiesLevel(AttachCapabilitiesEvent<Level> event) {     } i think i can do some witchcraft  here  but is many things don't understand  to start whit i dont get yet how to recall the saved data from a BlockEntity  the handler still in progress the plan is to make a Map to store nbt data using the block coordinates as index later store that map as a big nbt      ########## any way the question is if theres alredy a tutorial for 1.20.4 for this ?? or some alredy working code from someone else doing something similar ?           
    • I tried this, and found out that Oculus is the mod that is crashing the game. I have removed it, and it now works fine! Thanks!
    • Hi @DanielderErbauer, I arrived here as I have the "as it does not exist in Block{minecraft:air}" error in a modpack I am trying to start. It's a long-shot, I know, but as the post that led this to being solved is missing, can I ask if you may recall what it said? Thanks in advance
    • Hm yeah sorry, not seeing anything else that's sticking out, I'd need to debug myself probably. Do you have a github or bitbucket repo? I could poke around when I have time to see what the problem might be.
    • looking around for the capabilities thing i found a piece of code and find this piece of code  //########## ########## ########## ########## @SubscribeEvent public static void addCustomTrades(VillagerTradesEvent event) { if(event.getType() == VillagerProfession.FLETCHER) { System.out.println("\n\n### VillagerProfession.FLETCHER \n\n");//<----------- Int2ObjectMap<List<VillagerTrades.ItemListing>> trades = event.getTrades(); ItemStack stack = new ItemStack(ItemInit.ARROW_STEEL.get(), 16); int villagerLevel = 1; trades.get(villagerLevel).add((trader, rand) -> new MerchantOffer( new ItemStack(Items.EMERALD, 2), stack,1,3,0.02F)); } if(event.getType() == VillagerProfession.TOOLSMITH) { System.out.println("\n\n### VillagerProfession.TOOLSMITH \n\n");//<----------- Int2ObjectMap<List<VillagerTrades.ItemListing>> trades = event.getTrades(); ItemStack stack = new ItemStack(ItemInit.INGOT_STEEL.get(), 1); int villagerLevel = 1; trades.get(villagerLevel).add((trader, rand) -> new MerchantOffer( new ItemStack(Items.EMERALD, 2), stack,10,8,0.02F)); } } //########## ########## ########## ########## the event is aknoledge and execute when the maps load  ### VillagerProfession.FLETCHER  ### VillagerProfession.TOOLSMITH  //########## But is not working      is a random piece of code is not working  could it be than this code is old 1.18 and no valid anymore for 1.20.4 or the thing are this numbers  stack,10,8,0.02F));  i dont know what this numbers means    ########## the question is ¿how to add things to the villager traders    thanks for your attention               
  • Topics

×
×
  • Create New...

Important Information

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