DamageTypeBuilder - yeelp/Distinct-Damage-Descriptions GitHub Wiki

DDD's DamageTypeBuilder lets you create new damage types easily in ZenScript!

Importing the class

It might be required for you to import the class if you encounter any issues, like casting an array, so better be safe than sorry and add the import.

import mods.ddd.DamageTypeBuilder;

Creating a Damage Type

First off, you need to create an instance of the DamageTypeBuilder. You can do so with the create(string) static ZenMethod.

val exampleDamageType = mods.ddd.DamageTypeBuilder.create("example");

After registering this type (see below), you can access this damage type in regular CraftTweaker scripts with <dddtype:example>. You can also use this damage type in the config as ddd_example.

Registering a Damage Type

After you've set the properties you want (See the section on ZenProperties.), you should register the damage type with the register() ZenMethod.

exampleDamageType.register();

Making changes to the DamageTypeBuilder past this point won't change the damage type that was created. Note that the damage type doesn't actually exist yet. All the register ZenMethod does is queue this damage type to be registered. This damage type won't exist in any other script that runs with the ContentTweaker loader, so keep that in mind.

Setting the damage type's... uh, 'type'

Damage types in DDD have what can be referred to as a type category (check the IDDDDamageType's type ZenGetter). This type category may not be necessary or useful for some but it is there in case you want it. A Damage type in DDD can have one of two type categories: Physical or Special. This distinction is, once again, niche in application and DDD itself doesn't do anything mechanically significant with this. By default, the DamageTypeBuilder will set this to "SPECIAL" but you can change it if you wish.

exampleDamageType.setPhysical(); //Sets the type category to Physical
exampleDamageType.setSpecial(); //Sets the type category to Special (which is the default)

ZenProperties

These are the properties you can get and set for the damage type in the DamageTypeBuilder.

ZenProperty Name Type Notes
name string This is the internal name of the damage type. This field gets set to whatever you pass in to the create static ZenMethod, but you can change it like a normal ZenProperty. Note that your script will throw an exception if you set this to null and try to register that type! Once again, accessing the type inside other CraftTweaker (not ContentTweaker) scripts can be done with <dddtype:name> and in the config and in game with ddd_name.
displayName string This is the display name that will appear on tooltips and the like. Typically, if you create a damage type with the name "name" you'd likely want to set the displayName to "Name", but this restriction is not enforced. If you don't set this property before calling register(), DDD will use name as displayName. It will complain and give you a warning though, as most times you want to set a display name, and DDD will assume you forgot.
deathMessageNoAttacker string This is the death message DDD will use if Use Custom Death Messages is enabled in the config and when a player or tamed wolf is killed by this damage type and the cause was not another mob (such as it being environmental). Use #defender as a placeholder for where you want the killed entity's name to go in the death message. If this isn't set before calling register(), DDD will not display a different death message and Minecraft will display a normal death message instead.
deathMessageHasAttacker string This is the death message DDD will use if Use Custom Death Messages is enabled in the config and when a player or tamed wolf is killed by this damage type and the caused was another mob. Use #defender as a placeholder for where you want the killed's entity's name to go in the death message, and use #attacker for where you want the attacker's name to go. If this isn't set before calling register(), DDD will not display a different death message and Minecraft will display a normal death message instead.
color int This is the color that the damage type's name will appear as. This should be a valid hex color. (Anywhere from 0x000000 to 0xFFFFFF). It defaults to 0xFFFFFF which is white.
hidden boolean This determines if this type should show up on tooltips. For more information on what hiding damage types does, see Hiding Damage Types. It defaults to false, which allows this type to show up in tooltips.

ZenMethods

void setPhysical();

void setSpecial();

void register();

  • Queues this damage type to be registered. This DamageTypeBuilder can not be used to register multiple damage types so after this is called, this ZenMethod will do nothing if called again. Your script will throw an exception if the name ZenProperty is either null or already used and a warning will be thrown if the display name isn't set.

Static ZenMethods

Static ZenMethods have to be called on the ZenClass.

DamageTypeBuilder create(string);

  • Creates a new DamageTypeBuilder where the name ZenProperty will be set to the specified string.

Example

#loader contenttweaker
#modloaded distinctdamagedescriptions

val example = mods.ddd.DamageTypeBuilder.create("example"); //After registration, this will be accessible with <dddtype:example>
example.displayName = "Example";
example.deathMessageNoAttacker = "The world made an example out of #defender"; //E.g. "The world made an example out of Yeelp"
example.deathMessageHasAttacker = "#attacker made an example out of #defender"; //E.g. "Spider made and example out of Yeelp"
example.color = 0x00aa00;
example.setSpecial(); //default is special anyway so this isn't really needed if you want it to be special.
example.register();