Jump to content

Recommended Posts

Posted

Heyho folks,

even though I don't like to ask and prever to figure stuff out my self, I think this might be best for my mod and it's users :P

 

My first question is:

How can I load Models for Blocks and Items only if required. The following thread inspired me to do this: http://www.minecraftforge.net/forum/topic/55133-how-many-models-is-too-many/#comment-262773

I tried the stuff mentioned in there, but it sadly caused only crashes. And in addition I think this can be done a bunch easier, all I want is to load a model according to it's blockstate json as it's required.

I would appreciate if anybody could help me with this, as my Mod increases the RAM usage already by 1GB and that is of course to much D:

 

My second Question:

How could I port my current Storage Blocks to Capabilities, I got it working without the problem, I never understood really how it was working (made it 1 (or even more) year ago).

Now as I've understood at least NBT and Capabilities I want also try to move the storage to capabilities, but this time I would like to understand it earlier and not a few months later. 

I would be happy about maybe a link to a tutorial with a good Documentation or something similar where it's explained.

Even though my biggest trouble with it was always the the GUI and synchronization stuff.

Here is my current code if anybody is interested: 

https://github.com/DarkRoleplay/Dark-Roleplay-Medieval/blob/master/src/main/java/net/drpmedieval/common/gui/container/ContainerCrate.java
https://github.com/DarkRoleplay/Dark-Roleplay-Medieval/blob/master/src/main/java/net/drpmedieval/common/blocks/storage/Crate.java
https://github.com/DarkRoleplay/Dark-Roleplay-Medieval/blob/master/src/main/java/net/drpmedieval/common/blocks/tileentitys/TileEntityCrate.java

I would really appreciate any kind of help and thanks in advance.

Posted
1 hour ago, JTK222 said:

My first question is:

How can I load Models for Blocks and Items only if required. The following thread inspired me to do this: http://www.minecraftforge.net/forum/topic/55133-how-many-models-is-too-many/#comment-262773

I tried the stuff mentioned in there, but it sadly caused only crashes. And in addition I think this can be done a bunch easier, all I want is to load a model according to it's blockstate json as it's required.

I would appreciate if anybody could help me with this, as my Mod increases the RAM usage already by 1GB and that is of course to much D:

Post the code you tried and the crash(es) that resulted.

 

