ContentTweaker - illusivesoulworks/constructsarmory GitHub Wiki

Early draft of documenting the ContentTweaker integration

Extended Material Builder

Use this package instead of mods.contenttweaker.tconstruct.MaterialBuilder to make materials that are compatible with Construct's Armory armor! This has all of the functionality of the original package, plus additional functionality to provide armor capabilities. If you use this package at all, you do not need the original one.

Please prime yourself with the original Material Builder documentation, as this documentation will assume familiarity and will only address the differences in usage.

NOTE: This does not "extend" itself from the original MaterialBuilder. It simply shares the same code and builds additional functionality on top of that.

Importing the class

Instead of the original package, please import the following:

import mods.contenttweaker.conarm.ExtendedMaterialBuilder

Creating a material

Instead of the original method, please use the following:

//mods.contenttweaker.conarm.ExtendedMaterialBuilder.create(String identifier);
val myMat = mods.contenttweaker.conarm.ExtendedMaterialBuilder.create("kindlich_mat");

Material Traits

New possible values for dependency are:

  • "core"
  • "plates"
  • "trim"

Material Stats

Remember to implement these as only armor parts whose stats have been added will be built!

myMat.addCoreMaterialStats(float durability, float defense);
myMat.removeCoreMaterialStats();


myMat.addPlatesMaterialStats(float modifier, float durability, float toughness);
myMat.removePlatesMaterialStats();


myMat.addTrimMaterialStats(float durability);
myMat.removeTrimMaterialStats();

Armor Trait Representation

An Armor Trait Representation represents a Construct's Armory Trait. You can get such an object either from the Armor Trait Builder or from the Armor Trait Bracket Handler. Use this package instead of mods.contenttweaker.tconstruct.Trait

Importing the class

Instead of the original package, please import the following:

mods.contenttweaker.conarm.ArmorTrait

Armor Trait Bracket Handler

Use this bracket handler instead of the original only when handling traits built for armor. Please note that all armor identifiers are appended with "_armor" as a suffix.

<conarmtrait:identifier>

<conarmtrait:cactus>

Armor Trait Builder

Use this package instead of mods.contenttweaker.tconstruct.TraitBuilder to make traits for Construct's Armory armor!

Do not use this for building traits for tools.

Please prime yourself with the original Trait Builder documentation, as this documentation will assume familiarity and will only address the differences in usage.

Importing the class

Instead of the original package, please import the following:

import mods.contenttweaker.conarm.ArmorTraitBuilder

Creating a trait

Instead of the original method, please use the following:

//create(String identifier);
val myTrait = mods.contenttweaker.conarm.ArmorTraitBuilder.create("kindlich_test");

Please note that all armor identifiers are appended with "_armor" as a suffix. This happens automatically, so when building a trait please leave this out of the identifier but keep it in mind when trying to retrieve it again later.

Calculated Properties

CanApplyTogether

myTrait.canApplyTogetherTrait = function(ArmorTraitRepresentation thisTrait, String otherTrait){....};
myTrait.canApplyTogetherEnchantment = function(ArmorTraitRepresentation thisTrait, IEnchantmentDefinition enchant){....};

ExtraInfo

myTrait.extraInfo = function(ArmorTraitRepresentation thisTrait, IItemStack item, IData tag){....};

Adding Functionality

onUpdate

Called each tick by the armor when loaded (that means in the player’s inventory). Parameters:

  • A Trait Representation representing the currently used trait
  • An IItemStack representing the armor
  • An IWorld representing the world
  • An IEntity representing the owner
  • An int representing the itemSlot
  • A boolean that describes if the armor currently isSelected

Returns nothing.

Created using:

myTrait.onUpdate = function(trait, armor, world, owner, itemSlot, isSelected) {
    //CODE
};

onArmorRepair

Called before the armor is getting repaired with its repair material. Not to be confused with onArmorHealed which is called afterwards. Will be called multiple times if multiple items are used at once.

Parameters:

  • A Trait Representation representing the currently used trait.
  • An IItemStack representing the armor to be repaired
  • An int representing the amount of durability to be increased.

Returns nothing.

