Skip to content

ContentTweaker

TheIllusiveC4 edited this page Jun 26, 2018 · 8 revisions

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.

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 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");

Adding Functionality

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
};

onArmorChange

Called when the player changes worn 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.onArmorChange = function(trait, armor, player, index) {
    //CODE
};