Paste #69653: Untitled Paste

Date: 2020/05/26 05:26:55 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


woodcutting_listener:
    type: world
    events:
        on player places acacia_log:
        - flag server woodcutting.player_made_trees.<context.location.simple>
        - announce flagged
        on player left clicks *_log with item:
        - if !<context.item.has_script>:
            - stop
        #choose axe type
        - define axes:|:<item[bronze_axe]>|<item[iron_axe]>|<item[steel_axe]>|<item[branite_axe]>|<item[molmek_axe]>|<item[endos_axe]>
        - if !<[axes].contains_any[<context.item>]>:
            - stop

        #check if man made log
        - if <server.has_flag[woodcutting.player_made_trees.<context.location.simple>]>:
            - stop

         #choose log
        - if !<player.has_flag[woodcutting.tree.<context.location.simple>]>:
            - if <player.has_flag[woodcuting.is_chopping]>:
                - narrate "<&c><&l>I'm already chopping some other tree."
                - stop
            - choose <context.location.material.name>:
                - case acacia_log:
                    - flag player woodcutting.is_chopping
                    - flag player woodcutting.tree.<context.location.simple>
                    - flag player woodcutting.chop_count:0
                    - spawn hologram <player.location.below[1].forward[1]> save:woodcutting_display
                    - adjust <entry[woodcutting_display].spawned_entity> custom_name_visible:true
                    - adjust <entry[woodcutting_display].spawned_entity> custom_name:<&4>0<&pc>
                    - flag player woodcutting.entity:<entry[woodcutting_display].spawned_entity>
                - case acacia_wood:
                    - flag player woodcutting.tree.<context.location.simple>
                    - flag player woodcutting.chop_count:0
                    - spawn hologram <player.location.below[1].forward[1]> save:woodcutting_display
                    - adjust <entry[woodcutting_display].spawned_entity> custom_name_visible:true
                    - adjust <entry[woodcutting_display].spawned_entity> custom_name:<&4>0<&pc>
                    - flag player woodcutting.entity:<entry[woodcutting_display].spawned_entity>
                - default:
                    - stop


        #begin the felling process

        - if <player.has_flag[woodcutting.cooldown]>:
            - narrate "<&c>You swing your axe and miss."
            - playsound entity_llama_spit <player.location> pitch:-2
            - stop

        - choose <context.item.script.name>:
            - case bronze_axe:
                - flag player woodcutting.cooldown duration:1s
                - flag player woodcutting.chop_count:++ duration:1m
                - flag player woodcuttingxp:+:.30
                - actionbar "<&a><&l>+ .30 XP"
                - playsound block_wood_break <player.location> pitch:3
                - choose <player.flag[woodcutting.chop_count]>:
                    - case 1:
                        - adjust <player.flag[woodcutting.entity]> custom_name:<&c><&l>20<&pc>
                        - playeffect block_crack <player.location.forward[2]> special_data:acacia_log quantity:150
                    - case 2:
                        - adjust <player.flag[woodcutting.entity]> custom_name:<&6><&l>40<&pc>
                        - playeffect block_crack <player.location.forward[2]> special_data:acacia_log quantity:150
                    - case 3:
                        - playeffect block_crack <player.location.forward[2]> special_data:acacia_log quantity:150
                        - adjust <player.flag[woodcutting.entity]> custom_name:<&e><&l>60<&pc>
                    - case 4:
                        - playeffect block_crack <player.location.forward[2]> special_data:acacia_log quantity:150
                        - adjust <player.flag[woodcutting.entity]> custom_name:<&2><&l>80<&pc>
                    - case 5:

                        - playeffect block_crack <player.location.forward[2]> special_data:acacia_log quantity:150
                        - adjust <player.flag[woodcutting.entity]> custom_name:<&a><&l>100<&pc>
                        - playsound block_wood_break <player.location> pitch:-3
                        - if <proc[woodcuttinglevel_process].context[<player>]>:
                            - flag player woodcuttinglvl <player.flag[woodcuttinglvl].add[1]>
                            - playsound entity_experience_orb_pickup <player.location> pitch:-1
                            - toast "Congratulations your woodcutting level is now <player.flag[woodcuttinglvl]>!"
                        - flag player woodcutting.tree.<context.location.simple>:!
                        - remove <player.flag[woodcutting.entity]>
                        - flag player woodcutting.entity:!
                        - flag player woodcutting.chop_count:!
                        - flag player woodcutting.is_chopping:!


                        - define base_location <context.location>
                        - define leaves:|:acacia_leaves|birch_leaves|dark_oak_leaves|jungle_leaves|oak_leaves|spruce_leaves
                        - define wood:|:acacia_wood|birch_wood|dark_oak_wood|jungle_wood|oak_wood|spruce_wood
                        - define count 1
                        - while <[base_location].above[<[count]>].material.name> != air:
                            - define base_location <[base_location].above[<[count]>]>
                            - define count:++
                            - define logs_and_leaves:|:<[base_location].find.blocks[<context.location.material.name>|<[wood].separated_by[|]>|<[leaves].separated_by[|]>].within[4]>
                            - define processes:++
                            - if <[loop_index]> > 1:
                                - define logs_and_leaves:|:<[base_location].above[3].find.blocks[<context.location.material.name>|<[wood].separated_by[|]>|<[leaves].separated_by[|]>].within[7]>
                        - narrate "Processed <[processes]> loops."
                        - wait 1s
                        - narrate "Block count:"
                        - wait 1s
                        - narrate <[logs_and_leaves].size>
                        - wait 1s
                        - narrate "Block locations to remove:"
                        - wait 1s
                        - narrate <[logs_and_leaves].formatted>
                        - foreach <[logs_and_leaves]>:
                            - showfake glowstone <[value]> duration:10s