ContentTweaker

ContentTweaker

27M Downloads

Can't add "Magnetic" trait as a Custom Material Trait (1.12)(Tinkers' Construct)

Pacca64 opened this issue ยท 3 comments

commented

Using both bracket notation and the identifier string "magnetic" gives the error "Could not Identify trait" suggesting that the trait doesn't exist.

myMaterial.addTrait(<ticontrait:magnetic>);
myMaterial.addTrait("magnetic", "head");

Commenting out attempts to add magnetic allow my material to be added just fine with no issues. I can even added other traits, including ones added by PlusTIC, without any problems.

After looking through Tinkers Constructs source code, I found out some things. First, "magnetic" is indeed the correct identifier string for the trait (I was hoping the issue was merely a typo on my end).
Secondly, and perhaps what might be causing a problem here, is that it is one of a small collection of "Leveled Traits". As far as I can tell, ContentTweaker doesn't provide anyway to include a level when trying to find a trait. The few references to a traits "level" I can find are only used for building brand new traits, or for getting information from a trait you already have a reference to.

I'm honestly unsure if this is some sort of user error, but after scanning the documentation over and over again, and asking for help in the discord, I'm at a loss.

commented

I'm currently testing ZenTraits as a way around this limitation, as it supports leveled traits.

commented

I was wondering how to do this. thanks for the clarification, the wiki is a bit vague

commented

Look through the source code for TiC and other addon mods. See the constructor for the magnetic trait here, use the name that is supered:

https://github.com/SlimeKnights/TinkersConstruct/blob/c01173c0408352c50a2e8c5017552323ce42f5b4/src/main/java/slimeknights/tconstruct/tools/traits/TraitMagnetic.java#L28

I was able to get this to work for me when I did momentum:

2022-10-08_10 39 13