Posted April 4, 20205 yr Hi, I'm looking to save ArrayLists, in the WorldSavedData class. I already have the following: 0 Advanced issue found ▲ Spoiler package net.kidkoder.allergies.data; import net.minecraft.nbt.CompoundNBT; import net.minecraft.world.storage.WorldSavedData; public class DataPlayerAllergies extends WorldSavedData { private boolean dirty; public DataPlayerAllergies() { super("playerDataAllergies"); } @Override public void read(CompoundNBT nbt) { } @Override public CompoundNBT write(CompoundNBT compound) { return null; } @Override public boolean isDirty() { return dirty; } } How do I save an ArrayList in to the class in a diffrent class, then retrive it when I need it? Thanks in advance, Kid Koder Website: http://kidkoder.net GitHub: https://github.com/Uncodeable864
April 4, 20205 yr 1 hour ago, KidKoderMod033109 said: How do I save an ArrayList in to the class in a diffrent class, then retrive it when I need it? Wait what? The ArrayList should be in your WorldSavedData class. Use a ListNBT to store a "list" of Items. 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.
April 4, 20205 yr Author I have a class that has the logic to decide what does into the ArrayList, and I want to save that ArrayList to data in the world, Then, when the World is loaded again, to read the data and use it. I am using WorldSavedData because it seemed like it would work. If you know any other way to do this, please tell me(Please avoid from file stuff such as creating a file for each world). Website: http://kidkoder.net GitHub: https://github.com/Uncodeable864
April 4, 20205 yr Just do what @Animefan8888 said. Save the data in the list using a ListNBT with the write method, then read it back using the read method. Don't forget to call markDirty when the data changes in order to have it actually save. I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.
April 4, 20205 yr 8 minutes ago, KidKoderMod033109 said: I have a class that has the logic to decide what does into the ArrayList, and I want to save that ArrayList to data in the world Put the logic into the WorldSavedData class? 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.
April 4, 20205 yr Author The whole mod is based upon the logic and requires the logic to be in that class. But, I have thought to create a "config" file for each world, would that work/how would I do that? Website: http://kidkoder.net GitHub: https://github.com/Uncodeable864
April 4, 20205 yr 10 minutes ago, KidKoderMod033109 said: The whole mod is based upon the logic and requires the logic to be in that class. Why? It's your code you can manipulate it any way you want. 10 minutes ago, KidKoderMod033109 said: But, I have thought to create a "config" file for each world, would that work/how would I do that? You can't do that using the forge config system. 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.
April 4, 20205 yr Just now, Animefan8888 said: You can't do that using the forge config system. Can't you? I believe the SERVER config type will do exactly what is desired, unless the javadocs are misleading me. I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.
April 4, 20205 yr Author 5 minutes ago, Animefan8888 said: You can't do that using the forge config system. I mean't create a new "config file" in the world folder, then can be read back. imacatlol said: Can't you? I believe the SERVER config type will do exactly what is desired, unless the javadocs are misleading me. @imacatlololHow do I do that? Edited April 4, 20205 yr by KidKoderMod033109 Website: http://kidkoder.net GitHub: https://github.com/Uncodeable864
April 4, 20205 yr @Cadiboo has a great example mod that includes examples of how to make configs here. I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.
April 4, 20205 yr 8 minutes ago, imacatlolol said: Can't you? I believe the SERVER config type will do exactly what is desired, unless the javadocs are misleading me. Honestly it might, but I'm not sure that's something worth testing. Maybe the OP can enlighten us when/if they try it. 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.
April 4, 20205 yr Just now, Animefan8888 said: Honestly it might, but I'm not sure that's something worth testing. Maybe the OP can enlighten us when/if they try it. Good point, it might be easier to go with the WorldSavedData, especially since that was what OP wanted in the first place. It's at least still valuable to learn about Forge's config system in general I guess. I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.
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.