#Simplifying Code

1 messages · Page 1 of 1 (latest)

stiff fulcrum
#

I am making a code to teleport players, but does not teleport them if there is a block between the teleport location and the player. Does this code work, and is there a simpler way to write it?

#
    if player's held item is diamond sword of sharpness 7 and unbreaking 5 and looting 4 and smite 6 named "&5Ender Falchion":
        if {endertp.%player%} is not set:
            set {tp1.%player%} to 1 block infront of player
            set {tp2.%player%} to 2 block infront of player
            set {tp3.%player%} to 3 block infront of player
            set {tp4.%player%} to 4 block infront of player
            set {tp5.%player%} to 5 block infront of player
            if {tp1.%player%} is not air:
                send "&5You cannot telerport through blocks!" to player
            else if {tp2.%player%} is not air:
                send "&5You cannot telerport through blocks!" to player
            else if {tp3.%player%} is not air: 
                send "&5You cannot telerport through blocks!" to player
            else if {tp4.%player%} is not air:
                send "&5You cannot telerport through blocks!" to player
            else if {tp5.%player%} is not air:
                send "&5You cannot telerport through blocks!" to player
            else:
                set {endertptime.%player%} to 10
                set {endertp.%player%} to true
                set {tplocation.%player%} to 5 blocks infront of player
                set yaw of {tplocation.%player%} to yaw of player
                teleport player to {tplocation.%player%}
                send "&5Teleported." to player
                loop 10 times:
                    wait 1 second
                    remove 1 from {endertptime.%player%}
                clear {endertp.%player%}
        else:
            send "&5You need to wait %{endertptime.%player%}% seconds to teleport again!" to player```
silk otter
#

Tp 1-5 are all checking the same block

rancid pawn
#
        set {_target-dist} to (distance between player's target block and player's head) ? 100
        set {_landing} to player's head ~ (spherical vector 5, player's yaw, player's pitch)
        if {_target-dist} <= (distance between {_landing} and player's head):
            send "error"
        else:
            if block below {_landing} is air:
                set y coord of {_landing} to y coord of block below {_landing}
            teleport player to {_landing}

slightly better teleportation code

stiff fulcrum
#

uh frick

#

I just copy pasted thats why