English
English
Appearance
English
English
Appearance
The ItemWeightConfigItems
class is designed to manage and store custom item weight configurations for the MT Inventory Weight mod. It works by reading from and writing to the inventory_weights_items.json
file, which contains item-specific weight data.
The inventory_weights_items.json
file holds the custom item weights specified by players or mod authors. This allows for precise control over the weights assigned to specific items, providing flexibility in how the weight system affects gameplay.
loadConfig()
:
inventory_weights_items.json
file.ItemWeights.loadCustomWeightsFromConfig()
.saveConfig()
:
inventory_weights_items.json
file.ItemWeights.getCustomItemWeights()
method is used to retrieve the custom weights before saving.The inventory_weights_items.json
file contains custom weights in the following format:
{
"minecraft:stone": 810.0
}
In this example, minecraft:stone is assigned a weight of 810.0f. You can add or modify items and their respective weights in this file.
createDefaultConfig()
:
810.0f
to minecraft:stone
.isDynamicItem(String itemName)
:
true
if it can be modified.In case of an error while reading or writing to the inventory_weights_items.json
file, exceptions are caught and printed to the console for debugging purposes. This ensures that the mod does not crash if something goes wrong during file handling.
To add a custom weight to an item, simply open the inventory_weights_items.json
file in the config/inventoryweight
directory and add the item ID along with its desired weight. For example:
{
"minecraft:iron_ingot": 100.0,
"minecraft:diamond": 200.0
}
After saving the file, the mod will load these weights the next time it runs.
The createDefaultConfig()
method can be modified to include default weights for additional items. By default, only minecraft:stone
is assigned a weight, but you can extend this list based on the items in your modpack or world.
The configuration system is flexible and can be easily extended by adding more items and their corresponding weights to the inventory_weights_items.json
file. Custom weights allow players to tailor the game’s weight system to their preferences, giving them control over how certain items impact movement and gameplay.