Paste #48377: Untitled Paste

Date: 2018/07/04 10:54:59 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


"Heavens Handler":
    type: world
    debug: true
    events:
        on player right clicks quartz_block with flint_and_steel in prosperus:
        - if <context.location.add[0,1,0].material> != m@air
        {
            - queue clear
        }
        - if <context.location.add[1,0,0].material> == m@quartz_block && <context.location.add[-1,0,0].material> == m@quartz_block
        {
            - define axis-pos l@1,0,0
            - define axis-neg l@-1,0,0
            - define axis-data 1
        }
        else if <context.location.add[0,0,1].material> == m@quartz_block && <context.location.add[0,0,-1].material> == m@quartz_block
        {
            - define axis-pos l@0,0,1
            - define axis-neg l@0,0,-1
            - define axis-data 2
        }
        else
        {
            - queue clear
        }
        - define origin <context.location.add[0,1,0]>
        - define node <def[origin]>
        - define air-list li@
        - define y-list li@
        - define y-max <def[origin].y>
        - define y-min <def[origin].y>
        - define x-max <def[origin].x>
        - define x-min <def[origin].x>
        - define z-max <def[origin].z>
        - define z-min <def[origin].z>
        - while <def[node].material.is[==].to[m@air]>
        {
            - define air-list <def[air-list].include[<def[node]>]>
            - define y-list <def[y-list].include[<def[node]>]>
            - define y-max <def[y-max].max[<def[node].y>]>
            - define y-min <def[y-min].min[<def[node].y>]>
            - define node <def[node].add[0,1,0]>
        }
        - if <def[node].material> != m@quartz_block
        {
            - queue clear
        }
        else
        {
            - foreach <def[y-list]>
            {
                - define node <def[value]>
                - while <def[node].material.is[==].to[m@air]>
                {
                    - define air-list <def[air-list].include[<def[node]>]>
                    - if <def[axis-data]> == 1
                    {
                        - define x-max <def[x-max].max[<def[node].x>]>
                        - define x-min <def[x-min].min[<def[node].x>]>
                    }
                    - if <def[axis-data]> == 2
                    {
                        - define z-max <def[z-max].max[<def[node].z>]>
                        - define z-min <def[z-min].min[<def[node].z>]>
                    }
                    - define node <def[node].add[<def[axis-pos]>]>
                }
                - if <def[node].material> != m@quartz_block
                {
                    - queue clear
                }
                - define node <def[value]>
                - while <def[node].material.is[==].to[m@air]>
                {
                    - define air-list <def[air-list].include[<def[node]>]>
                    - if <def[axis-data]> == 1
                    {
                        - define x-max <def[x-max].max[<def[node].x>]>
                        - define x-min <def[x-min].min[<def[node].x>]>
                    }
                    - if <def[axis-data]> == 2
                    {
                        - define z-max <def[z-max].max[<def[node].z>]>
                        - define z-min <def[z-min].min[<def[node].z>]>
                    }
                    - define node <def[node].add[<def[axis-neg]>]>
                }
                - if <def[node].material> != m@quartz_block
                {
                    - queue clear
                }
            }
        }
        - modifyblock <def[air-list]> m@end_gateway,<def[axis-data]> no_physics
