[1.16] Disable the global generation rate of enchanting & reduce a biological global generating rate [CRT] CRAFTTWEAKER

This tutorial is set by the author's setting without permission.

Share two simple but practical tips.

Advertising: Replacement/Supplement of this tutorial: Enchantato, Potatweaker.

Disable enchant

This disabled method focuses on "use" instead of "acquisition". If you make your mind, you want to make a magic unable to attach it in the enchanting Taichu, then this method is not suitable for you.

The disadvantages of this method are also obvious (player: I sent it so hard that the devil attached to it?), Everyone used it as appropriate.

If a magic magic can cause the game to collapse and its corresponding module can turn off its configuration file, this method will be very suitable.

Idea: Surveillance LivingUpdate Event (Playrtick Event, you can also do it at will). If the player's weapon/armor has the enchantment you want to disable, it will be replaced to remove this enchanting weapon/armor.

example

The following examples disable the sharp enchantment of weapons.

 Import Crafttweaker.api.event.living.mclivingupdateEvent;

import crafttweaker.api.events.cteventmanager;

import crafttweaker.api.util.mchand;

CteventManager.register ((EVENT) => {// "Surveillance Living Lidingupdate Event"

Var Entity = Event.entityliving;

Var World = Entity.WORLD;

If (World.remote || Entity.type! = ) Return; // "Player"

Var Mainhanditem = Entity.Gethelditemmianhand (). Asiitemstack ();

Var OffHandItem = Entity.Gethelditemoffhand (). Asiitemstack ();

If (Mainhanditem.GetenchantmentLeveel

// "If the player's weapon/armor has the enchanting you want to disable"

Entity.Sethelditem (mchand.main_hand, MainhandiTem.Removeenchantment ()););););

// "Just replace it with weapons/armor that removes this enchanting"

}

If (OFFHANDITEM.GetenchantMentLevel ()> 0) {// Deputy Similar Similar Phase

Entity.SethelDiTem (mchand.off_hand, offhanditem.Removeenchantment (););}

});

Derivative: Uniform enchantment

You can use this method with the same enchantment, such as Fish's Undead Rising, Cyclic and Random Enchants.

The idea is to remove all first, and then unify again.(The module Config always brings its own True/FALSE of the enchantment? You can write less) (for example

script

 Import Crafttweaker.api.event.living.mclivingupdateEvent;

import crafttweaker.api.events.cteventmanager;

import crafttweaker.api.util.mchand;

CteventManager.register {

Var Entity = Event.entityliving;

Var World = Entity.WORLD;

If (World.remote || Entity.type! = ) Return; Return;

VarmedINDITEM = Entity.Gethelditemmainhand (). AsiiteMStack (); // Here is the master of the master, the mate of the deputy, the main is changed to OFF.

Var Remainhandlevel = Mainhanditem.GetenchantmentLevel ();

Var Fishmainhandlevel = Mainhanditem.GetenchantmentLevel ();

Var cyclicmainhandlevelly = Mainhanditem.GetenchantmentLevel ();

If (Remainhandlevel> 0 || Fishmainhandlevel> 0 || CyClicmainhandlevel> 0) {{

// Because the sliding bars of the encyclopedia block are not long enough, it is divided into 仨 to write

Var remover1 = Mainhanditem.removeenchantment (); VAR Remover2 = Remover1.removeenchantment t: MOD_LAVACOW: Lifesteal>);

Var remover3 = Remover2.removeenchantment (); // here, "All removed"

Var Item = Remover3.withenchantment (, 1); // "Unity" "unity"

// The enchanting level can live the whole point, and use 1 here.

Entity.Sethelditem (mchand.main_hand, item);

}

});

Reduce the global generating rate of a certain creature

Do you think that some creatures still generate a lot of generating weight even if you reducing the generating weight to the minimum in its config?(Such as piggy bank, weeping angels)

Then this idea will help you.

Idea: The generic rate is not a probability, then we also have a probability to adjust it.The incident of listening to the Entityjoinworld, a random number between 0 to 100, if this number is larger than the value you set (this value = 100 -the biological generation rate you want to be reduced* 100), or this number is more than you set.Value (this value = the biological generation rate* 100 you want to be reduced) If you want to be small, cancel the event and prevent the entity from joining the world.

example

Let's take an example to reduce the global biological generation rate of the crying angel by 80%.

By the way, make up a nonsense, and this reduction method is also effective for brushing cages.

 Import Crafttweaker.api.Event.entity.mcentityjoinWorldEvent;

import crafttweaker.api.events.cteventmanager;

CteventManager.register ((EVENT) => {// "Surveillance EntityjoinWorld event" event "

Var Entity = Event.entity;

Var World = Entity.WORLD;

If (world.remote) Return;

If (entity.removetag ("CRT.SPAWNED") {{) {

ENTITY.ADDTAG ("CRT.SPAWNED");

Return;

}

Entity.addtag ​​("CRT.SPAWNED"); // The meaning of the operating of tag above is to let the following code be executed only once.

// Otherwise, every time you enter your archive, all the entities will be considered to be added to the world again, and if the following complicated operations are performed, it will have a great impact on performance.

// Even the archive card was killed.

//Entity.removetag returns the Boolean value, and this method will be executed in the IF at the same time, so you need to addtag ​​again.

// Very good TAG black technology, love comes from CRT

// There is also a related pr.

If (if (if (if

Entity.type == &&

World.random.nextint (0, 100)> 20

) {// "Take the random number between 0 to 100, if this number is more than the value you set (this value = 100-the biological generation rate you want to be reduced*100)

Event.cancel (); // "Cancel the incident and prevent the entity from joining the world"

}

});