개인 자료란 (JE)

  서버 커뮤니티

Profile starbix 대표칭호 없음
Profile

질문하기 스크립트

무기 강화 스크립트

2024.07.07 조회 수 211 추천 수 0
이해도 입문자 
게임버전 (JE) 1.20.1 
게임버전 (BE) 관련없음 
스크립트 버전 최신 버전 
스크립트 애드온 SKbee 

# 아이템 강화 스크립트 (모루 사용)


variables:

    {_damage_increase::*} = 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0

    {_protection_increase::*} = 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0


function upgrade_cost(level: number) :: number:

    return {_level} + 1


on anvil prepare:

    if target item is a sword or target item is a helmet or target item is a chestplate or target item is leggings or target item is boots:

        set {_item} to target item

        set {_level} to nbt tag "UpgradeLevel" of {_item}

        if {_level} is not set:

            set {_level} to 0

        set {_next_level} to {_level} + 1

        set {_cost} to upgrade_cost({_level})

        if {_cost} > 1:

            set {_cost_display} to "%{_cost}% diamonds"

        else:

            set {_cost_display} to "%{_cost}% diamond"

        set {_tooltip} to "Upgrade Cost: %{_cost_display}%"

        set {_item} to {_item} with lore {_tooltip}

        set event-item to {_item}


on anvil repair:

    if target item is a sword or target item is a helmet or target item is a chestplate or target item is leggings or target item is boots:

        set {_item} to target item

        set {_level} to nbt tag "UpgradeLevel" of {_item}

        if {_level} is not set:

            set {_level} to 0

        set {_cost} to upgrade_cost({_level})

        if player has {_cost} of diamonds:

            remove {_cost} of diamonds from player

            add 1 to {_level}

            set nbt tag "UpgradeLevel" of {_item} to {_level}

            if target item is a sword:

                set {_damage} to {_damage_increase::%{_level}%}

                add {_damage} to nbt tag "AttributeModifiers:[{AttributeName:\"generic.attack_damage\",Name:\"generic.attack_damage\",Amount:%{_damage}%,Operation:0,UUID:[I;1,1,1,1]}]" of {_item}

            else if target item is a helmet or target item is a chestplate or target item is leggings or target item is boots:

                set {_protection} to {_protection_increase::%{_level}%}

                add {_protection} to nbt tag "AttributeModifiers:[{AttributeName:\"generic.armor\",Name:\"generic.armor\",Amount:%{_protection}%,Operation:0,UUID:[I;1,1,1,1]}]" of {_item}

            send "Your %{_item}% has been upgraded to level %{_level}%!" to player

        else:

            send "You need %{_cost}% diamonds to upgrade your %{_item}%." to player

            cancel event

잘못된 부분과 수정해주시면 감사하겠습니다


1개의 댓글

코코냐
2024.07.07

문제 없이 의도대로 돌아가면 잘못된게 없는겁니다. 안되는게 있으면 어디가 안되는지를 알려주셔야합니다.

뉴스 및 창작물
/files/thumbnails/246/933/003/262x150.crop.jpg?20241204080049

업데이트

[마인크래프트 1.21.4 업데이트]

제작대

2024-12-04

0

/files/thumbnails/477/930/003/262x150.crop.jpg?20241201030912

레드스톤

뉴진스 - Super Shy | 마크 노트블럭 커버

노트블럭전문가

2024-12-01

0

/files/thumbnails/483/916/003/262x150.crop.jpg?20241127115329

레드스톤

[노트블럭 커버] 뉴진스 - ETA 3

노트블럭전문가

2024-11-27

1

/files/thumbnails/150/925/003/262x150.crop.jpg?20241123005717

건축

응답하라 1988 ? 1

팀뉴일리시

2024-11-23

5

/files/thumbnails/761/908/003/262x150.crop.jpg?20241025153749

건축

서울 숭례문(崇禮門) 6

KHC

2024-10-25

2