Use COT to add custom characteristics to the soul of the craftsmanship [COT] ContentTweaker Minecraft Game

This tutorial is set by the author to use the CC by-NC protocol.

Notice:

1. For full content, please refer to the official wiki/other comrades translated wiki/other COT tutorials/other CRT tutorials.

Https://docs.blamejared.com/1.12/zh/

Https://crafttweaker.readthedocs.io/zh_cn/laatest/

Https://youyi580.gitbook.io/zentutorial/

2. This tutorial is applicable to 1.12.2. If you want to use it for other versions, see Wiki or try it yourself.

3. Due to my limited technology, this tutorial must have shortcomings. Please understand. If you have better suggestions, please point out in the comment area.

4. Modules required for this tutorial: Crafttweaker, ContentTweaker, Craftsmanship 2. Magic Soul (Optional), Craft Soul Adjustment (optional) (optional)

5. The nouns that may involve in the tutorial will not be explained, such as the "parent".

Code area

// The following is a script of creating characteristics

#Loader ContentTweaker

#priority 10

import crafttweaker.item.iitemDefinition;

Import Crafttweaker.events.ieventmanager;

Import Crafttweaker.event.playEraattackentiEvent;

import crafttweaker.player.iplayer;

import crafttweaker.item.iitemstack;

Import crafttweaker.World.iworld;

Import Mods.ContentTWEAKER.TCONSTRUCT.TRAITBUILDER;

// The information above starts with #loader

// The first line indicates that this script is loaded by COT to load this script.

// If the information of the script warning/error report is too eye -catching, you can add a line "#ikwid" under "#Loader ContentTweaker".The function is to indicate that the warning/error message will be printed in the log and will not be displayed in the game.

// The second line indicates the loading priority, and the priority is from large to small. Look at who loads this script first in A-Z.

// Import xxx, etc., indicate to be introduced into a certain bag

// Create an object called XXX.

Val Trait_moonLight = MODS.CONTENTTTWEAKER.TCONSTRUCT.TRAITBUILDER.CREATE ("Trait_moonlight");

// Set color

Trait_moolight.color = 0x99ffff;

// Set the characteristic name, which is displayed in items with this feature.

Trait_moolight.localizedName = ("Moonlight"); // Set feature annotation, displayed in the soul book.

Trait_moolight.localizedDescripting = ("" Damage bonus ");

// The specified material can strengthen this feature to the tool.Like the rapid characteristics of the use of redstone to ah, it is enhanced in the artisan soul forging platform.

// If you want to add your own characteristics to the customs that are not written by your own, you should use the artisan soul to adjust the module to configure in the configuration file of the module.

// Only on the forging table for tool reinforcement will the color set on the color = 0x99fff set on it. If the tool does not need to be enhanced, it is determined by the material.

Trait_moolight.additem

// Change the damage calculated when the player attacks the entity.

// Please refer to wiki: https: //docs.blamejared.com/1.12/zh/mods/contenttweaker/tinkeers_constructbuilder/#ontoolhealheal

// mytrait.calcdamage = Function (...) {// code} means that the event is captured when the entity is attacked.For more events, please refer to the wiki page. There is a description under each event.

// If you can't understand, see the incident explanation below.

Trait_moonlight.calcdamage = Function (Trart, TOOL, Attacker, Target, OriginalDamage, NewDamage, ISCRITICAL) {

// Create a variable to save the moon phase integer.

// Attacker is an IENTITYLIVINGBASE type, so you can get monthly phase information or other world information according to his parent class, such as whether it is during the day.

Var nowmoonPhase as int = Attacker.WORLD.GetmoonPhase ();

// Determine whether the monthly phase variable is empty, and the bonus damage is returned without air.For empty, it returns the original damage.

// Great than or equal to 3 judgments to avoid the situation where it becomes negative BUFF after 2, such as how I hurt 0.

// Judging whether it is night now.

// The maximum monthly phase is 7 times. Except for 2, the maximum damage can be limited to 3.5 times. It may be that the type of involved in the operation is not the number of floating -point numbers or the returned value must be up to 3.5 times.

IfmoonPhase> = 3 &! Attacker.World.isdaytime ()) {) {

Return newDamage*(nowmoonPhase/2);

} Else {

// Return to the original damage when not met.

Return NewDamage;}

};

// Register this feature to the game.

// When the features are written, you can use COT/Pewter to add this feature to the material. You need to pay attention to the priority.

trait_moonlight.register ();

Code result

Event explanation

-Fere the list of events, please refer to wiki: https: //docs.blamejared.com/1.12/zh/mods/contenttweaker/tinkers_constructbuilder/#ontoolhealheal

-Mytrait.calcdamage = Function (...) {// code} indicates events when capturing the entity being attacked.For more events, please refer to the wiki page. There is a description under each event.

-What is an event: the incident means "whether something has happened".For example, player synthesis, player attack, and physical damage.

-How to use events provided by the event list:

Call an event that is the object you created and add event methods. For example, I created an object called "Trait_moonlight" in this tutorial, and then I hope to modify the damage caused by the attack......) {// code} "

-How to know the tools or the world used by the player when calling this event:

When we call the incident, the "Function (Trart, TOOL, Attacker, Target, OriginalDamage, NewDamage, IScripical)" behind the name ") bring this information.The program will automatically fill in these parameters, we only need to understand the meaning of these parameters.

For example, tract represents the current feature, Tool represents the current tools of the current tool, and target represents the attack target.

If there is no information we want in the parameter list, you can find the method provided by the parameter object.If this class is not provided, you can also see if his parent class provides the corresponding method.

For example: ATTACKER is an attacker. Its parent "IENTITY" provides a "World" method to indicate the information of the world where the entity is located.We can use "Attacker.WORLD.GetmoonPhase ();" to know the moon phase information of the world's world.Or understand the current dimension (attacker.World.getDimension ()) through the "iWorld" type represented by this "World".

Example analysis

Take the event in the event list as an example: mytrait.ontoolDamage = Function (Trart, Tool, UnmodifiedAmount, Newamount, Holder) {// code Return newAmount; // or y y Our modeld value};

The tools are durable to reduce before calling.

parameter:

Trait: Represents the characteristics of the current use.

TOOL: indicates the current use tool.

Unmodifydamount: It means durability before modification.

newamount: It means durability to be reduced.

HOLDER: It is an IENTITYLIVINGBASE object. We can modify or understand the information of the tool holder through this object.For example, if durable decreases each time, the value of life is reduced by 1 point ( SVG>).Or the health of the holder is less than 10 points ( ) durable durability consumption.Returns an int representative to reduce durability.Otherwise, return newamount.

Simple example:

-The durability and decrease of 1 point ( )::

Function (...) {


Holder.health = Holder.health- 1.0;

};

-The holder's health is less than 10 points ( ) durability durable consumption doubles:

Function (...) {

If (holder.health <= 10) {

Return newamount * 2;

} Else {

Return newamount;};

};

grateful:

// Copy his github

Friendship HJ: Flying Road 3 3

// Translated wiki

Sinicic CRT's Wiki of CRT

Youyihj's gitbook

Official wiki