Luminescent Items:
affected_mobs: wolf|spider|cavespider|witch
luminescent_items: i@torch|i@glowstone|i@sea_lantern|i@redstone_torch_on|i@lava_bucket|i@jack_o_lantern|i@glowstone_dust|i@beacon
success max: 10
success min: 6
duration: d@2s-15s
light_time_update: d@12t
light_levels:
i@torch: 12
i@glowstone: 15
i@sea_lantern: 15
i@redstone_torch_on: 4
i@lava_bucket: 6
i@jack_o_lantern: 8
i@glowstone_dust: 5
i@beacon: 15
type: world
events:
on entity damages entity:
- if !<player.item_in_hand.simple> == i@torch queue clear
- define max "<script.yaml_keys[success max]>"
- define min "<script.yaml_keys[success min]>"
- define roll <util.random.int[0].to[<def[max]>]>
- if !<def[roll].is[or_more].than[<def[min]>]> queue clear
- define duration <script.yaml_keys[duration]>
- burn <context.entity> duration:%duration%
on entity targets:
- if !<script.yaml_keys[affected_mobs].contains[<context.entity.name>]> queue clear
- if !<context.reason.contains[closest_player]> queue clear
- - if !<context.target.item_in_hand.simple.is[===].to[i@torch]> queue clear
+ - if !<context.target.item_in_hand.simple.is[==].to[i@torch]> queue clear
- determine cancelled
on player holds item:
- define name <player.name>_light_update_queue
- if <queue.exists[<def[name]>]> queue clear
- run "Hand Item Light Update" def:<script>|<player> id:<def[name]>
Hand Item Light Update:
type: task
definitions: script|entity
speed: 0t
script:
- if !<server.list_scripts.contains[<def[script]||none]>]>
|| !<def[entity].is_spawned||false> {
- define message "Incorrect input for <script.name><&co> script<&co> <def[script]||none> entity<&co> <def[entity]||none>"
- event "Script Generates Error" context:queue|<queue>|script|<script>|message|<def[message]>
- queue clear
}
- while <def[script].yaml_keys[luminescent_items].contains[<def[entity].item_in_hand.simple>]> {
- wait <def[script].yaml_keys[light_time_update]>
- define location
<def[entity].location.simple.as_location>
#if didnt move, dont do anything
- if <def[location]> == <def[last_location]||no_last_location>
while next
#change lightning according to scripted values
- light
<def[location]>
<def[script].yaml_keys[light_levels.<def[entity].item_in_hand.simple>]>
duration:d@1m
#reset old lightning if last_location exists
- if <def[last_location].exists||false>
light
<def[last_location]>
reset
#define last_location as this location
- define last_location
<def[location]>
}
- if <def[last_location].exists||false>
light
<def[last_location]>
reset