Jump to content

In-Code Json Creation


ComputerCraze

Recommended Posts

In my mod that I am currently working on, I have a numerous amount of identical blocks which you can texture using a texture pack. However hard coding all of these would be painful at best so I was thinking of looping over a piece of code that would create all of the jsons. How would I go about it?

Link to comment
Share on other sites

Ok then, thanks. Sorry I've been a bit stubborn, but just to make sure:

 

Could you loop over something in one of your classes that will create all of the variants in the JSON file without typing all of that in? I'm not really looking for compact code, although that would be nice, but I'm looking for something that will create that code right there on startup.

Link to comment
Share on other sites

I don't really understand why a resource pack would come into play here. Let me explain thoroughly:

 

My mod is something that adds a set amount of blocks (50 as default) that are exactly identical to each other except the texture they use. When the game first boots up, these blocks are generated and added into the game using a for loop. What I want to do is create the model files for these blocks inside the code in that same for loop, so that the user can use a texture pack to retexture them as they please.

 

Basically I want to code something that goes into the for loop of my code and generates the JSON files at the same time as the blocks. All I need is the piece of code specifying where the file needs to be written to.

Link to comment
Share on other sites

Okay, hopefully this will help:

 for(i=0;i<50;i++){
String json = "blah blah mymod:blocks/dummyblock1 blah blah"; //text for the jsons, the file names for the textures, models and blocknames are incremented
//add code for adding json
} 

 

If you're asking why, as in why would I want this feature in my mod, it's supposed to be more of a utility mod for mapmakers.

 

If you're asking why, as in it would make no difference whether you put it in there or not, although I might be new to programming Minecraft mods, you do need a JSON and only a JSON to specify the attributes of how the block or item is rendered, correct? So if I want all of the attributes of my 50 blocks to be the same, except for the texture, I would either have to have tons of variants of that single block or add three separate JSON files for each block, correct? So therefore I would just need to loop over a line of code that adds the JSON files for every single block on bootup as an alternative to typing out the code for all 50 of the blocks.

 

If this doesn't make sense, I'm really sorry, but I'm trying to explain this the best I can. Hopefully you'll understand now.

Link to comment
Share on other sites

Do not create the json or dynamic blocks from code.

You can create the data externally once and then ship it out.

Creating models/textures/jsons with code is bad.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Do not create the json or dynamic blocks from code.

You can create the data externally once and then ship it out.

 

Question, as I have a 1.7.10 mod that creates blocks at runtime.

 

The reason is that it's actually generating replacement blocks for an uncertain number of blocks, some of which may exist (as they are mod blocks) or may not.  The reason being that I create BlockFalling types for them and give them several runtime generated textures (as in, I have a custom TextureAtlastSprite that takes the original texture and pre-renders an overlay onto it for several variants).

 

For vanilla, it's no problem to handle this once, externally, and ship it.  But due to there being other mods that also ship blocks that I'd want to replace (and due to the overlay nature of the texturing) I did this programmatically and it even handles variant resource packs.  I even supply an API hook for someone to write a plugin that would register additional types.

 

When I do get around to updating to 1.9, how should this be handled instead?  Pre-packaged data?

 

(My number of blocks is small, vanilla would be 3 with another 3-6 from mods, so it's not an undo amount of work to generate the data externally, I'm just trying to understand the advertised method).

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.

Link to comment
Share on other sites

Prepackage the data, and in all honesty what you've described doesnt need to do anything special or replace blocks, just listen for block change events and create falling entities.

'Dynamic' mods/block are a BAD IDEA. Do not do them.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

You misunderstand my use-case.  I'm replacing stone.  All of it.  Every single block the world as it is generated.

 

And I don't want to merely create falling entities, I am trying to provide a custom level of physics support.  Each block needs to determine whether or not it has support and not just from below.  Hence a custom block class is required.  Which includes 4 variants, each with their own rules for falling and unique texture.  BlockChangeEvent is insufficient.

 

However there are multiple kinds of stone.  Vanilla (gray) stone, basalt, granite, marble, diorite...

 

