COT adds a little more complicated feature example to the soul [COT] ContentTweaker Minecraft Game

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

statement

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

Trart Builder -Crafttweaker Documentation (Blamejared.com)

Advanced use · gitbook (IMC.WIKI)

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

5. The two cases of this tutorial are self -integrated packages.

Case code v1

#Loader ContentTweaker

#priority 999

#Modloaded tconstruct

Import Mods.ContentTWEAKER.TCONSTRUCT.TRAITBUILDER;

Import crafttweaker.World.ifacing;

// 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.

// The third line indicates that when the artisan soul is loaded, this script will be loaded

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

var faciling as string [string] = {

"Up": "double",

"DOWN": "UP",

"North": "South",

"South": "North",

"East": "West",

"West": "East"

};

// This is an associated array, if you need a tutorial, please go to the associated array (mapping) · gitbook (IMC.WIKI)

// Create an object called XXX.

var association = trartbuilder.create ("assassinated");

// Set the color (the hexadecimal color code)

assassinated.color = 0xee0000;

// Set the characteristic level upper limit

assassinated.maxLevel = 1;

// 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 at the forging table for tool enhancement will the color set on the color = 0xee0000 on it. If the tool does not need to be strengthened, it comes with this feature. The color of the font is determined by the material.

assassinated.addItem (); // People hold you with a small hair (flower) and stab at you ~~

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

assassinated.localizedName = "Assassin will never hit the front!";

// Set feature annotation, which is displayed in the book of craftsmanship.

assassinated.localizedDescripting = "Attack damage behind the behind increased by 20, positive attack damage decreases by 10, and side damage is reduced by 7.5";

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

// Please refer to Wiki: Trart Builder -Crafttweaker Documentation (Blamejared.com)

// 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.

assassinated.calcdamage = Function (Trart, TOOL, Attacker, Target, OriginalDamage, NewDamage, Iscribeical) {

If (! Target.World.remote) {

// Make sure the incident runs on the server

Var facilinga as ifacing = iFacing.getDirectionFromentityliving (Attacker.position, Attacker);

Var facilingt as ifacing = iFacing.getDirectionFromentityliving (target.position, target);

// Get the position of the attacker and the target

// There are six positions in the southeast, northwest, and northwest

// For more if IFACING, please go to ifacing

If (Faceinga == Faceingt) {

// For example, both attackers and targets look north, and then the attacker attacking must be the back of the target

// If the orientation you see is the same, the damage increases 20 20

Return NewDamage + 20;

} Else {

// If the attacker and the goal do not see the same orientation, enter the judgment here

// Because the "positive attack damage is reduced by 10, and side damage is reduced by 7.5" //

// At this time, the associated array above will play a role

// If you need to associate an array, please go to the associated array (mapping) · gitbook (IMC.WIKI)

For aa, bb in faciling {

// The left side of the associated array colon represents AA

// The parties on the right of the associated array are BB

If (faceinga.getName (). TOLOWERCASE () == AA) {

// If the position of the attacker see is the same as AA

// Note! The GetName () method returns all the capital, such as North, UP, DOWN

// TOLOWERCASE () is a method that comes with Java itself.

// For more details, go to Basic Variable Functions

If (faceingt.getName (). TOLOWERCASE () == BB) {

// If the position of the target see is the same as the BB

// For examples of the above two if: // If the attacker looks at north (north), the target looks at south

// Then I will first judge the position of the attacker see

// Let's look at the associated array. When AA is nurth, BB is south (south)

// Then judge the position of the target, and look at the goal!Okay, right with BB

// So you can determine that the attacker and the target are in the state of view, that is, positive

// So the operation of the damage is reduced by 10 10

Break;

// This operation is an exit loop to reduce unnecessary performance loss

// Cycle related knowledge, please go to the cycle and traversal · Gitbook (IMC.WIKI)

Return NewDamage -10;

} Else {

// Okay. If the target is not the south, it will enter the place where it is // Since it is not the south, then it can be determined that it is east or west, then the attacker's attack must be the side of the target

// So the attack minus 7.5

Break;

Return NewDamage -7.5;

}

}

}

}

}

Return newDamage;

};

// Register this feature to the game.

// That is to tell the game that I have finished writing this feature

// 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.

assassinated.register ();

Effect in the game v1

[picture]

[picture]

[picture]

[picture]

[Okay, there is no picture here ...]

Case code v2

// V2 only explains the code logic (if you copy it directly and use it, don’t find me when you report the error)

// The thinking and logic of the magic reform is the idea and logic of the magic reform

var peacefully = trartbuilder.create ("" peaceFully ");

Peacefully.color = 0xee0000;

Peacefully.maxLevel = 1;

Peacefully.localizedName = "Both feet and one kick with the world without fighting";

Peacefully.localizedDescripting = "Eliminate the surrounding 9*9 range of biological hatred (centered on players) when squatting above the dry grass";

Peacefully.onUpdate = Function (Thistrait, Tool, World, Entity, Itemslot, Isselect) {

// When this characteristic craftsmanship tool is on the player, each T will trigger this function

// Please refer to Wiki: Trart Builder -Crafttweaker Documentation (Blamejared.com)

// For more events, please refer to the wiki page, and there is a description under each event.

Var pos as iBlockpos = Entity.position; if (! World.remote) {

// The service side runs

If (entity instanceof iPlayer) {

// Determine whether this entity is an iPlayer type

// After all, zombies can also pick up the artisan soul tool

Var Player as iPlayer = Entity;

Ifer.issneaking && world.getBlock (pos.down ()). Definition.id == "Minecraft: HAY_BLOCK") {

// Judging whether the player is squatting and judging the box under the foot

Player.removePotionEffect ();

// This is to balance the characteristics of my integrated package, which can be deleted

Player.addpotionEffect ( .makePotionEffect (1, 3, TRUE, FALSE));

// If it can be eliminated, it will be too good, so it is given weak and reduced damage.

Var s = pos.getOffset (ifacing.up (), 5) .getOffset (ifacing.west (), 4) .getOffset (ifacing.north (), 4) as iBlockpos;

Var e = pos.getOffset (ifacing.down (), 5) .getOffset (ifacing.east (), 4) .getOffset (iFacing.South (), 4) as iBlockpos;

// Determine a range

Var entities = World.GetentITIESIEEARa (s.asposition3f (), e.asposition3f ()) as IENTITY []; // record the entities of this range in this array

For Entity in Entities {

// Traversen an array

If (! (Entity Instanceof iPlayer)) {{

// If it is not belonging to the iPlayer type

// Because of the hate from the player?

If (entity instanceof personityliving) {{

// Judging whether it belongs to Ientityliving

Var entityliving as IENTITYLIVING = Entity;

Entityliving.attacktarget = null;

// Set the hatred as empty, that is, there is no hatred

}

}}

}

}

}

};

Peacefully.register ();

Effect in the game v2

[picture]

[picture]

[picture]

[picture]

[Rest assured, there are no pictures here ~~~]

grateful

The method of eliminating hatred provided by Friendship Mom in the Q group

Nishiki tutorial

Official wiki