English
English
Appearance
English
English
Appearance
The ItemWeightsConfigServer
class manages the server-side configuration for the MT Inventory Weight mod. It handles custom item weights, maximum carrying weight, and pocket weight adjustments that impact player movement and interaction based on the weight of items in their inventory.
The server configuration is stored in the inventory_weights_server.json
file within the config/inventoryweight
directory. This file allows server owners to define global weights for different item categories and to adjust the maximum allowable weight players can carry before experiencing negative effects, such as reduced movement speed.
maxWeight
: The maximum weight a player can carry before they are penalized with movement restrictions.pocketWeight
: The weight associated with items stored in a player's armor pockets.loadConfig()
:
inventory_weights_server.json
.maxWeight
and pocketWeight
from the config.InventoryWeightUtil
class with the loaded pocket weight to ensure consistency in the game mechanics.saveConfig()
:
maxWeight
and pocketWeight
) back to the inventory_weights_server.json
file.getMaxWeightFromConfig()
:
setMaxWeight(float value)
:
The inventory_weights_server.json
file has the following structure:
{
"buckets": 3.5,
"bottles": 0.5,
"blocks": 10.0,
"ingots": 2.5,
"nuggets": 0.1,
"items": 1.0,
"creative": 0.0,
"maxWeight": 50.0,
"pocketWeight": 5.0
}
buckets
, bottles
, blocks
, ingots
, nuggets
, items
, and creative
: These fields define the weight values for different categories of items.maxWeight
: Defines the maximum weight a player can carry before being penalized.pocketWeight
: Sets the weight of items carried in a player's armor pockets.If no configuration exists, the system creates a default config file with preset values for each item category:
810.0
270.0
810.0
90.0
10.0
50.0
30000
(Values for some items associated with Creative mode)80000
10000
hese values can be customized by editing the JSON file directly or by using mod-specific configuration tools.
To customize the weight of specific item categories, simply adjust the values in the inventory_weights_server.json
file. For example:
{
"blocks": 12.0,
"ingots": 3.0
}
This change would set weight of blocks to 12.0
and ingots to 3.0
, impacting how much of these items a player can carry before they are slowed down or penalized.
If an error occurs while loading or saving the configuration, it is caught and printed to the server console. This ensures that the server remains operational, even if the config file has issues.
maxWeight
value directly affects how much a player can carry before penalties (such as reduced movement speed) are applied.pocketWeight
value allows for a special inventory system where items carried in pockets (e.g., within armor) have their own weight category, impacting total weight differently.These server-side settings allow for fine-tuning of the gameplay experience to suit different servers' needs, adding a layer of realism and strategy to inventory management in Minecraft.
This flexibility allows the server admin to tailor the weight system to fit any custom modpack or playstyle.