That's why I asked.  I'm interested in learning the better way.  The reason I went with code-generated textures was three fold:

(Note: this was done prior to 1.8 being supported by Forge, these were the reasons at the time)

1) providing pre-packaged textures does not allow for popular resource packs without explicit support (if a pack changes the texture of vanilla stone, my mod would be unable to utilize it).

2) using a custom model utilizing two render passes resulted in problems with rendering (falling entities and particles would only render the overlay texture, etc.)

3) manually combining an overlay with the base texture was time consuming (I did it with my ores and I regret it; 11 supported ores with 16 metadata texture variants: 176 hand-created textures with no resource pack support).

 

All you have said is "they are bad, don't do them" and I am trying to understand why.  I am trying to learn, so please be informative.

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.

Link to comment
Share on other sites

That is called layers, you can use normal textures layered on top of each other just fine. No need for custom generated code.

It would work JUST FINE with resource packs.

As for the physics shit, you can do the substitution system we have in the registry to take control. And leave it as is.

Generating context, be it blocks, items, textures, whatever is bad because it 1) breaks the data driven design that we at forge, and mojang are trying to do

2) It breaks a lot of functionality when it comes to external modification for resource pack makers, server owners, etc..

3) It makes life hell when trying to manage data and keep worlds/servers clean and synced up

4) It opens up a PLETHORA of potential security issues depending on the routes which you go.

5) It screws with the caching and performance of the re-written rendering pipeline causing major downgrades to end user's experiences.

 

There are A LOT of issues with doing dynamic content like that.

 

If you run into issues, then you can get them addressed. 1) Fixed with multilayer models 2) Fixed with some re-working of the entities nothing hard just needs to be brought it properly. 3) Should never need to be done.

 

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

3) Should never need to be done.

 

Technically speaking, 3 was fixed by:

 

That is called layers, you can use normal textures layered on top of each other just fine. No need for custom generated code.

 

That's why I said "these were the reasons behind the decision in 1.7.10."  1.7.10 did not have a concept of layers.  I understand that those issues have been addressed.  Same goes for the particles.

 

Thank you for explaining why dynamic blocks are a bad idea.  I was completely unaware of those problems because you do a terrible job of advertising "doing it this way leads to a better experience, not doing it breaks fucking everything."  Instead people try their best to figure out how to get the effect they want, get something half-working and you come along and go "don't do that."

 

As for the physics shit, you can do the substitution system we have in the registry to take control. And leave it as is.

 

