Solved Change Item Base Damage

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.
Oct 14, 2019
1
0
0
19
Hello! I wanted to know how to change an item's base damage when giving a player an item via Skript, I honestly have no idea how to do this but I just want something like:

Give player 1 Wooden sword with base damage of 128 and when they hit something the sword does 128 base damage, extra damage with enchants and whatever else.

Any help is appreciated, Thank you!
 
If you want to do this in straight vanilla Skript, you'd have to use a combination of a Skript command and a Vanilla Minecraft command (using a trick I recently discovered, it is possible to use NBT data in Skript without the help of addons - but only giving or setting data, not detecting it; anyway, back on topic). Here's what you need to do:

1) If you haven't already, create an "options" section like so:
Code:
options:
        giveCmd:
2) One space-bar after the "giveCmd", type this NBT data:
Code:
{AttributeModifiers:[{AttributeName:""generic.attackDamage"",Name:""generic.attackDamage"",Amount:128,Operation:0,UUIDMost:44099,UUIDLeast:131413}]}
3) The "options" section should now look like this:
Code:
options:
        giveCmd: {AttributeModifiers:[{AttributeName:""generic.attackDamage"",Name:""generic.attackDamage"",Amount:128,Operation:0,UUIDMost:44099,UUIDLeast:131413}]}
4) Where you've set the "give player", replace it with this:
Code:
make console execute command "/minecraft:give %player% wooden_sword{@giveCmd} 1"
 
If you want to do this in straight vanilla Skript, you'd have to use a combination of a Skript command and a Vanilla Minecraft command (using a trick I recently discovered, it is possible to use NBT data in Skript without the help of addons - but only giving or setting data, not detecting it; anyway, back on topic). Here's what you need to do:

1) If you haven't already, create an "options" section like so:
Code:
options:
        giveCmd:
2) One space-bar after the "giveCmd", type this NBT data:
Code:
{AttributeModifiers:[{AttributeName:""generic.attackDamage"",Name:""generic.attackDamage"",Amount:128,Operation:0,UUIDMost:44099,UUIDLeast:131413}]}
3) The "options" section should now look like this:
Code:
options:
        giveCmd: {AttributeModifiers:[{AttributeName:""generic.attackDamage"",Name:""generic.attackDamage"",Amount:128,Operation:0,UUIDMost:44099,UUIDLeast:131413}]}
4) Where you've set the "give player", replace it with this:
Code:
make console execute command "/minecraft:give %player% wooden_sword{@giveCmd} 1"
You can actually do this right in Skript without using the give command

code_language.skript:
aliases:
    test item = minecraft:wooden_sword {AttributeModifiers:[{AttributeName:"generic.attackDamage",Name:"generic.attackDamage",Amount:128,Operation:0,UUIDMost:44099,UUIDLeast:131413}]}

command /test:
    trigger:
        give player a test item
 
You can actually do this right in Skript without using the give command

code_language.skript:
aliases:
    test item = minecraft:wooden_sword {AttributeModifiers:[{AttributeName:"generic.attackDamage",Name:"generic.attackDamage",Amount:128,Operation:0,UUIDMost:44099,UUIDLeast:131413}]}

command /test:
    trigger:
        give player a test item

Completely forgot about aliases. But even still, our points remain: you can still use NBT in vanilla Skript (many people say otherwise, or have trouble doing so)
 
Completely forgot about aliases. But even still, our points remain: you can still use NBT in vanilla Skript (many people say otherwise, or have trouble doing so)
I "knew" about this when 2.3 came out, and forgot + never tried it til recently.
most people arent aware basic item NBT can be added in Skript now (since 2.3) .... its pretty neat.
 
Agreed. I came across this on accident, seeing how Skript treats things in "options" quite literally. So if I wanted to tell the player their playername for example and put it in the "options", it would just show as %player% (this is a actually a bad example, but I forgot what I was doing when I found out)
 
Status
Not open for further replies.