2024-12-10 17:56:20|Myriagame |source:minecraft skins
Hello Hello, this tutorial simply introduces how to use Kubejs 6 to achieve creating a new Attribute to customize the new Attribute effect.
This article refers to the method of calling and defining the ATTRIBUTE in the method of station B.(The following is a video link. The content in the video is to teach you to define Critic Rate and Critic Damage. If you need it, you can see it.)
BV1FX4Y1675V "1.20.1 kubejs6" Hold a knife, I have a knife crit! | Minecraft Minecraft | Magic Reform Classroom
Bv1dz421j7n "1.20.1 kubejs6" attribute registration, physical attribute modification event!
How to make special bonuses with a physical damage incident with a physical damage incident?Inspired.
First of all, we must clarify that the realization of this function should have two different strings of code to achieve, all placed in the startup_scripts file (it is best to separate, otherwise it will be messy!)
The first paragraph is the registration of the Attribute attribute (the following is the case)
Let $ Attribute = java.loadClass ('Net.mineCraft.World.entity.Ai.attribute')// Register a new bullet damage attribute
StartuPEVENTS.Registry ('Attribute', event => {
Event.createcustom ('kubejs: generic.bullet_damage', () => {
Return New $ Attribute (
'Attribute.name.gneric.bullet_damage',
0.0 // The default value is 0.0
);
});
});
// Add bullet damage attributes to the player entity
ForgeModeVENTS.Onevent (
'Net.mineCraftForge.event.entity.entityATRIBUTEMODIFINEENT
(Event) => {{
If (! Event.has ('Player', 'Kubejs: Generic.bullet_damage') {) {
Event.add ('PLAYER', 'Kubejs: GENERIC.BULLET_DAMAGE');
}
});
The second paragraph is the identification and trigger effect of the Attribute attribute (the following is the case)
forgeevents.onevent ('net.mineCraftforge.event.entity.living.livingHurtevent', livingHurtevent => {{Global.livingHurt (livingHurtevent);
});
/** @param {Internet.livingHurtevent} Event*/
global.livingHurt = EVENT => {
Let {amount, source} = Event;
Let {player} = source;
// Judging the type of damage
Let damageType = Typeof Source.type === 'Function'? Source.type (): Source.type;
Let msgid = typeof damageType.msgid === 'function'? DamageType.msgid (): damageType.msgid;
If (msgid === 'scgus.bullet') {{
// This section is used to test the damage for effective use
// If (Player && Source.gettype () === 'Player') {{
// // Get bullet damage attribute
// Let BulletDamageattribute = Player.Getattribute ('Kubejs: GENERIC.BULLET_DAMAGE');
// if (BulletDamageattribute) {
// Let BulletDamage = BulletDamageattribute.getValue (); // event.setamount (amount*(1.5+BulletDamage)); // Use bullet damage attributes
//} else {
// event.setamount (amount*1.5);
//}
//}
// If it is not directly damaged, for example, the bow and arrow need to be added .Actual to determine the source of direct damage
If (source.actual && source.actual.isplayer ()) {{) {
Let BulletDamageattribute = Player.Getattribute ('Kubejs: GENERIC.BULLET_DAMAGE');
If (BulletDamageattribute) {
Let bulletDamage = BulletDamageattribute.getValue ();
Event.setamount (amount+bulletDamage); // Use bullet damage attributes
} Else {
Event.setamount (amount);
}}
}
};
Next, let's understand the meaning of different code one by one:
The first is the first part:
Let $ Attribute = java.loadClass ('Net.mineCraft.World.entity.Ai.attribute')
I understand this sentence is that the class of Minecraft, the class of Attribute.
In this way, we can tell us what we have to do in the next code, and we must do this before registering Attribute.
StartuPEVENTS.Registry ('Attribute', event => {{{Event.createcustom ('kubejs: generic.bullet_damage', () => {
Return New $ Attribute (
'Attribute.name.gneric.bullet_damage',
0.0
);
});
});
In this paragraph, we define a Startevent event. The type of the incident is registry, the registered thing is 'Attribute', and then create our defined Attribue, that is, 'kubejs: generic.bullet_damage', and give us the package that we first called to identifyNote here that if you want to introduce attributes such as violent crit rate, then please check the BV1DZ421J7N carefully. Among them, the Rangedattribute class needs to be imported.The scope is left to the system by default.From this we only need to define the two attributes of Return New $ Attribute (); one is arg0: string, and the other is ARG1: Number (please use Probejs here in detail, it can tell us what you need to fill in), for ARG0: String, we need to define a name. This term is similar to mine, and ARG1: Number, that is, define the initial value of the player.
forgemodeVents.onevent ('Net.mineCraftForge.event.entity.entityATRIBUTEMODIFINEENT
(Event) => {{
If (! Event.has ('Player', 'Kubejs: Generic.bullet_damage') {Event.add ('Player', 'Kubejs: Generic.Bullet_damage'))
}
}
);
Next is the ForgetModeVENT. According to the meaning of Lu Bucai, you must prevent some problems that register first and then register. Therefore, adding MOD can avoid such problems to a certain extent. This string of code will automatically add us to players to play us.Registered just now (ie: kubejs: generic.bullet_damage attribute).This will not only affect the initial addition, but also need to be used when adding attributes through items. With this, it will automatically add the effect to the player.
Second, let's check the second code:
forgeevents.onevent ('net.mineCraftforge.event.entity.living.livingHurtevent', livingHurtevent => {{Global.livingHurt (livingHurtevent);
});
This is an Forge event. The trigger condition of the incident is LivingHURTEVENT, which can be written according to this, and then the Global.livingHurt (livingHURTEvent) is triggered when the conditions are met;Functions to obtain players' ATTRIBUTE. Other methods are measured that the XXX event cannot call the GetAttribute property.
/** @param {internal.livingHurtevent} every*/global.livingHurt = EVENT => {
Let {amount, source} = Event;
Let {player} = source;
Let damageType = Typeof Source.type === 'Function'? Source.type (): Source.type;
Let msgid = typeof damageType.msgid === 'function'? DamageType.msgid (): damageType.msgid;
If (msgid === 'scgus.bullet') {{
If (source.actual && source.actual.isplayer ()) {Let BulletDamageattribute = Player.getattribute ('Kubejs: Generic.Bullet_damage');
If (BulletDamageattribute) {
Let bulletDamage = BulletDamageattribute.getValue ();
Event.setamount (amount+bulletDamage); // Use bullet damage attributes
} Else {
Event.setamount (amount);
}
}
}
};
This is a way to call the global function. The previous/** @param {internales} Event*/is the introduction of the incident LivingHurtevent. Next, we call the number and source of the injured incident so that we can make modifications and judgments.
Let DamageType = Typeof Source.type === 'Function'? Source.type (): Source.type;Let msgid = typeof damageType.msgid === 'function'? DamageType.msgid (): damageType.msgid;
This is an event that judges the type of damage. For details, please refer to another tutorial on me.
if (msgid === 'scgus.bullet') {If (source.actual && source.actual.isplayer ()) {{) {
Let BulletDamageattribute = Player.Getattribute ('Kubejs: GENERIC.BULLET_DAMAGE');
If (BulletDamageattribute) {
Let bulletDamage = BulletDamageattribute.getValue ();
Event.setamount (amount+bulletDamage); // Use bullet damage attributes
} Else {
Event.setamount (amount);
If the damage type is 'scguns.bullet' (that is, bullet damage, this type can go to the file generated by Probejs to see, find DAMGETYPE -related content (should be this, you can find it carefully)) and then trigger the next content.
Note: Because such as bullet damage and bow and arrow damage are indirectly completed by the medium (either bullet or arrow), we have to obtain a direct source of damage (that is, player), so we need to add .Actual behind the source.And attached source.actual.isplayer () (where source.actual.isplayer ()
It has been judged that the source of damage is the player, and it returns True or FALSE. Therefore, it does not need to be written as the way of the introduction of the below). Of course, the damage caused by our firearms is bullet damage.Add.
The next step is to get the attributes of 'kubejs: generic.bullet_damage' on our players, and then+you can also define a formula in the damage caused by this time.Increase damage, lead:
Event.setamount (amount*bulletDamage);
Haha, the damage is doubled after multiplier.
Finally, let's explain that part of the comment:
// This section is to test the damage for effect// If (Player && Source.gettype () === 'Player') {{
// // Get bullet damage attributes // Let BulletDamageattribute = Player.Getattribute ('Kubejs: GENERIC.BULLET_DAMAGE');
// if (BulletDamageattribute) {
// Let BulletDamage = BulletDamageattribute.GetValue ();
// event.setamount (amount*(1.5+BulletDamage)); // Use bullet damage attributes
//} else {
// event.setamount (amount*1.5);
//}
//}
This is what we said above. The method of judging the source of direct damage. During the writing process, because of the particularity of the incident, it is difficult to understand where our attributes have problems.It is judged that the source is the player, that is, our player is empty -handed, or the damage caused by the sword. If you want to define a attribute similar to melee damage bonus, you must do this.
Take a simple look at the finished product:
The original damage was 10 points
But we have caused 14 damage, and we can also define it on items (take a wooden stick for example)
It caused 18 points of damage. My effect was made with CRT. I think it is more convenient. We must manually write UUID by ourselves.Essence
Note:
Since we define the Startup incident, if you/RELOAD may lead to inexplicable damage, and the ATTRIBUTE failure on various players, you must completely exit the game and restart the effect.Monitoring code increases difficulty.
Since we add Lang files to the game, we only display the name of its definition list in the game. You can write it yourself in the asset file of Kubejs.
You may notice above, my entry: In any hand, it is not in the master or the deputy. This effect is deified, but in version 1.20.1, you only need to add Apothic Attributes (ATTRIBUTESLIB) (that isIt can make the effect show this way. If below 1.20.1, you can also use a deified module to achieve it, but if you don't want other effects of deity, the actual measurement can be measured in version 1.19.2.It is turned off, but retains Tooltip (that is, the above effects) and the small knife in the GUI in Gui in the item bar. This seems to show more attributes (compared to L2 library (that is, the front of Lateland)), the actual measurement is in the CRTAmong them, you just need to write it directly in a <> that the main hand will take effect and the deputy hand will take effect, use "," separate the effect (this effect can be similar to the effect on the staff of Iron's Magic.For the particle size: D).Finally, you can look at the combination effect, damage the group!(I brought an ammunition box with a 50%critical strike rate (this is not the case in my own game), and brought a lower alloy arrow bag that will cause scope damage in the way of the previous tutorialTimes+4 damage guns and wooden sticks)
A little irritable, you must shift+ctrl to display it. The screenshot of the ancestor's mobile phone is used to add an effect to the video.[ASB] ARMOR SET BONUSES suit attribute module is implemented. By defining only one item can form a suit to achieve the addition and activation of attributes, if you want to add random entries to the accessories to define the attributes, you can use the Tiered modulusThe group is implemented, and the specific content will not be expanded for the time being. For details, please consult Github.Of course, through these two modules, you can also add our just -defined Attribute to form a new effect. For example, I will change this ammunition box to bullet damage bonus.
Finally, I wish you happy every day, and you can also add more interesting effects to your game to share in the comment area to provide you with more ideas!
National Service DNF Dark Ni
2025-01-28 09:19:27The new screenshot of the be
2025-01-28 09:18:57The 15th anniversary wallpap
2025-01-28 09:18:273DM Xuanyuan Sinicization Gr
2025-01-28 09:17:57French magazine is the first
2025-01-28 09:17:27The sneak game "Republic" wi
2025-01-28 09:16:57The story between humans and
2025-01-28 09:16:27Capture "Trinity 3: Artifact
2025-01-28 09:15:27Wind direction change "Myste
2025-01-28 09:14:57DICE's new project "Dream" w
2025-01-28 09:14:27Pirate Minecraft Skins
Minecraft Skins
2024-12-10 04:11:27Pirate Minecraft Skins
Minecraft Skins
2024-12-10 04:11:26Master Minecraft Skins
Minecraft Skins
2024-12-10 04:11:25King Minecraft Skins
Minecraft Skins
2024-12-10 04:11:25Guide Minecraft Skins
Minecraft Skins
2024-12-10 04:11:24Dark Knight Minecraft Skins
Minecraft Skins
2024-12-10 04:11:23Sparta Minecraft Skins
Minecraft Skins
2024-12-10 04:11:23Moncraft Skins of the War
Minecraft Skins
2024-12-10 04:11:22Red Witch Minecraft Skins
Minecraft Skins
2024-12-10 04:11:22Golden Cavaliers Minecraft S
Minecraft Skins
2024-12-10 04:11:22