Interestingly, said system doesn't actually work as of the most recent information I've seen.  Questionable as to whether or not it works in 1.7.10 perfectly as well.  That is: no one has been able to figure out how to get it to work, even hoped you (or anyone, really) would come along and post a working example, and it's lingered without a reply.

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.

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hallo all! I'm working on a custom mod pack for a few friends an I. However, whenever I launch it, it crashes and returns this error code. It appears to be crashing while trying to render some sprites from different mods, but I can't find a way to fix this.      The game crashed whilst stitching Error:      net.minecraft.client.renderer.texture.StitcherException:      Unable to fit: minecolonies:entity/citizen/nether/noblemale3_b - size: 128x64 -      Maybe try a lower resolution resourcepack? Here's the pastebin of the crash report: https://pastebin.com/17hgAPFS
    • when i join it looks normal until i look a mob or i have some thing in my hand and my screen starts turning different colors when i look around. i can see my inventory and the menu but not mobs or blocks in my hand I've tried to turn off the anti virus  uninstall and reinstalling the best driver  going back from version 20 to 8 and putting a ton of ram into minecraft. if i could get any help. thank you
    • Hi fellow minecrafter,   We've got exciting news from the Pacific Laboratory for Artificial Intelligence (PLAI) at UBC! We're merging the worlds of Minecraft and AI research, and you're invited to join through our platform, plaicraft.ai, to aid our data collection process. It's not just playing games; it's contributing to cutting-edge AI research.   BetterStructures and more!!: We want to make the server as fun as possible for everyone so we recently added a bunch of structural plugins that adds over a hundred of new structures and sites for you to explore and challenge. We are also working on PVP, bedwars and skyblock content, which will make the server even more fun!   Here’s how you can get involved! -Register on plaicraft.ai with your email(you can fake one, as long as you can receive email from it it's fine). -Complete a consent form. -Play Minecraft and contribute to science! (all you need is a Chrome browser and a steady internet, you'll be playing on VM)   Why You Should Participate? -Support AI Research: Your gameplay directly contributes to important AI advancements.  -Free Minecraft Access: Enjoy the game without any cost. -We have shaders and a bunch of cool mods loaded on our instances  -Great Community: Our server currently has a fantastic community, with many awesome players you can meet.   Elephant in the room: Now I want to address some obvious concerns, I sure did a good job making us sound like a scam by the above content. I know that the "free Minecraft" thing has always been taboo in the Minecraft community. So how can I prove to you that this is not a scam? - The easiest way and most official way is that we are approved by the University of British Columbia ethics board, our BREB number is H23-02389. You can verify this case number yourself. - The harder way is that I'll explain the technical details of this project and why we choose to provide free Minecraft. So the goal of this project is very similar to the paper MineDojo or MineRL, we want to collect a multi-modal dataset that consists of video, audio, keyboard and mouse movement. Minecraft has been a very important simulation environment for the ML community and there are tons of papers related to it. Now we obviously don't have enough money like those big tech companies who can just pay people to play, so we have to turn to the Minecraft community. To record all the data mentioned, there needs to be a lot of setup and coding, and it's definitely impossible for us to ask people to run these recording programs on their personal computers. So we carefully configured the AWS EC2 instance to run Minecraft alongside the programs. And that's where and why we also provide you with free Minecraft licenses, of course, we are not giving the account to you, just allowing you to be able to play Minecraft on these instances. You might ask, "Why can't I log in with my account on the instances?", that's because first login with your personal Minecraft account is another privacy risk; second not all our target audiences have an account; and lastly we restricted a lot on what you can do on the instance, basically all you can do is play Minecraft and that's all the data we want, allowing you to log in will make things complicated to control.   For more information on the project and the team, visit Dr. Frank Wood’s website or follow @frankdonaldwood on Twitter. You can also learn more about PLAI lab research on our website (just search ubc plai). Join us in transforming your gaming experience into a meaningful contribution to AI research. Let’s push the boundaries of what gaming can achieve together! Happy plaiing!   Best,  The PLAI Team
    • The mod has improved a lot from yesterday just 1 last issue  Here's the crash report- https://pastebin.com/k2A1BAKn   Please help, Thanks.
    • Take Your Gaming Experience to the Next Level with These Essential Tools   If you're a Minecraft enthusiast, you've likely experienced the need to customize your world and server to make it more exciting and challenging. Fortunately, there's a perfect solution for you: https://menzatyx.xyz, the website that offers a wide selection of free and pre-configured Minecraft plugins. At https://menzatyx.xyz, you'll find a diverse range of plugins that will allow you to take your gaming experience to the next level. From server management tools to mods that add new functionalities, each of these plugins has been carefully selected and configured, so you can enjoy a more personalized and thrilling Minecraft experience. One of the primary benefits of using these pre-configured plugins is the ease of implementation. You no longer have to spend hours configuring and adjusting each individual plugin. Simply download the package that best suits your needs, and you're good to go! You'll be able to enjoy all the features and improvements without investing too much time and effort. From plugins that enhance the security of your server to mods that add new game modes, the variety offered by https://menzatyx.xyz is impressive. Moreover, as these are free plugins, you can access these tools without spending a single penny. It's the perfect opportunity to take your Minecraft experience to the next level without affecting your wallet! Whether you're a casual player or an experienced server administrator, at https://menzatyx.xyz you'll find the Minecraft plugins you need to personalize and enhance your game. Visit the website now and discover how you can transform your Minecraft world into something unique and thrilling!
  • Topics

×
×
  • Create New...

Important Information

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