이해도 | 입문자 |
---|---|
게임버전 (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
잘못된 부분과 수정해주시면 감사하겠습니다
코코냐
2024.07.07문제 없이 의도대로 돌아가면 잘못된게 없는겁니다. 안되는게 있으면 어디가 안되는지를 알려주셔야합니다.