ThrowableAxe.sk

Created by YoshYz

Just so you know, we don't know the file format for every file. If it's just a bunch of random characters, it's probably a .zip or .jar.

#  _____   _                                         _       _             _                  
# |_   _| | |__    _ __    ___   __      __   __ _  | |__   | |   ___     / \    __  __   ___ 
#   | |   | '_ \  | '__|  / _ \  \ \ /\ / /  / _` | | '_ \  | |  / _ \   / _ \   \ \/ /  / _ \
#   | |   | | | | | |    | (_) |  \ V  V /  | (_| | | |_) | | | |  __/  / ___ \   >  <  |  __/
#   |_|   |_| |_| |_|     \___/    \_/\_/    \__,_| |_.__/  |_|  \___| /_/   \_\ /_/\_\  \___|
#

#Autohor: YoshYz
#Version: 1.1.1b 

#==========================================================================================================#
# -------------------------------------------------------------------------------------------------------- #
#                                              OPTIONS                                                     #
# -------------------------------------------------------------------------------------------------------- #
#==========================================================================================================#

options:
#Main Things:
#Options:
    reload_sound: BLOCK_IRON_TRAPDOOR_OPEN
    shoot_sound: ENTITY_SKELETON_SHOOT
    hit_sound: ENTITY_VILLAGER_HURT
    fail_sound: ENTITY_SHULKER_SHOOT
    pickup_sound: ENTITY_PAINTING_BREAK
#Name things:
    name_axe: &aThrowable Axe
    reloading_axe: &8[&c[reload]&8]

#==========================================================================================================#
# -------------------------------------------------------------------------------------------------------- #
#                                             MAIN CODE                                                    #
# -------------------------------------------------------------------------------------------------------- #
#==========================================================================================================#

on rightclick with any axe:
    if player has permission "throwableaxe.use":
        if {taxe::reload::%uuid of player%} isn't set:
            set {taxe::reload::%uuid of player%} to 0
        if {taxe::reload::%uuid of player%} is 0:
            while player's held item is player's tool:
                while {taxe::reload::%uuid of player%} < 10:
                    set {_name-fix} to player's tool
                    add 1 to {taxe::reload::%uuid of player%}
                    set {_reloading} to "{@reloading_axe}"
                    set {_percent} to ( {taxe::reload::%uuid of player%}*100 ) / 10
                    replace all "[reload]" in {_reloading} with "%{_percent}%%%"
                    set name of player's held item to "{@name_axe} %{_reloading}%"
                    play sound "{@reload_sound}" to player with volume 2 and pitch 2
                    wait 2 ticks
                    if player's held item isn't {_name-fix}:
                        remove {_name-fix} from player's inventory
                        add {_name-fix} named "{@name_axe}" to player's inventory
                        set {taxe::reload::%uuid of player%} to 0
                        stop                        						
                set name of player's held item to "{@name_axe}"
                set {_tool} to player's tool
                drop player's tool at location 1 blocks upwards and 1 blocks forwards player
                remove player's tool from player's inventory				
                set {taxe::reload::%uuid of player%} to 0
                set {_axe} to last dropped item
                if {_tool} is a wooden axe:
                    push {_axe} in direction of player at speed ( ( 8 - 1 ) + 1.2 ) / 7
                    set {_power} to 1
                if {_tool} is a stone axe:
                    push {_axe} in direction of player at speed ( ( 8 - 2 ) + 1.4 ) / 8
                    set {_power} to 2
                if {_tool} is a golden axe:
                    push {_axe} in direction of player at speed ( ( 8 - 3 ) + 1.6 ) / 9
                    set {_power} to 3
                if {_tool} is a iron axe:
                    push {_axe} in direction of player at speed ( ( 8 - 4 ) + 1.8 ) / 10 
                    set {_power} to 4
                if {_tool} is a diamond axe:
                    push {_axe} in direction of player at speed ( ( 8 - 5 ) + 2 ) / 10
                    set {_power} to 5
                wait 2 ticks
                push {_axe} upwards at speed 0.2
                push {_axe} in direction of player at speed 0.5
                loop 12 times:
                    loop all entities in radius 1 around {_axe}:
                        if loop-entity is set:
                            if loop-entity is alive:
                                if loop-entity isn't the player:
                                    set {_hit} to true
                                    play sound "{@hit_sound}" to player with volume 2 and pitch 2
                                    if loop-entity is a player:
                                        play sound "{@hit_sound}" to loop-entity with volume 2 and pitch 2
                                    if distance between player and loop-entity >= 12:
                                        make player damage loop-entity by {_power}*2
                                    else:
                                        make player damage loop-entity by {_power}
                    wait 2 ticks
                if {_hit} isn't set:
                    play sound "{@fail_sound}" to player with volume 2 and pitch 2
                stop
				
on drop of any axe:
    if {taxe::reload::%uuid of player%} > 0:
        cancel the event  
				
on pickup of any axe:      
    if event-player has permission "throwableaxe.use":
        play sound "{@pickup_sound}" to event-player with volume 2 and pitch 2