|
| 1 | + |
| 2 | +from ./particles import circle |
| 3 | + |
| 4 | +append function_tag load:load {"values":["fee:load"]} |
| 5 | +function fee:load: |
| 6 | + scoreboard objectives add fee dummy |
| 7 | + scoreboard players set #2 fee 2 |
| 8 | + |
| 9 | +advancement fee:throw_eye { |
| 10 | + "criteria": { |
| 11 | + "mainhand": { "trigger": "minecraft:using_item", "conditions": { |
| 12 | + "item": { "items": [ "minecraft:ender_eye" ]}, |
| 13 | + "player": [ |
| 14 | + { "condition": "minecraft:value_check", |
| 15 | + "value": { "type": "minecraft:score", "target": { "type": "minecraft:fixed", "name": ".gametime" }, "score": "fee" }, "range": { |
| 16 | + "min": { "type": "minecraft:score", "target": "this", "score": "fee" }, |
| 17 | + "max": 2147483647 }}, |
| 18 | + { "condition": "minecraft:entity_properties", "entity": "this", "predicate": { |
| 19 | + "equipment": { "mainhand": { "items": [ "minecraft:ender_eye" ]}}}}, |
| 20 | + { "condition": "minecraft:inverted", "term": { |
| 21 | + "condition": "minecraft:entity_properties", "entity": "this", "predicate": { |
| 22 | + "equipment": { "mainhand": { "nbt": "{}" }}}}}] |
| 23 | + }}, |
| 24 | + "offhand": { "trigger": "minecraft:using_item", "conditions": { |
| 25 | + "item": { "items": [ "minecraft:ender_eye" ]}, |
| 26 | + "player": [ |
| 27 | + { "condition": "minecraft:value_check", |
| 28 | + "value": { "type": "minecraft:score", "target": { "type": "minecraft:fixed", "name": ".gametime" }, "score": "fee" }, "range": { |
| 29 | + "min": { "type": "minecraft:score", "target": "this", "score": "fee" }, |
| 30 | + "max": 2147483647 }}, |
| 31 | + { "condition": "minecraft:entity_properties", "entity": "this", "predicate": { |
| 32 | + "equipment": { "offhand": { "items": [ "minecraft:ender_eye" ]}}}}, |
| 33 | + { "condition": "minecraft:inverted", "term": { |
| 34 | + "condition": "minecraft:entity_properties", "entity": "this", "predicate": { |
| 35 | + "equipment": { "mainhand": { "items": [ "minecraft:ender_eye" ]}}}}}, |
| 36 | + { "condition": "minecraft:inverted", "term": { |
| 37 | + "condition": "minecraft:entity_properties", "entity": "this", "predicate": { |
| 38 | + "equipment": { "offhand": { "nbt": "{}" }}}}}] |
| 39 | + }} |
| 40 | + }, |
| 41 | + "requirements": [[ "mainhand", "offhand" ]], |
| 42 | + "rewards": { "function": "fee:throw_eye" }} |
| 43 | +function fee:throw_eye: |
| 44 | + execute anchored eyes positioned ^ ^ ^ summon snowball function fee:setup/snowball |
| 45 | + if entity @s[advancements={fee:throw_eye={mainhand=true}},gamemode=!creative] item modify entity @s weapon.mainhand fee:remove_one |
| 46 | + if entity @s[advancements={fee:throw_eye={offhand=true}},gamemode=!creative] item modify entity @s weapon.offhand fee:remove_one |
| 47 | + playsound minecraft:entity.ender_eye.launch neutral @a ~ ~ ~ 0.5 0.42 |
| 48 | + advancement revoke @s only fee:throw_eye |
| 49 | + store result score @s fee schedule function fee:refresh_gametime 4t append: |
| 50 | + store result score .gametime fee time query gametime |
| 51 | + |
| 52 | +function fee:setup/snowball: |
| 53 | + data modify entity @s NoGravity set value 1b |
| 54 | + data modify entity @s Item set value {id:"minecraft:ender_eye",Count:1b} |
| 55 | + function fee:locate |
| 56 | + store result entity @s Pos[0] double 1 scoreboard players operation #location_x fee /= #denominator fee |
| 57 | + store result entity @s Pos[2] double 1 scoreboard players operation #location_z fee /= #denominator fee |
| 58 | + positioned 0 ~ 0 facing entity @s feet run tp @s ^ ^ ^10 |
| 59 | + store result entity @s Motion[0] double 0.028 run data get entity @s Pos[0] |
| 60 | + store result entity @s Motion[2] double 0.028 run data get entity @s Pos[2] |
| 61 | + tp @s ~ ~ ~ |
| 62 | + data modify entity @s Motion[1] set value 0.16d |
| 63 | + tag @s add fee.snowball |
| 64 | + execute summon marker function fee:setup/marker: |
| 65 | + ride @s mount @e[type=snowball,tag=fee.snowball,dx=0,limit=1] |
| 66 | + tag @s add fee.marker |
| 67 | + store result score @s fee schedule function fee:clean_up/ 81t append |
| 68 | + |
| 69 | +function fee:clean_up/: |
| 70 | + store result score .gametime fee time query gametime |
| 71 | + as @e[type=marker,tag=fee.marker] if score @s fee <= .gametime fee at @s function fee:clean_up/marker: |
| 72 | + scoreboard players set .should_drop fee 0 |
| 73 | + if predicate fee:should_drop scoreboard players set .should_drop fee 1 |
| 74 | + if score .should_drop fee matches 1 function fee:clean_up/drop: |
| 75 | + summon item ~ ~ ~ {Item:{"id":"minecraft:ender_eye",Count:1b}} |
| 76 | + if score .should_drop fee matches 0 function fee:clean_up/dont_drop: |
| 77 | + circle(2, 20, "reverse_portal", "in", 1, mode="normal") |
| 78 | + particle item ender_eye ~ ~ ~ 0.2 0.2 0.2 0.1 5 |
| 79 | + particle minecraft:portal ~ ~ ~ 0.2 0.2 0.2 0 20 |
| 80 | + playsound minecraft:entity.ender_eye.death neutral @a |
| 81 | + on vehicle kill @s |
| 82 | + kill @s |
| 83 | + |
| 84 | +item_modifier fee:remove_one { |
| 85 | + "function": "minecraft:set_count", |
| 86 | + "count": -1, |
| 87 | + "add": true } |
| 88 | + |
| 89 | +predicate fee:should_drop { |
| 90 | + "condition": "minecraft:random_chance", |
| 91 | + "chance": 0.8 } |
0 commit comments