개인 자료란 (JE)

  서버 커뮤니티

Profile starbix 대표칭호 없음
Profile

질문하기 스크립트

무기 강화 스크립트

2024.07.07 조회 수 121 추천 수 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/348/896/003/262x150.crop.jpg?20241006021144

디도스/봇테러등등을 낚는 방법

물귀신

2024-10-06

0

/files/thumbnails/839/895/003/262x150.crop.jpg?20241006021227

SRV레코드는 보안도메인이 아닙니다. [서버오픈시 필독]

물귀신

2024-10-05

1

/files/thumbnails/648/892/003/262x150.crop.jpg?20241002184058

아티클

마인크래프트 라이브 2024 후기: 무성의가 느껴졌던 '절망편' 라이브

라비

2024-10-02

1

/files/thumbnails/693/890/003/262x150.crop.jpg?20241005095433

소식

[방송인 필독] 시참 컨텐츠 방송인분들께 DDoS(디도스) 공격을 퍼붓는 용의자 특정중, 예방 & 대처법 정리 7

해그

2024-10-01

1

사진이 없습니다.

레드스톤

[노트블럭 패러디] 신창섭 - 모장이 다해줬잖아

노트블럭전문가

2024-09-28

0