/attribute: base value बनाम modifiers, और आपकी वैल्यू बार-बार रीसेट क्यों हो रही है
base value सेट करना स्थायी होता है और modifier सेट करना नहीं — जब तक कि आप गलत ऑपरेशन न चुनें। तीन ऑपरेशन, स्टैकिंग क्रम, और स्लॉट का जाल।
/attribute looks like one command with three subcommands. It is really two different systems that happen to share a name, and mixing them up is why values keep snapping back.
base बनाम modifier
/attribute @s minecraft:max_health base set 40
/attribute @s minecraft:max_health modifier add my_buff 20 add_value
base setentity की अपनी वैल्यू को दोबारा लिखता है। यह बरकरार रहता है रीलोड के दौरान और यह
किसी अन्य चीज़ से नहीं हटाया जाता सिवाय दूसरे base set.
modifier addऊपर से एक अस्थायी बदलाव जोड़ता है। इसकी एक id होती है, और इसे
उस id द्वारा हटाया जा सकता है।
यदि relog करने पर आपका बदलाव गायब हो जाता है, तो आपने modifier का उपयोग किया था और किसी चीज़ ने उसे हटा दिया। यदि आपका बदलाव नहीं हटता है, तो आपने इस्तेमाल किया base set and need base reset.
तीन ऑपरेशन, और उनके लागू होने का क्रम
| ऑपरेशन | क्या करता है | लागू |
|---|---|---|
add_value | value + n | पहले |
add_multiplied_base | value + (base × n) | दूसरे |
add_multiplied_total | running total × (1 + n) | अंतिम |
क्रम तय है और इसका महत्व है। base 20 से शुरू होकर, फिर add_value 10 and add_multiplied_total 0.5:
20 → 30 → 45 not 20 → 30 → 30 + 10 = 40
add_multiplied_base always multiplies the मूल base, न कि रनिंग टोटल — यही कारण है कि उनमें से दो कंपाउंड होने के बजाय योगात्मक रूप से स्टैक होते हैं।
Modifier id अब namespaced हैं
पुराने वर्ज़न एक UUID का उपयोग करते थे। आधुनिक वर्ज़न एक namespaced id:
/attribute @s minecraft:attack_damage modifier add my_pack:rage 5 add_value
समान id के साथ दूसरा modifier जोड़ना प्रतिस्थापित करता है स्टैक होने के बजाय पहले वाले को। किसी बफ़ को रीफ्रेश करने का यही सही तरीका है — आपको इसे पहले हटाने की आवश्यकता नहीं है।
Equipment modifiers आइटम पर रहते हैं, entity पर नहीं
एक enchanted तलवार का डैमेज बोनस एक attribute_modifiers item component, और यह केवल तभी लागू होता है जब आइटम सही स्लॉट में हो:
/give @s diamond_sword[attribute_modifiers=[{type:"attack_damage",amount:5,
operation:"add_value",slot:"mainhand",id:"my:bonus"}]]
slot is required and is the usual mistake. इसे छोड़ दें और modifier हर स्लॉट में लागू होता है, इसलिए आपकी इन्वेंटरी में रखी तलवार वहीं रखे-रखे आपको बफ़ देती है।
मान्य स्लॉट: mainhand, offhand, head, chest, legs, feet, armor, body, any.
वैल्यू को वापस पढ़ना
/attribute @s minecraft:max_health get
लौटाता है base, प्रभावी कुल नहीं। modifiers सहित कुल प्राप्त करने के लिए, उपयोग करें execute store result on a scoreboard and read that.
इनमें से किसी को भी बनाएँ — स्लॉट सेट वाले item-component रूप सहित — इसमें: Entity & Combat Command Builder.