Paste #50425: Untitled Paste

Date: 2018/10/27 03:40:57 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


TNTAntiBlockDestruction:
# As it turns out, TNT explosion rays can slip through the cracks where 2 blocks connect, damaging what-ever you may be hiding behind them.
# These connecting blocks can be obsidian, bedrock, or even glass.
# To alter the mechanics of lesser blast-resistant blocks, the mech block_resistance can be used to alter the blast resistance, or they can be filtered out with .filter[material.name.is[==].to[<your material here>]].
    type: world
    debug: false
    events:
        on entity explodes:
        - foreach <context.blocks>:
            - if <def[value].points_between[<context.location>].filter[material.name.is[==].to[red_stained_glass]].is[!=].to[null]>:
                # If the result is false, that means a blast-resistant block is between the explosion, and the block that would explode.
                # Build a list in the event of multiple blocks affected; then add to that same list.
                - define BlockList <def[blocklist].include[l@<def[value].simple>]||li@l@<def[value].simple>>

        # Debugging output.
        #- narrate "The list of blocks that are to blown up:" targets:<server.list_online_players>
        #- narrate "<context.blocks>" targets:<server.list_online_players>

        #- narrate "The list of blocks that are to be excluded from that first list:" targets:<server.list_online_players>
        #- narrate "<def[BlockList]>" targets:<server.list_online_players>

        #- narrate "The list of blocks, after the 2nd list has been excluded from the 1st list:" targets:<server.list_online_players>
        #- narrate "New context.blocks: <context.blocks.exclude[<def[BlockList]>]>" targets:<server.list_online_players>

        # Remove <def[BlockList]> from the <context.blocks> list.
        - determine <context.blocks.exclude[<def[BlockList]>]>