Player Weight Mod

Player Weight Mod

35.2k Downloads

The Player Weight mod is the newest addition of the mods that i made.

Note The mod doesnt add weight by itself. The user has to manually select the weight for each item or set a default weight. That is ment to be like that to make it fully customizable. (Yes there were people who didn't understand why the mod did nothing on installing)

It basically allows to control how much mass each item has and what happens when you reach a specisifc weight in your inventory.

Since of the later version forge added a way to detect Inventories inside of items (not perfectly but some mods) it will also account for that if a Mod makes the inventory visible.
On Top of that it will be able to detect the Fluids inside of Containers that can store fluids and add these extra to the weight of the Item.
If no Weight is provided then it will default to 1kg per 1000mB of the density of the liquid (Math: (fluidDensity(1000) / 1000) * fluidamount / 1000)
Custom FluidEntry Math (customWeight * (fluidamount / 1000))

Weight in this mod is handled with a double number so whenever you see a weight you work with 0.12 numbers.
This allows to adds the most Flexiblity.
Here are the weights that the mod supports by default:

1000 = 1Ton
1 = 1Kg
0.001 = 1g
0.000.001 = 1mg

Ok you have now two types of files you need to manage.

The Weight Files and the Effect Files.


Weight File Doc:

So when you make a Weight file you basically need to make it in a XML Format (not 100% but it copies some aspects of it)
An example would be:
<type=item name=minecraft:wool meta=5 weight=0.2>

Type defines what exactly the entry is. (Either: Item, Ore, Fluid, Default, MaxStacksize)
Weight defines how much  the Item Weighs. Here the values are exactly what was descriped on top. So in this example its 200g (or 0.2kg)

Name & meta are parameters based on the Type


Now a list of all the Possible Types you can put in:

<type=item name=minecraft:wool meta=5 weight=0.02> (Single Item Meta Selection)

<type=item name=minecraft:wool metas=2:3:5 weight=0.02> (Multi Item Meta Selection)

<type=item name=minecraft:wool weight=0.02> (Ignore Item Meta Selection, Does all metas that this item represents)

<type=ore name=copperOre weight=0.02> (OreDictionary support for all equal blocks/items)

<type=fluid name=minecraft:water weight=0.02> (Fluid Check for Fluid Containers)

<type=defaultWeight weight=0.02> (Default for all none registered Items)


<type=defaultPlayerWeight weight=0.02> (Default weight of the player that can not be effected)

<type=size name=minecraft:stick maxsize=32> (Allows to modify stacksizes of items)

If a line starts with // or is empty it will get skipped. That should allow for enough clean code.

Effect File Doc:

The Effect File is a Json File which works like this:

{
	"effects":
	[
		{
			"type": "potion",
			"cooldown": "20",
			"min": 1,
			"max": 200,
			"potions":
			[
				{
					"name": "minecraft:speed",
					"duration": "40",
					"amplifier": 1
				}
			]
		}
	]
}

You have the "effects" array which contains all the effects and then you use a "type" to define which effect you want to use


Here is a list of all effects:

  • Type: "potion"
    Description: (Allows to apply a potion Effect on to the player once he has certain weight level)
    Arguments:
    - "cooldown": (How long it should take until the effects get refreshed)
    - "min": (Which weight it should activate in.) DoubleNumber
    - "max": (Which weight the effect should disable at) DoubleNumber
    - "percent": (If the Min/Max should be a counted as percentage instead of fixed weight values so values between 0-1 for 0% or 100%, defaults to false) Boolean
    - "effectRidden": (Allows to decide if a Player rides an Entity that it gets effected, default false) Boolean
    - "potions": (The Potion Effects that should be applied) ObjectArray or Object
          - "name": (The Potion Registry name)
          - "duration": (How long the Potion Effect should last)
          - "amplifier": (How Strong the Potion Effect should be)
          - "particles": (If Particles should be seen or not)

  • Type: "attribute"
    Description: (Allows to modify the players Attributes)
    Arguments:
    - "effect": (The Attribute of the Player that should be modified) String
    - "min": (Which weight it should activate in.) DoubleNumber
    - "max": (Which weight the effect should disable at) DoubleNumber
    - "percent": (If the Min/Max should be a counted as percentage instead of fixed weight values so values between 0-1 for 0% or 100%, defaults to false) Boolean
    - "effectRidden": (Allows to decide if a Player rides an Entity that it gets effected, default false) Boolean
    - "id": (The ID of the Modification(Unique ID)) String
    - "amount": (How much it should be modified) DoubleNumber
    - "modifierType": (Which type of modification should be, 0 = basic addition, 1 = % Multiplier, 2 = Multiplier (Look up the MinecraftDoc that discribes it well)

  • Type: "exhaustion"
    Description: (Allows to apply extra exhaustion to the player making them more hungry)
    Arguments:
    - "amount": (How much Exhaustion should be added) FloatNumber
    - "cooldown": (How many ticks the game should be waiting between each exhaustion addition) IntNumber
    - "min": (Which weight it should activate in.) DoubleNumber
    - "max": (Which weight the effect should disable at) DoubleNumber
    - "percent": (If the Min/Max should be a counted as percentage instead of fixed weight values so values between 0-1 for 0% or 100%, defaults to false) Boolean

  • Type: "advancment"
    Description: (Allows to make a advancement cause that the player can hold more weight)
    Arguments:
    - "name": (The Advancment that is needed for this weight addition) String
    - "effectName": (Unique ID for the Weight Expansion) String
    - "amount": (How much it should modifier the weight) DoubleNumber
    - "effectType": (Which type of modification should be, 0 = basic addition, 1 = % Multiplier, 2 = Multiplier (Look up the MinecraftDoc that discribes it well) IntNumber

  • Type: "damage"
    Description: (Allows to damage the Player if a certain weight percentage is reached.)
    Arguments:
    - "amount": (How much Damage it should deal) FloatNumber
    - "cooldown": (How many between each damage to the player) IntNumber
    - "activation": (At how many % the Damage should activate, 100 = 100% weight, 0 = 0% weight) DoubleNumber
    - "effectRidden": (Allows to decide if a Player rides an Entity that it gets effected, default false) Boolean

  • Type: "potion_modify"
    Description: (Allows to temporary boost the Players Max Weight if he has a Potion Effect)
    Arguments:
    - "name": (The Potion Registry effect name) String
    - "passive": (If the Effect should be passive or active (Only tickspeed. Passive does every 10 seconds a check (Performance), Default true) Boolean
    - "id": (Unique ID for the Weight Expansion) String
    - "amount": (How much it should modifier the weight) DoubleNumber
    - "effectType": (Which type of modification should be, 0 = basic addition, 1 = % Multiplier, 2 = Multiplier (Look up the MinecraftDoc that discribes it well) IntNumber

  • Type: "kill_ridden"
    Description: (Allows to kill a Entity that a player rides if the weight is to high. (Filter based))
    Arguments:
    - "amount": (How much in Weight the Entity can carray) Double,
    - "name": (The Type of the Entity that it should check for. (Same as commands)) String,

How to use the UI:

 

Ok this seems a bit Complicated but hear me out its very simple:

First of all how do you access this UI? Before you start the game you go into the config folder and select the "loadHelperUI" to true. Once the game starts up this UI pops up and has access to all MCs data (mods/oredict/etc). Once you close it you have to restart the game. That sadly can't be changed because of how i keep track of data etc.

Also to make changes Effective you need to export them and put them into the config. That can be reloaded with reloadCommand so a restart isnt required.

So you have it open and how does it work:

  • The BigTab:
    You have this big area that has all these tabs (Name, Mod, Weight, MaxSize, MaxSizeDefault).
    That is your Data tab where you select the Items that you want to change. This List allows multi select and also all features that interact with the tab are multi selection compatible.
    The stuff that is displayed there is every single thing it can find + Changes that were already loaded via the configs.
  • The Buttons:
    Lets go from top to bottom.
    You have there the "Items", "ItemStacks", "Fluids", "OreDictionary", these buttons are the Categories that you can choose that you want to edit. Changing that will effect some other buttons and also reload List of Objects that is being shown in the Big Tab. (Sorting will be reseted). Also changing stuff in the Oredictionary tab will effect the other tabs and the export behaivior so if you change oredictionary things make sure you do it first, and then the items that have oreIDs.

  • Next: "Set Weight" & "Clear Weight" these will change the weight of the Items and change things based on what you have selected. If nothing is seleceted or the Number typed in isnt parseable then it will throw an error. (Also the Input Values are the exactly the same as in the Files you have to do. But they will be converted in the BigTab so you can understand them better)

  • Now: "Set Max Size" & "Reset Max Size". These Buttons only work if you are in the Items Tab which will allow you to modify the Maximum Stacksize of the Item. (No meta support for that thing).

  • The "Give Item" button was added to allow you to give to yours the  item if you need it for something. Or if you have a entry that name you dont understand and want to know what exactly it is. The Button will throw an Error that you have to have a world loaded to use it. (Duhhh).

  • Last Simple ones: "Set Default Weight" & "Set Player Weight" those buttons are overall buttons.
    Set Default Weight allows you to set the Weight of every single weight that doesnt have a custom modification. Set Player Weight sets the Weight that the player weighs. This weight is a base weight and allow to make it a bit more customizable.
    These two buttons directly effect the game and directly get applied as soon you change the values.
  • Now the complexer one: "ID" & "Invert Sorter" these two are your sorter Buttons, where you can select how the big tab is sorted. You options are depending on which Type you have selected between: "Id",  "IdMeta", "Name", "Mod", "Weight" and "MaxSize".
    The tab gets sorted every time you select a change in these two areas. And it might be helpfull if you search for something.
  • Last two are "Load Changes" and "Export Changes",  Load Changes loads all the installed changes from the game into your current work project, so when you export something that all these get combined into 1 file.
    Export Changes asks you first one thing how should the file be named. (It will add a .xml after that automatically) After that it will ask you should it delete the exported changes out of its cache. Once that is out of the way it will only export all the changes you have made made. If you clear the changes after wards and then export another file with a couple differend changes without loading them in manually again they will only export these couple changes between your last export and the current one. Thats intentional so you can make easier patches (additions only). So if you want to make 1 large file make sure to load the changes that are already in the game and then export them.

I think that covers all the things inside of the UI.


 Note if people want to contribute to the mod or want to make addons for it feel free to do so
 
 Also the mod gains features based on requests. So if you miss something please just ask and as soon i have time i will implement it (if possible)