Jump to content

Loading Assets Dynamically


Belial

Recommended Posts

I was trying to achieve creating blocks with data from a server, but I hit a wall. What I'm trying to accomplish is creating easily manageable decorative items without editing whole java code. I'm parsing a JSON from a server and creating the blocks by using it, at the moment. But, this isn't reasonable by just itself because the assets are not included at the moment. So, I also have to do the same thing for the assets to make it independent of editing the jar, but classes about resources can only access internal resource folder if I'm not mistaken. I don't know it is possible or not, but I might try to override some of them with my own classes&methods. Still, before blindly doing it, I wanted to ask about it. Do you have any suggestions about how I can do this? Or any ideas about problems it might create?

Edited by Belial
Typo&Grammar
Link to comment
Share on other sites

2 minutes ago, Belial said:

and creating the blocks

You can not create Blocks post initialization. If you are doing this. Stop. However if you have created a Block and are using a CustomStateMapper to map dynamic BlockStates. 

 

6 minutes ago, Belial said:

Do you have any suggestions about how I can do this? Or any ideas about problems it might create?

I think you could create a custom IResourcePack implementation and you will have to get the data from the server and (maybe)cause a resource manager reload to load the new textures and models.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

6 minutes ago, Animefan8888 said:

You can not create Blocks post initialization. If you are doing this. Stop. However if you have created a Block and are using a CustomStateMapper to map dynamic BlockStates. 

 

I think you could create a custom IResourcePack implementation and you will have to get the data from the server and (maybe)cause a resource manager reload to load the new textures and models.

4

I'm getting the JSON at pre-init and creating them at registration event before registry. Currently, it needs to restart to get updated, but, that is not a problem. My intention isn't changing them after post-init. So, it's not a problem I suppose. :D

But, still, I have to get them before the registry happens, at pre-init.

Edited by Belial
Link to comment
Share on other sites

2 minutes ago, Belial said:

I'm getting the JSON at pre-init and creating them at registration event before registry. Currently, it needs to restart to get updated, but, that is not a problem. My intention isn't changing them after post-init. So, it's not a problem I suppose. :D

You shouldn't be doing it this way. Blocks should not be dynamically registered.

You should register a single block that has a custom IProperty and an IStateMapper that maps the blockstate to the proper model. And these would be gotten from the parsed JSON data(the value for the state and the model path). These models and the textures would have to be parsed into the custom IResourcePack, somehow. Though the network cost might be huge on the first connection so this should be up based and have some sort of signature.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

7 minutes ago, Animefan8888 said:

You shouldn't be doing it this way. Blocks should not be dynamically registered.

 

I said decorative, I know, but I plan to change hardness etc. for some of them. So, I suppose blockstate isn't enough. What could go wrong with creating them dynamically? I had thought of it and only world corruption & change of the block ID came into my mind. (don't know they are possible, just thoughts)

 

 

7 minutes ago, Animefan8888 said:

Though the network cost might be huge on the first connection so this should be up based and have some sort of signature.

I will use some kind of version checking and resource checking to avoid expensive network usage.

Edited by Belial
Link to comment
Share on other sites

2 minutes ago, Belial said:

What could go wrong with creating them dynamically?

The whole system is built with the idea that every block will be registered every time consistently. It is just a bad idea, diesieben07 would be able to explain this better than I could.

3 minutes ago, Belial said:

I said decorative, I know, but I plan to change hardness etc. 

Override the method in the block class that have a IBlockState parameter.

  • Like 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

2 minutes ago, Animefan8888 said:

The whole system is built with the idea that every block will be registered every time consistently. It is just a bad idea, diesieben07 would be able to explain this better than I could.

Override the method in the block class that have a IBlockState parameter.

Yeah I know, it's not proper but suited my purpose. Still, doing the most proper one is preferable. I didn't know I can do it without registering blocks each time. Thank you.

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



×
×
  • Create New...

Important Information

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