-
Notifications
You must be signed in to change notification settings - Fork 1
Durability System
WearAndTear uses a set of BlockEntityBehaviors to create a part based durability system for BlockEntities.
Behavior Code: wearandtear:PartController
This is behavior is required to use the durability system as it is what manages all the parts.
Behavior Code: wearandtear:Part
This is the base class that defines a part, any part with modified logic has to inherit from this.
Accepts: PartProps
Behavior Codes: wearandtear:ProtectivePart & wearandtear:OptionalProtectivePart
These are parts that provide bonuses to other parts.
Accepts: ProtectivePartProps
Behavior Code: N/A
This is the base class for item parts (since pretty much all blocks handle their item differently...), for implementations see HelveItemPart & PulverizerItemPart.
Behavior Code: wearandtear:RepairItem
This is the behavior that makes it so an item can repair a Part.
Accepts: RepairItemProps
The main properties of a part are defined in PartProps but custom parts may accept extra properties, which can be found in the Config/Props folder.
Decay is calculated by the IDecayEngine implementations that are registered at WearAndTearModSystem.DecayEngines, which use the Props.AvgLifeSpanInYears and other factors (such as being sheltered) to calculate how much damage it should have taken.
Each part can specify the types of decay they are affected by in the PartProps, if multiple are specified it will become the average of them (to ensure that Props.AvgLifeSpanInYears is somewhat accurate)
WearAndTear uses something I call AutoPartRegistry, to automatically add the above behaviors to blocks based on conditions (and the template configuration in the config).
This means that as long as your modded block fulfills the requirements it will naturally become affected by WearAndTear. If you want to customize the WearAndTear configuration of your block or get the AutoPartRegistry to scan your block despite it not being a mechanical block then you need to do the following:
- Add the
wearandtear:PartControllerbehavior.
Which accepts 2 special boolean fields:
-
MergeWithAutoRegistry: If set totruethis block will be scanned by the AutoPartRegistry and the existing behaviors will be merged onto it (this means you can overwrite part of the behavior properties). -
OnlyMergeIfNormallyAutoReg: If set totruethis behavior will only ever merge with AutoPartRegistry if the block fulfilled the requirements for AutoPartRegistry.
- Add the part behaviors you want.
{
"file": "expandedmolds:blocktypes/clay/mold/platemold.json",
"op": "addmerge",
"path": "/entityBehaviorsByType/platemold-*",
"value": [
{
"Name": "wearandtear:PartController",
"Properties": {
"MergeWithAutoRegistry": true,
"OnlyMergeIfNormallyAutoReg": true //Makes it so it won't register if you disable WearAndTear on Molds
}
},
{
"Name": "wearandtear:MoldPart",
"Properties": { //Overwrite the durability usage
"MinDurabilityUsage": 0.06,
"MaxDurabilityUsage": 0.10
}
}
],
"dependsOn": [
{ "modid": "wearandtear" },
{ "modid": "expandedmolds" }
]
}