#        - announce to_console "cu@<def[x-min].add[<def[axis-neg].x>]>,<def[y-min].add[-1]>,<def[z-min].add[<def[axis-neg].z>]>,prosperus|<def[x-max].add[<def[axis-pos].x>]>,<def[y-max].add[1]>,<def[z-max].add[<def[axis-pos].z>]>,prosperus as:heavens-portal-<util.random.duuid>"
        - note cu@<def[x-min].add[<def[axis-neg].x>]>,<def[y-min].add[-1]>,<def[z-min].add[<def[axis-neg].z>]>,prosperus|<def[x-max].add[<def[axis-pos].x>]>,<def[y-max].add[1]>,<def[z-max].add[<def[axis-pos].z>]>,prosperus as:heavens-portal-<util.random.duuid>
        on player breaks end_gateway:
        - if <context.location.cuboids.contains_text[heavens-portal]>
        {
            - define notable <context.location.cuboids.filter[notable_name.starts_with[heavens-portal]].get[1]>
            - modifyblock <def[notable].blocks[end_gateway]> m@air
            - note remove as:<def[notable].notable_name>
        }
        on player breaks quartz_block:
        - if <context.location.cuboids.contains_text[heavens-portal]>
        {
            - define notable <context.location.cuboids.filter[notable_name.starts_with[heavens-portal]].get[1]>
            - modifyblock <def[notable].blocks[end_gateway]> m@air
            - flag server <context.cuboids.filter[notable_name.starts_with[heavens-portal]].get[1].notable_name>:!
            - note remove as:<def[notable].notable_name>

        }
        on player enters notable cuboid:
        - if <context.cuboids.contains_text[heavens-portal]>
        {
            - define target-location l@<context.from.x.div[2].as_int>,<context.from.y.as_int>,<context.from.z.div[2].as_int>,heavens
            - announce to_console "def target-location: <def[target-location]>"
            - define target-material <def[target-location].material>
            - announce to_console "def target-material: <def[target-material]>"
            - define portal <context.cuboids.filter[notable_name.starts_with[heavens-portal]].get[1]>
            - announce to_console "def portal: <def[portal]>"
            - define portal-exit <context.cuboids.filter[notable_name.starts_with[heavens-portal]].get[1].notable_name>
            - announce to_console "def portal-exit: <def[portal-exit]>"
            - define portal-unsafe-exit <def[portal-exit]>-unsafe
            - announce to_console "def portal-unsafe-exit: <def[portal-unsafe-exit]>"
            - if <server.has_flag[<def[portal-exit]>]>
            {
                - teleport <server.flag[<def[portal-exit]>]>
                - queue clear
            }
            - if <server.has_flag[<def[portal-unsafe-exit]>]>
            {
                - teleport <server.flag[<def[portal-unsafe-exit]>]>
                - announce to_console "teleport <server.flag[<def[portal-unsafe-exit]>]>"
                - flag player player-gliding-chestplate:<player.equipment.chestplate>
                - announce to_console "Giving player temporary elytra, player chestplate was <player.equipment.chestplate>"
                - wait 10t
                - equip <player> chest:elytra
                - adjust <player> gliding:true
                - queue clear
            }
            - if <def[target-material]> == m@air && <def[target-location].add[0,-1,0].material> != m@air && <def[target-location].add[0,1,0].material> == m@air
            {
                - announce to_console "Initial block is safe"
                - define teleport-location l@<context.from.x.div[2]>,<context.from.y>,<context.from.z.div[2]>,heavens
                - teleport <def[teleport-location]>
                - announce to_console "teleport <def[teleport-location]>"
                - flag server <def[portal-exit]>:<def[teleport-location]>
                - queue clear
            }
            - define size 20
            - if <def[target-location].find.surface_blocks.within[<def[size]>].size> >= 1
            {
                - announce to-console "Finding safe spot"
                - define safe-spot <def[target-location].find.surface_blocks.within[<def[size]>].random>
                - announce to_console "Safe spot: <def[safe-spot]>"
                - teleport <def[safe-spot]>
                - announce to_console "teleport <def[safe-spot]>"
                - flag server <def[portal-exit]>:<def[safe-spot]>
                - queue clear
            }
            else
            {
                - announce to_console "No safe spot, let's glide!"
                - flag server <def[portal-unsafe-exit]>:l@<context.from.x.div[2]>,90,<context.from.z.div[2]>,heavens
                - teleport l@<context.from.x.div[2]>,90,<context.from.z.div[2]>,heavens
                - announce to_console "teleport l@<context.from.x.div[2]>,90,<context.from.z.div[2]>,heavens"
                - flag player player-gliding-chestplate:<player.equipment.chestplate>
                - announce to_console "Giving player temporary elytra, player chestplate was <player.equipment.chestplate>"
                - equip <player> chest:elytra
                - adjust <player> gliding:true
            }
            - determine cancelled
        }
        on player stops gliding in heavens:
        - if <player.has_flag[player-gliding-chestplate]>
        {
            - equip <player> chest:<flag.player[player-gliding-chestplate]>
            - flag player player-gliding-chestplate:!
        }
        on player clicks in inventory:
        - if <player.has_flag[player-gliding-chestplate]> && <context.slot> == 39
        {
            - narrate "<&c>You can change your chestplate after landing!"
            - determine cancelled
        }
#"Portal Gliding Handler":
#    type: world
#    debug: false
#    events:
#        on player stops gliding in heavens:
#        - if <player.has_flag[portal-exiter]>
#        {
##            - flag player portal-exiter:!
#            - determine cancelled
#        }
##        - determine cancelled
#        on player starts gliding in heavens:
#        - if <player.has_flag[portal-exiter]>
#        {
##            - flag player portal-exiter:!
#            - determine cancelled:false
#        }