Created using: myTrait.onArmorRepair = function(trait, armor, amount) { //CODE };

onArmorTick

Called each tick when wearing the armor. Parameters:

  • A Trait Representation representing the current used trait
  • An IItemStack representing the worn armor
  • An IWorld representing the world
  • An IPlayer representing the player

Returns nothing.

Created using:

myTrait.onArmorTick = function(trait, armor, world, player) {
    //CODE
};

getModifications

Called when calculating damage reduction values from armor. Parameters:

  • A Trait Representation representing the current used trait
  • An IPlayer representing the player
  • An ArmorModification representing the mods
  • An IItemStack representing the worn armor
  • An IDamageSource representing the damageSource
  • A double representing the amount of damage
  • An integer representing the armor slot index

Returns an ArmorModification.

Created using:

myTrait.getArmorModifications = function(trait, player, mods, armor, damageSource, damage, index) {
    //CODE
};

An ArmorModification object has 5 public fields:

  • float armor that represents the armor amount
  • float toughness that represents the toughness amount
  • float armorMod that represents the armor multiplier
  • float toughnessMod that represents the toughness multiplier
  • float effective that represents the overall multiplier

onItemPickup

Called when picking up an EntityItem Parameters:

  • A Trait Representation representing the current used trait
  • An IItemStack representing the worn armor
  • An IEntityItem representing the picked up item
  • An EntityItemPickupEvent evt

Returns nothing.

Created using:

myTrait.onItemPickup = function(trait, armor, item, evt) {
    //CODE
};

onHurt

Called when taking damage while wearing the armor, before armor and potion calculations. Parameters:

  • A Trait Representation representing the current used trait
  • An IItemStack representing the worn armor
  • An IPlayer representing the player
  • An IDamageSource representing the damageSource
  • A float representing the amount of originalDamage
  • A float representing the amount of newDamage
  • A LivingHurtEvent evt

Returns a float representing the new damage. Otherwise, returns newDamage.

Created using:

myTrait.onHurt = function(trait, armor, player, source, damage, newDamage, evt) {
    //CODE
};

onDamaged

Called when taking damage while wearing the armor, after armor and potion calculations. Parameters:

  • A Trait Representation representing the current used trait
  • An IItemStack representing the worn armor
  • An IPlayer representing the player
  • An IDamageSource representing the damageSource
  • A float representing the amount of originalDamage
  • A float representing the amount of newDamage
  • A LivingDamageEvent evt

Returns a float representing the new damage. Otherwise, returns newDamage.

Created using:

myTrait.onDamaged = function(trait, armor, player, source, damage, newDamage, evt) {
    //CODE
};

onKnockback

Called when being knocked back while wearing the armor. Parameters:

  • A Trait Representation representing the current used trait
  • An IItemStack representing the worn armor
  • An IPlayer representing the player
  • A LivingKnockbackEvent evt

Returns nothing.

Created using:

myTrait.onKnockback = function(trait, armor, player, evt) {
    //CODE
};

onFalling

Called when the player is set to fall. Parameters:

  • A Trait Representation representing the current used trait
  • An IItemStack representing the worn armor
  • An IPlayer representing the player
  • A LivingFallEvent evt

Returns nothing.

Created using:

myTrait.onFalling = function(trait, armor, player, evt) {
    //CODE
};

onJumping

Called when the player jumps. Parameters:

  • A Trait Representation representing the current used trait
  • An IItemStack representing the worn armor
  • An IPlayer representing the player
  • A LivingJumpEvent evt

Returns nothing.

Created using:

myTrait.onJumping = function(trait, armor, player, evt) {
    //CODE
};

onAbility

Called each tick when the player has the trait. Parameters:

  • A Trait Representation representing the current used trait
  • An integer representing the trait level
  • An IWorld representing the world
  • An IPlayer representing the player

Returns nothing.

Created using:

myTrait.onAbility = function(trait, level, world, player) {
    //CODE
};

onArmorEquip

Called when the player equips the armor. Parameters:

  • A Trait Representation representing the current used trait
  • An IItemStack representing the worn armor
  • An IPlayer representing the player
  • An integer representing the armor slot index

Returns nothing.

Created using:

myTrait.onArmorEquip = function(trait, armor, player, index) {
    //CODE
};

onArmorRemove

Called when the player removes the armor. Parameters:

  • A Trait Representation representing the current used trait
  • An IItemStack representing the worn armor
  • An IPlayer representing the player
  • An integer representing the armor slot index

Returns nothing.

Created using:

myTrait.onArmorRemove = function(trait, armor, player, index) {
    //CODE
};

onArmorDamaged

Called when the armor gets damaged by any means. Parameters:

  • A Trait Representation representing the current used trait
  • An IItemStack representing the worn armor
  • An IDamageSource representing the damageSource
  • An integer representing the original amount
  • An integer representing the newAmount
  • An IPlayer representing the player
  • An integer representing the armor slot index

Returns an integer representing the new damage amount. Otherwise, returns newAmount.

Created using:

myTrait.onArmorDamaged = function(trait, armor, damageSource, amount, newAmount, player, index) {
    //CODE
};

onArmorHealed

Called when the armor gets healed by any means. Parameters:

  • A Trait Representation representing the current used trait
  • An IItemStack representing the worn armor
  • An IDamageSource representing the healSource
  • An integer representing the original amount
  • An integer representing the newAmount
  • An IPlayer representing the player
  • An integer representing the armor slot index

Returns an integer representing the new heal amount. Otherwise, returns newAmount.

Created using:

myTrait.onArmorHealed = function(trait, armor, healSource, amount, newAmount, player, index) {
    //CODE
};

getAbilityLevel

Called when a function needs to know the ability level of the trait on the armor piece. Parameters:

  • A Trait Representation representing the current used trait
  • A ModifierNBT representing the data

Returns an integer representing the ability level. Otherwise, returns 1.

Created using:

myTrait.getAbilityLevel = function(trait, data) {
    //CODE
};