It can't really be done in a much easier way. The standard vanilla system bakes all models at start-up, so if you want to do something other than that, you need to alter the model loading and baking steps yourself. But that said, it really isn't as complicated as it might seem. For a simple system (i.e. one that would be simple enough to render using ordinary JSON blockstates), you can do it all within one object which implements ICustomModelLoader, IModel, and IBakedModel:

  • Register your object with ModelLoaderRegistry.registerLoader.
  • accepts should check for your block (probably by checking that the ResourceLocation path contains your block's registry name).
  • loadModel should load all the models you will need from ModelLoaderRegistry.getModel (or one of the variant methods like getModelOrLogError) by passing the ResourceLocations of the json files, and store those in fields to use later. Then it can return itself.
  • bake should do nothing except store the parameters as fields to use later, and return itself.
  • getQuads should do the actual baking as needed. From the IBlockState parameter, decide which model(s) are needed for the block. Use your previously-stored IModel fields, call bake (using your previously-stored parameters) and then getQuads and return the result.
    • You should also have a cache to store models which have already been created. In simple cases it can just be a Map<IBlockState, List<BakedQuad>>. The first step in your getQuads should be to check whether the state has a cached result (and return it if so), and the last step should be to add the result to the cache if it's not already present.

For simple cases, a lot of this can be done automatically and the same for every case (rather than needing to write it individually for every block). I have an abstract class which I use for all the stuff that's the same every time here. Then I only have to write loadModel and getQuads individually, which is not really any more complicated than writing a big messy blockstates file.

  • Like 1
Posted

Can users fake it by adding  virtual memory? Then unused models would be paged out.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

@Jay Avery Thank you! Your explanation helped me a lot ^^ And I got it working (somehow)

But one question is there a way to get the Model Path that would be used by default for a blockstate?

I am asking because I have to many different blocks and making the loadModel and getQuads methods would take to long.

In case no such method exists I will write something for that by myself.

Posted

What do you mean by the default model path for a blockstate? For a normally-rendered block you'd have to write a blockstates file telling it which model(s) to render depending on the state - in this case you're just doing the same thing in Java instead of json. Or did I misunderstand your question?

Posted

I would like to read the path from the json, as making it in java would cause to much work. I have currently 50 Blocks that require a delayed baking process.

And changing all that to java would take a bunch of time D:

Posted

Ok found a solution, only one problem left D:

 

I cant figure out in which format the Keys for the variants in ModelBlockDefinition are.
The variable is private and the only getter method for this returns it's values. Does anybody maybe know the format?
Or tell me how to figure it out by myself? (I guess that would be possible with reflections even though I don't have much experience with that)

Posted (edited)
15 hours ago, JTK222 said:

Ok found a solution, only one problem left D:

 

I cant figure out in which format the Keys for the variants in ModelBlockDefinition are.
The variable is private and the only getter method for this returns it's values. Does anybody maybe know the format?
Or tell me how to figure it out by myself? (I guess that would be possible with reflections even though I don't have much experience with that)

The keys look to be the variant names. To clarify, they are the strings you put before a variant to specify the conditions that should cause that variant to be used. Examples of variant names include "facing=up", "snowy=true", "facing=top, part=top", etc.

 

I figured this out by creating exit breakpoints on both of the constructors of ModelBlockDefinition. Then I launched in debug mode; when execution suspended due to one of the breakpoints, I hovered over mapVariants in the source and looked at the string representation of it in the lower popup. I'm using Eclipse, but IDEA should have something similar.

 

Edited by Leviathan143
Posted

@Leviathan143 Thank you! But I figured it already out yesterday night using reflexions.

 

@Jay Avery Ok, so it can find the models and everything there are no more errors. But the problem is that the Block is now invisible D:
I've been trying now the whole day to find the cause for this but everything seems right. Here is the source code: https://github.com/DarkRoleplay/Dark-Roleplay-Medieval/blob/1.11/src/main/java/net/dark_roleplay/medieval/client/model_baking/DelayedBakedModel.java

Posted

Are the appropriate methods being called (e.g. acceptsloadModel and bake during startup, getQuads when the block is placed or the state is changed)? If the methods are being called correctly, step through them (or use print statements) to see whether the flow is what you expect it to be (e.g. is a condition returning false when you expect it to be true, is something null at the wrong time). I can see you've already got some print and log statements in the code, could you show a log from starting up the game and placing one of your blocks?

Posted
7 minutes ago, JTK222 said:

Latest.log: https://pastebin.com/C3NFivLm
fml-client-latest.log: https://pastebin.com/TJ07CDet

I have removed a few of the debug messages becase there were over thousand lines for my block D:
 

As I said everything should work. The Models get loaded they just don't render. All I could imagine is to test if the Baked Models do contain any quads D:

That's what I'd try next! See what result contains just before it's returned from getQuads. It may be empty for some reason, and then you could backtrack and find out why it's not being filled.

Posted

Ok... it seems that the list never gets filled. There are also no quads during baking. I have no clue why that's not working.

I think I have to figure out how that stuff with breakpoints works to find a solution :P

Posted (edited)

As I suspected! I didn't use your blockstates file technique, so my bet is that it's somewhere in that process that models aren't being found or loaded correctly.

 

I just had another poke around. In the vanilla blockstates process, BlockStateLoader.load is called with a specific Gson as the second parameter, not a generic new parameterless constructor one. The method ModelBlockDefinition.parseFromReader calls it using its own Gson which seems to be set up to read blockstates, so I'd give that a shot! (Disclaimer, I have no direct experience of reading json resources, but this is what I would be doing if I wanted to work it out :P).

 

Edit: But yes, becoming comfortable with using breakpoints and the debugger is always a good idea!

Edited by Jay Avery
Posted

Well. I kind of fixed it.... all I had to do is to pass null as the side on getBakedQuads methods.

There are still a few bugs, but as I've been sitting on this for more than 5 days now I will make a break on that.

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

    • Reach Out To Rapid Digital: What sapp Info: +1 41 4 80 7 14 85 Email INFO: rap iddi gita lrecov ery @ exe cs. com Hello, my name is Jayson, and I’m 35 years old from the United Kingdom. My family and I recently endured an incredibly challenging experience that I wouldn’t wish on anyone. We became victims of a cryptocurrency investment fraud scheme that saw us lose a staggering $807,000 in USDT and Bitcoins. The fraudsters had created a convincing facade, and we were lured into investing, only to discover later that the platform was a complete scam. We were left devastated, not just financially, but emotionally, as we had trusted these people and believed in the legitimacy of the investment. After the initial shock wore off, we desperately searched for ways to recover the lost funds. It seemed like an impossible task, and we felt as though there was no hope. That’s when, by sheer luck, we stumbled across a post about Rapid Digital Recovery, a cryptocurrency and funds recovery organization with a proven track record in cybersecurity and fraud recovery. We decided to reach out to them, and from the first interaction, we were impressed with their professionalism and transparency. They explained the recovery process in detail and reassured us that they had the skills and expertise to track down the perpetrators and recover our funds. This gave us a renewed sense of hope, something we hadn’t felt in months. What truly stood out during our experience with Rapid Digital Recovery was their dedication to the recovery process. The team went above and beyond, using sophisticated tracking tools and cyber forensics to gather critical information. Within a matter of weeks, they had successfully located the funds and traced the scam back to the fraudsters responsible. They worked with the authorities to ensure the criminals were held accountable for their actions. To our relief, the team at Rapid Digital Recovery was able to recover every single penny we had lost. The funds were returned in full, and the sense of closure we felt was invaluable. We couldn’t have imagined such a positive outcome in the early stages of our recovery journey, and we are deeply grateful for the work they did. If you ever find yourself in a similar situation, I highly recommend contacting Rapid Digital Recovery. Their expertise, transparency, and dedication to their clients make them the go-to choice for anyone seeking to recover lost cryptocurrency or funds. They truly gave us back our financial future.  
    • This is my first time modding anything, so maybe just skill issue. I'm using Forge 54.0.12 and Temurin 21.0.5+11-LTS I wanted to create a custom keybind and to check whether it works I'd like to send a chat message. I tried using Minecraft.getInstance().player.sendSystemMessage(Component.literal("test")); but IntelliJ couldnt resolve sendSystemMessage(...). Since I saw people using it in earlier versions, I tried the same thing with 1.20.6(- 50.1.0), where it works fine, now I can't figure out if this is intentional and whether there are other options for sending chat messages. On that note, is there more documentation than https://docs.minecraftforge.net/en/1.21.x/? It seems very incomplete compared to something like the Oracle Java docs
    • Hi, i'm having this error and I wanna fix it. we try: -Reload drivers -Eliminate .minecraft -Eliminate Java -Restart launcher -Verify if minecraft is using gpu -Mods  in .minecraft is empty -Install the latest and recomended version of forge idk what i have to do, help me pls. the lastest log is: https://mclo.gs/WAMao8x  
    • Read the FAQ, Rule #2. (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/)  
    • The link to your log does not work, it says it is forbidden, Error, this is a private paste or is pending moderation.
  • Topics

×
×
  • Create New...

Important Information

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