I'm using the @Config type configuration file for my mod. However I need to know how to add a field that is a list of strings, or if possible a list of pairs of strings and doubles. It appears to only want to read primitive types so how should I go about adding this type of configuration field?
To be clear, it will be a collection of strings, each of those strings has a double. This can be done directly or if there is a way to combine them within the configuration file, but I would probably need some code for that approach.
It sounds like you want a Map<String, Double> field, which will be converted to a category with a property for each key. If you want the order to be maintained, you should be able to use a LinkedHashMap.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
It sounds like you want a Map<String, Double> field, which will be converted to a category with a property for each key. If you want the order to be maintained, you should be able to use a LinkedHashMap.
It says I can't instantiate Map, even when I used the scala import. Which import should I use? And then do I just include it the same way that it works for integers? I don't know what Object types the GUI has support for.
It says I can't instantiate Map, even when I used the scala import. Which import should I use? And then do I just include it the same way that it works for integers? I don't know what Object types the GUI has support for.
Map is an interface, you can't instantiate it. Use an implementation of Map for the value of the field (e.g. HashMap or LinkedHashMap).
Just create a Map field and initialise it with a value and Forge will convert it to a category. It won't have any properties until you populate the Map with some keys and values.
The config GUI doesn't support adding new entries to the Map. If you want to do that, you'll need to create your own IConfigEntry implementation and tell Forge to use that instead of the default one.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Map is an interface, you can't instantiate it. Use an implementation of Map for the value of the field (e.g. HashMap or LinkedHashMap).
Just create a Map field and initialise it with a value and Forge will convert it to a category. It won't have any properties until you populate the Map with some keys and values.
The config GUI doesn't support adding new entries to the Map. If you want to do that, you'll need to create your own IConfigEntry implementation and tell Forge to use that instead of the default one.
Where do I add default values to the HashMap? You can't initialize with values on a hash map, and I don't think a constructor will work because it's static and never instantiated. And then how will this be written in the file? The other entries have something like "S:" to say that it's a string. Will this also correctly read the values when it runs sync?
Where do I add default values to the HashMap? You can't initialize with values on a hash map, and I don't think a constructor will work because it's static and never instantiated. And then how will this be written in the file? The other entries have something like "S:" to say that it's a string. Will this also correctly read the values when it runs sync?
The Map will be converted to a category with a property for each key-value pair, with the key as the property name and the value as the property value. Forge will preserve the value type, so a Map<String, Double> will be converted to a category containing double properties.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
The Map will be converted to a category with a property for each key-value pair, with the key as the property name and the value as the property value. Forge will preserve the value type, so a Map<String, Double> will be converted to a category containing double properties.
Ah, I forgot about those. I added a static initialization block and it seems to appears to not crash, however I set a sysout to print the HashMap on sync(), and it doesn't appear to read any extra values added from the configuration file, even when the game starts with the new lines in the file. I have this as a test:
But only the ones (stone and wool) that are initialized in the static initialization block are printed out. Do I need to do something to manually load new keys from the file?
Ah, I forgot about those. I added a static initialization block and it seems to appears to not crash, however I set a sysout to print the HashMap on sync(), and it doesn't appear to read any extra values added from the configuration file, even when the game starts with the new lines in the file. I have this as a test:
But only the ones (stone and wool) that are initialized in the static initialization block are printed out. Do I need to do something to manually load new keys from the file?
It looks like the FieldWrapper.MapWrapper class used by the annotation-based config system for Map fields is a bit broken, I've reported this issue here. I've also reported two other issues with it here and here.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
It looks like the FieldWrapper.MapWrapper class used by the annotation-based config system for Map fields is a bit broken, I've reported this issue here. I've also reported two other issues with it here and here.
Ah, I see. Do you think this will be fixed any time soon or should I look into making a custom implementation?
Ah, I see. Do you think this will be fixed any time soon or should I look into making a custom implementation?
The main issue may take a while to be fixed, since I'm not entirely sure how it should be implemented. You'll have to wait for LexManos or someone else to get around to fixing it.
The other two issues should be relatively easy to fix, I plan to submit PRs for them soon.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I'm using the @Config type configuration file for my mod. However I need to know how to add a field that is a list of strings, or if possible a list of pairs of strings and doubles. It appears to only want to read primitive types so how should I go about adding this type of configuration field?
To be clear, it will be a collection of strings, each of those strings has a double. This can be done directly or if there is a way to combine them within the configuration file, but I would probably need some code for that approach.
It sounds like you want a Map<String, Double> field, which will be converted to a category with a property for each key. If you want the order to be maintained, you should be able to use a LinkedHashMap.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
It says I can't instantiate Map, even when I used the scala import. Which import should I use? And then do I just include it the same way that it works for integers? I don't know what Object types the GUI has support for.
Map is an interface, you can't instantiate it. Use an implementation of Map for the value of the field (e.g. HashMap or LinkedHashMap).
Just create a Map field and initialise it with a value and Forge will convert it to a category. It won't have any properties until you populate the Map with some keys and values.
The config GUI doesn't support adding new entries to the Map. If you want to do that, you'll need to create your own IConfigEntry implementation and tell Forge to use that instead of the default one.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Where do I add default values to the HashMap? You can't initialize with values on a hash map, and I don't think a constructor will work because it's static and never instantiated. And then how will this be written in the file? The other entries have something like "S:" to say that it's a string. Will this also correctly read the values when it runs sync?
You can use a static initialiser block to populate the Map with default values.
The Map will be converted to a category with a property for each key-value pair, with the key as the property name and the value as the property value. Forge will preserve the value type, so a Map<String, Double> will be converted to a category containing double properties.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Ah, I forgot about those. I added a static initialization block and it seems to appears to not crash, however I set a sysout to print the HashMap on sync(), and it doesn't appear to read any extra values added from the configuration file, even when the game starts with the new lines in the file. I have this as a test:
But only the ones (stone and wool) that are initialized in the static initialization block are printed out. Do I need to do something to manually load new keys from the file?
It looks like the FieldWrapper.MapWrapper class used by the annotation-based config system for Map fields is a bit broken, I've reported this issue here. I've also reported two other issues with it here and here.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Ah, I see. Do you think this will be fixed any time soon or should I look into making a custom implementation?
The main issue may take a while to be fixed, since I'm not entirely sure how it should be implemented. You'll have to wait for LexManos or someone else to get around to fixing it.
The other two issues should be relatively easy to fix, I plan to submit PRs for them soon.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.