MrGarretto's One-Command Creations

Giving the modded minecraft feeling to vanilla

Table Tennis command (1.10.2)
About this command
This command allows you to play table tennis (A.K.A. Ping Pong)! This version of the command is updated for Minecraft version 1.10.2
Show source commands

# Install messages
INIT:tellraw @a[r=200] {"color":"dark_aqua","text":"Table Tennis (A.K.A. Ping Pong) has been installed!"}
INIT:tellraw @a[r=200] {"color":"red","text":"Created by MrGarretto"}
INIT:tellraw @a[r=200] {"text":"Click for MrGarretto on Youtube","color":"dark_red","clickEvent":{"action":"open_url","value":"https://www.youtube.com/c/JustMrGarretto"}}

# Custom Crafting
INIT:scoreboard objectives add TNi dummy
scoreboard players set @e TNi 1 {Item:{id:minecraft:wooden_pressure_plate},OnGround:1b}
scoreboard players set @e TNi 2 {Item:{id:minecraft:stick},OnGround:1b}
execute @e[score_TNi_min=1,score_TNi=1] ~ ~ ~ execute @e[r=1,score_TNi_min=2,score_TNi=2] ~ ~ ~ summon Item ~ ~ ~ {Item:{id:minecraft:wooden_axe,Count:1,tag:{display:{Name:"Table Tennis Paddle"}}}}
execute @e[score_TNi_min=1,score_TNi=1] ~ ~ ~ execute @e[r=1,score_TNi_min=2,score_TNi=2] ~ ~ ~ kill @e[r=3,score_TNi_min=1,score_TNi=2]
scoreboard players set @e TNi 3 {Item:{id:minecraft:repeater},OnGround:1b}
scoreboard players set @e TNi 4 {Item:{id:minecraft:heavy_weighted_pressure_plate},OnGround:1b}
execute @e[score_TNi_min=3,score_TNi=3] ~ ~ ~ execute @e[r=1,score_TNi_min=4,score_TNi=4] ~ ~ ~ summon Item ~ ~ ~ {Item:{id:minecraft:sticky_piston,Count:1,tag:{display:{Name:"Table Tennis Table"}}}}
execute @e[score_TNi_min=3,score_TNi=3] ~ ~ ~ execute @e[r=1,score_TNi_min=4,score_TNi=4] ~ ~ ~ particle smoke ~ ~ ~ 0 0 0 0.1 100
execute @e[score_TNi_min=3,score_TNi=3] ~ ~ ~ execute @e[r=1,score_TNi_min=4,score_TNi=4] ~ ~ ~ kill @e[r=3,score_TNi_min=3,score_TNi=4]
scoreboard players set @e TNi 5 {Item:{id:minecraft:wooden_axe,tag:{display:{Name:"Table Tennis Paddle"}}},OnGround:1b}
scoreboard players set @e TNi 6 {Item:{id:minecraft:sticky_piston,tag:{display:{Name:"Table Tennis Table"}}},OnGround:1b}
execute @e[score_TNi_min=5,score_TNi=5] ~ ~ ~ execute @e[r=1,score_TNi_min=6,score_TNi=6] ~ ~ ~ summon Item ~ ~ ~ {Item:{id:minecraft:spawn_egg,Count:1,tag:{EntityTag:{id:"Creeper"},display:{Name:"Table_Tennis"},ench:[{id:1,lvl:1}]}}}
execute @e[score_TNi_min=5,score_TNi=5] ~ ~ ~ execute @e[r=1,score_TNi_min=6,score_TNi=6] ~ ~ ~ particle crit ~ ~ ~ 0 0 0 0.1 100
execute @e[score_TNi_min=5,score_TNi=5] ~ ~ ~ execute @e[r=1,score_TNi_min=6,score_TNi=6] ~ ~ ~ kill @e[r=3,score_TNi_min=5,score_TNi=6]
scoreboard players set @e TNi 7 {Item:{id:minecraft:wooden_button},OnGround:1b}
scoreboard players set @e TNi 8 {Item:{id:minecraft:dye},OnGround:1b}
execute @e[score_TNi_min=7,score_TNi=7] ~ ~ ~ execute @e[r=1,score_TNi_min=8,score_TNi=8] ~ ~ ~ summon Item ~ ~ ~ {Item:{id:minecraft:snowball,Count:1,tag:{display:{Name:"Ping Pong Ball"}}}}
execute @e[score_TNi_min=7,score_TNi=7] ~ ~ ~ execute @e[r=1,score_TNi_min=8,score_TNi=8] ~ ~ ~ particle cloud ~ ~ ~ 0 0 0 0.1 100
execute @e[score_TNi_min=7,score_TNi=7] ~ ~ ~ execute @e[r=1,score_TNi_min=8,score_TNi=8] ~ ~ ~ kill @e[r=3,score_TNi_min=7,score_TNi=8]

# Placing the table tennis
scoreboard players tag @e[type=Creeper,name=Table_Tennis] add TNs
execute @e[tag=TNs] ~ ~ ~ summon ArmorStand ~ ~ ~ {CustomName:TBTNCenter,Marker:1,Invisible:1,NoGravity:1}
# TRACK execute @e[tag=TNs] ~ ~ ~ summon ArmorStand ~ ~ ~ {CustomName:TBTNTrack,Marker:1,Invisible:1,NoGravity:1}
# Banner armor stands
# Side 1
execute @e[tag=TNs] ~ ~-0.2 ~1 summon ArmorStand ~ ~ ~ {DisabledSlots:1,Invisible:1,CustomName:TBTNFlat,ArmorItems:[{},{},{},{id:banner,Count:1,tag:{BlockEntityTag:{Base:15,Patterns:[{Pattern:ss,Color:4},{Pattern:ls,Color:4},{Pattern:rs,Color:4}]}}}],Pose:{Head:[-90f,0f,0f]},NoGravity:1}
execute @e[tag=TNs] ~-0.75 ~-0.2 ~1 summon ArmorStand ~ ~ ~ {DisabledSlots:1,Invisible:1,CustomName:TBTNFlat,NoGravity:1,ArmorItems:[{},{},{},{id:banner,tag:{BlockEntityTag:{Base:4,Patterns:[]}}}],Pose:{Head:[-90f,0f,0f]}}
execute @e[tag=TNs] ~0.75 ~-0.2 ~1 summon ArmorStand ~ ~ ~ {DisabledSlots:1,Invisible:1,CustomName:TBTNFlat,NoGravity:1,ArmorItems:[{},{},{},{id:banner,tag:{BlockEntityTag:{Base:4,Patterns:[]}}}],Pose:{Head:[-90f,0f,0f]}}
# Side 2
execute @e[tag=TNs] ~ ~-0.2 ~ summon ArmorStand ~ ~ ~ {DisabledSlots:1,Invisible:1,CustomName:TBTNFlat,ArmorItems:[{},{},{},{id:banner,Count:1,tag:{BlockEntityTag:{Base:15,Patterns:[{Pattern:ss,Color:4},{Pattern:ls,Color:4},{Pattern:rs,Color:4}]}}}],Pose:{Head:[-90f,180f,0f]},NoGravity:1}
execute @e[tag=TNs] ~-0.75 ~-0.2 ~ summon ArmorStand ~ ~ ~ {DisabledSlots:1,Invisible:1,CustomName:TBTNFlat,NoGravity:1,ArmorItems:[{},{},{},{id:banner,tag:{BlockEntityTag:{Base:4,Patterns:[]}}}],Pose:{Head:[-90f,180f,0f]}}
execute @e[tag=TNs] ~0.75 ~-0.2 ~ summon ArmorStand ~ ~ ~ {DisabledSlots:1,Invisible:1,CustomName:TBTNFlat,NoGravity:1,ArmorItems:[{},{},{},{id:banner,tag:{BlockEntityTag:{Base:4,Patterns:[]}}}],Pose:{Head:[-90f,180f,0f]}}
execute @e[tag=TNs] ~ ~ ~-5 execute @e[name=TBTNFlat,c=3] ~ ~ ~ summon ArmorStand ~ ~-0.7 ~0.76 {Invisible:1,CustomName:TBTNNet,NoGravity:1,ArmorItems:[{},{},{},{id:glass_pane,Count:1,tag:{display:{Name:"TBTNNet"}}}]}
execute @e[tag=TNs] ~ ~ ~ summon ArmorStand ~ ~ ~-1.5 {CustomName:TBTNp1,Invisible:1,Marker:1,NoGravity:1,Tags:["TNpy"]}
execute @e[tag=TNs] ~ ~ ~ summon ArmorStand ~ ~ ~2.5 {CustomName:TBTNp2,Invisible:1,Marker:1,NoGravity:1,Rotation:[180f,0f],Tags:["TNpy"]}
execute @e[tag=TNs] ~ ~ ~ summon ArmorStand ~ ~ ~ {CustomName:TBTNr1,Invisible:1,Marker:1,NoGravity:1,Tags:["TNr"]}
execute @e[tag=TNs] ~ ~ ~ summon ArmorStand ~ ~ ~ {CustomName:TBTNr2,Invisible:1,Marker:1,NoGravity:1,Tags:["TNr"]}
execute @e[tag=TNs] ~ ~ ~ summon ArmorStand ~ ~ ~ {CustomName:TBTNr3,Invisible:1,Marker:1,NoGravity:1,Tags:["TNr"]}
execute @e[tag=TNs] ~ ~ ~ fill ~-1 ~ ~-1 ~1 ~ ~-1 iron_bars
execute @e[tag=TNs] ~ ~ ~ fill ~-1 ~ ~2 ~1 ~ ~2 iron_bars
execute @e[tag=TNs] ~ ~ ~ fill ~-1 ~ ~ ~1 ~ ~1 barrier
execute @e[tag=TNs] ~ ~ ~ execute @e[name=TBTNp1] ~ ~ ~ summon ArmorStand ~0.3 ~-0.8 ~ {CustomName:TBTNPaddle,NoGravity:1,Tags:["TNpdl","TNpi1"]}
execute @e[tag=TNs] ~ ~ ~ execute @e[name=TBTNp2] ~ ~ ~ summon ArmorStand ~-0.3 ~-0.8 ~ {CustomName:TBTNPaddle,NoGravity:1,Rotation:[180f,0f],Tags:["TNpdl","TNpi2"]}
execute @e[tag=TNs] ~ ~ ~ entitydata @e[name=TBTNPaddle] {Invisible:1,DisabledSlots:1,HandItems:[{id:wooden_axe},{}]}
# Remove the creeper after it has been used everywhere it was needed
tp @e[tag=TNs] ~ ~-500 ~

# Pick up the table
INIT:scoreboard objectives add TNpu dummy
scoreboard players reset @a TNpu
scoreboard players set @a TNpu 1 {Inventory:[{id:minecraft:glass_pane,tag:{display:{Name:"TBTNNet"}}}]}
execute @a[score_TNpu_min=1] ~ ~ ~ kill @e[type=ArmorStand,r=7]
execute @a[score_TNpu_min=1] ~ ~ ~ summon Item ~ ~ ~ {Item:{id:"minecraft:spawn_egg",Count:1,tag:{EntityTag:{id:"Creeper"},display:{Name:"Table_Tennis"},ench:[{id:1,lvl:1}]}}}
execute @a[score_TNpu_min=1] ~ ~ ~ fill ~-5 ~-5 ~-5 ~5 ~5 ~5 air 0 replace barrier
execute @a[score_TNpu_min=1] ~ ~ ~ fill ~-5 ~-5 ~-5 ~5 ~5 ~5 air 0 replace iron_bars
clear @a[score_TNpu_min=1] glass_pane 0 1 {display:{Name:"TBTNNet"}}

# Keep track of players who are playing
scoreboard players reset @e TNpl
execute @e[name=TBTNp1] ~ ~ ~-0.5 scoreboard players set @e[type=!ArmorStand,c=1,r=1] TNpl 1
execute @e[name=TBTNp2] ~ ~ ~ scoreboard players set @e[type=!ArmorStand,c=1,r=1] TNpl 2

# Moving the paddles
# Player 1's paddle
execute @a[rym=-80,ry=-31] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 1
execute @a[rym=-30,ry=-21] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 2
execute @a[rym=-20,ry=-11] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 3
execute @a[rym=-10,ry=-1] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 4
execute @a[rym=0,ry=9] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 5
execute @a[rym=10,ry=19] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 6
execute @a[rym=20,ry=29] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 7
execute @a[rym=30,ry=39] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 8
execute @a[rym=40,ry=99] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 9

# Player 2's paddle
execute @a[rym=100,ry=149] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 9
execute @a[rym=150,ry=159] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 8
execute @a[rym=160,ry=169] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 7
execute @a[rym=170,ry=179] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 6
execute @a[rym=-180,ry=-171] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 5
execute @a[rym=-170,ry=-161] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 4
execute @a[rym=-160,ry=-151] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 3
execute @a[rym=-150,ry=-141] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 2
execute @a[rym=-140,ry=-100] ~ ~ ~ scoreboard players set @e[tag=TNpdl,c=1,r=2] TNpl 1

# Villager AI (Make villagers able to play ping pong!)
INIT:scoreboard objectives add TNai dummy
INIT:scoreboard objectives add TNam dummy
/execute @e[score_TNpl_min=1] ~ ~ ~ scoreboard players add @e[type=Villager,r=1] TNai 1
/scoreboard players set @e[score_TNai_min=19] TNai 1
/scoreboard players set @e[tag=TNpy] TNai -1
/execute @e[score_TNai_min=1] ~ ~ ~ tp @e[score_TNai_min=1,c=1,r=1] @e[score_TNai=-1,c=1,r=2]
# Update the villager's paddle to the ball location every time TNai for the villager reaches the number specified above (originally was 15, and may still be)
/execute @e[type=Villager,score_TNai=1] ~ ~ ~ scoreboard players operation @e[type=ArmorStand,name=TBTNPaddle,c=1,r=2] TNpl = @e[score_TNbl_min=1,c=1,r=8] TNbl
/execute @e[type=Villager,score_TNai=1] ~ ~ ~ scoreboard players operation @e[score_TNai_min=1,c=1,r=1] TNam = @e[score_TNbl_min=1,c=1,r=8] TNbl
# Still force the paddle to be controlled when before the villager is allowed to update it's position, but don't let the paddle move
/execute @e[type=Villager,score_TNai_min=2] ~ ~ ~ scoreboard players operation @e[type=ArmorStand,name=TBTNPaddle,c=1,r=2] TNpl = @e[type=Villager,score_TNai_min=2,c=1,r=1] TNam
# Pushing the villager away from the ping pong table
INIT:scoreboard objectives add TNsn stat.crouchOneCm
/execute @a[score_TNsn_min=1] ~ ~ ~ tp @e[type=Villager,score_TNai_min=1,r=2] ~3 ~ ~
/execute @a[score_TNsn_min=1] ~ ~ ~ scoreboard players reset @e[type=Villager,score_TNai_min=1,r=3] TNai
/scoreboard players reset @a TNsn
# Make the villagers move a bit back from the table so that their paddles aren't hidden inside them
/tp @e[score_TNai_min=1,score_TNpl=1] ~ ~ ~-0.5
/tp @e[score_TNai_min=1,score_TNpl_min=2] ~ ~ ~0.5

# Serving the ball
scoreboard players set @e[type=Item] TNi 9 {Item:{id:minecraft:snowball,tag:{display:{Name:"Ping Pong Ball"}}}}
execute @e[score_TNi_min=9,score_TNi=9] ~ ~ ~ execute @e[name=TBTNPaddle,r=2,c=1] ~ ~ ~ summon ArmorStand ~ ~2 ~ {CustomName:TBTNBall,Small:1,Invisible:1,NoGravity:1,DisabledSlots:1,HandItems:[{id:quartz_block},{}],Pose:{RightArm:[0f,0f,-35f]}}
execute @e[score_TNi_min=9,score_TNi=9] ~ ~ ~ execute @e[tag=TNpdl,r=2] ~ ~ ~ scoreboard players set @e[name=TBTNBall,c=1,r=8] TNbl 5
execute @e[score_TNi_min=9,score_TNi=9] ~ ~ ~ execute @e[tag=TNpi1,r=2] ~ ~ ~ scoreboard players set @e[name=TBTNBall,c=1,r=8] TNdr -7
execute @e[score_TNi_min=9,score_TNi=9] ~ ~ ~ execute @e[tag=TNpi2,r=2] ~ ~ ~ scoreboard players set @e[name=TBTNBall,c=1,r=8] TNdr 7
execute @e[score_TNi_min=9,score_TNi=9] ~ ~ ~ execute @e[tag=TNpi1,r=2] ~ ~ ~ scoreboard players set @e[name=TBTNBall,c=1,r=8] TNto 1
execute @e[score_TNi_min=9,score_TNi=9] ~ ~ ~ execute @e[tag=TNpi2,r=2] ~ ~ ~ scoreboard players set @e[name=TBTNBall,c=1,r=8] TNto -1
execute @e[score_TNi_min=9,score_TNi=9] ~ ~ ~ execute @e[tag=TNpdl,r=2] ~ ~ ~ scoreboard players set @e[type=Villager,r=8] TNai 2
# Cooldown timer for the ball to be tp'ed
INIT:scoreboard objectives add TNcd dummy
execute @e[score_TNi_min=9,score_TNi=9] ~ ~ ~ execute @e[tag=TNpdl,r=8] ~ ~ ~ scoreboard players set @e[name=TBTNBall,c=1,r=8] TNcd 3
scoreboard players remove @e[score_TNcd_min=1] TNcd 1
# Move the track armorstand back to the center
# TRACK execute @e[score_TNi_min=9,score_TNi=9] ~ ~ ~ execute @e[name=TBTNPaddle,r=2] ~ ~ ~ tp @e[name=TBTNTrack,c=1,r=5] @e[name=TBTNCenter,c=1,r=5]
execute @e[score_TNi_min=9,score_TNi=9] ~ ~ ~ execute @e[tag=TNpdl,r=2] ~ ~ ~ kill @e[score_TNi_min=9,score_TNi=9,r=3]

# Ball controller
INIT:scoreboard objectives add TNbl dummy
INIT:scoreboard objectives add TNdr dummy
# Note that TNbl can be anywhere from 1 to 9, and it represents the location of the ball on the table (lane) with 5 being the center, like so: 1234 5 6789
# This part is for keeping TBTNTrack in the correct place on the all times:
# TRACK execute @e[name=TBTNTrack] ~ ~ ~ tp @e[name=TBTNTrack,c=1,r=1] @e[name=TBTNCenter,c=1,r=6]
execute @e[name=TBTNBall] ~ ~ ~ tp @e[name=TBTNBall,c=1,r=1,score_TNcd=0] @e[name=TBTNCenter,c=1,r=6]

# Change the TNdr so the ball moves
INIT:scoreboard objectives add TNto dummy
INIT:scoreboard objectives add TNae dummy
INIT:scoreboard objectives add TNrev dummy
# TNto keeps track of which direction the ball is moving (TNdr doesn't keep track of the direction anymore, but rather the ball's location on the table)
# Set TNae for the ball to 1 if it is at the edge of the table (simply if TNdr is either -7 or 7)
scoreboard players set @e[name=TBTNBall] TNae 0
scoreboard players set @e[score_TNdr=-7] TNae 1
scoreboard players set @e[score_TNdr_min=7] TNae 2
# Ball movement
scoreboard players remove @e[name=TBTNBall,score_TNto=-1,score_TNdr_min=-6] TNdr 1
scoreboard players add @e[name=TBTNBall,score_TNto_min=1,score_TNdr=6] TNdr 1

# Keeping the ball in the correct lane (without TBTNTrack)
tp @e[score_TNbl_min=1,score_TNbl=1,score_TNcd=0] ~1 ~ ~
tp @e[score_TNbl_min=2,score_TNbl=2,score_TNcd=0] ~0.8 ~ ~
tp @e[score_TNbl_min=3,score_TNbl=3,score_TNcd=0] ~0.5 ~ ~
tp @e[score_TNbl_min=4,score_TNbl=4,score_TNcd=0] ~0.25 ~ ~
tp @e[score_TNbl_min=6,score_TNbl=6,score_TNcd=0] ~-0.25 ~ ~
tp @e[score_TNbl_min=7,score_TNbl=7,score_TNcd=0] ~-0.5 ~ ~
tp @e[score_TNbl_min=8,score_TNbl=8,score_TNcd=0] ~-0.8 ~ ~
tp @e[score_TNbl_min=9,score_TNbl=9,score_TNcd=0] ~-1 ~ ~

# TNbl is used to track whether each player hits the ball or not
# TNdr tracks the direction of the ball (towards player 1 is negative, and towards player 2 is positive (updown to 10 for each))
# TNdr also tracks where the ball is on the Z axis
tp @e[score_TNdr_min=-7,score_TNdr=-7,score_TNcd=0] ~ ~0.7 ~-1.4
tp @e[score_TNdr_min=-6,score_TNdr=-6,score_TNcd=0] ~ ~0.85 ~-0.9
tp @e[score_TNdr_min=-5,score_TNdr=-5,score_TNcd=0] ~ ~0.95 ~-0.6
tp @e[score_TNdr_min=-4,score_TNdr=-4,score_TNcd=0] ~ ~1.1 ~-0.4
tp @e[score_TNdr_min=-3,score_TNdr=-3,score_TNcd=0] ~ ~1.15 ~-0.2
tp @e[score_TNdr_min=-2,score_TNdr=-2,score_TNcd=0] ~ ~1.2 ~
tp @e[score_TNdr_min=-1,score_TNdr=-1,score_TNcd=0] ~ ~1.25 ~0.2
tp @e[score_TNdr_min=0,score_TNdr=0,score_TNcd=0] ~ ~1.25 ~0.4
tp @e[score_TNdr_min=1,score_TNdr=1,score_TNcd=0] ~ ~1.25 ~0.6
tp @e[score_TNdr_min=2,score_TNdr=2,score_TNcd=0] ~ ~1.2 ~0.9
tp @e[score_TNdr_min=3,score_TNdr=3,score_TNcd=0] ~ ~1.15 ~1.15
tp @e[score_TNdr_min=4,score_TNdr=4,score_TNcd=0] ~ ~1.1 ~1.4
tp @e[score_TNdr_min=5,score_TNdr=5,score_TNcd=0] ~ ~0.95 ~1.6
tp @e[score_TNdr_min=6,score_TNdr=6,score_TNcd=0] ~ ~0.85 ~1.9
tp @e[score_TNdr_min=7,score_TNdr=7,score_TNcd=0] ~ ~0.7 ~2.4

# Hitting the ball
scoreboard players reset @e[type=ArmorStand,name=TBTNBall] TNrev
execute @e[score_TNpl_min=1,score_TNpl=1] ~ ~ ~ scoreboard players set @e[c=1,r=2,score_TNae_min=1,score_TNbl_min=1,score_TNbl=1] TNrev 1
execute @e[score_TNpl_min=1,score_TNpl=3] ~ ~ ~ scoreboard players set @e[c=1,r=2,score_TNae_min=1,score_TNbl_min=2,score_TNbl=2] TNrev 1
execute @e[score_TNpl_min=2,score_TNpl=4] ~ ~ ~ scoreboard players set @e[c=1,r=2,score_TNae_min=1,score_TNbl_min=3,score_TNbl=3] TNrev 1
execute @e[score_TNpl_min=3,score_TNpl=5] ~ ~ ~ scoreboard players set @e[c=1,r=2,score_TNae_min=1,score_TNbl_min=4,score_TNbl=4] TNrev 1
execute @e[score_TNpl_min=4,score_TNpl=6] ~ ~ ~ scoreboard players set @e[c=1,r=2,score_TNae_min=1,score_TNbl_min=5,score_TNbl=5] TNrev 1
execute @e[score_TNpl_min=5,score_TNpl=7] ~ ~ ~ scoreboard players set @e[c=1,r=2,score_TNae_min=1,score_TNbl_min=6,score_TNbl=6] TNrev 1
execute @e[score_TNpl_min=6,score_TNpl=8] ~ ~ ~ scoreboard players set @e[c=1,r=2,score_TNae_min=1,score_TNbl_min=7,score_TNbl=7] TNrev 1
execute @e[score_TNpl_min=7,score_TNpl=9] ~ ~ ~ scoreboard players set @e[c=1,r=2,score_TNae_min=1,score_TNbl_min=8,score_TNbl=8] TNrev 1
execute @e[score_TNpl_min=9,score_TNpl=9] ~ ~ ~ scoreboard players set @e[c=1,r=2,score_TNae_min=1,score_TNbl_min=9,score_TNbl=9] TNrev 1

# Always make sure that paddle2's TNpl score is reversed since it is 180 degrees rotated
INIT:summon ArmorStand ~ ~ ~ {CustomName:"TBTNNum10",Marker:1,NoGravity:1,Invisible:1}
INIT:scoreboard objectives add TNct dummy
scoreboard players set @e[type=ArmorStand,name=TBTNNum10] TNct 10
execute @e[type=!ArmorStand] ~ ~ ~ execute @e[tag=TNpi2,c=1,r=2] ~ ~ ~ scoreboard players operation @e[type=ArmorStand,name=TBTNNum10] TNct -= @e[tag=TNpi2] TNpl
execute @e[type=!ArmorStand] ~ ~ ~ execute @e[tag=TNpi2,c=1,r=2] ~ ~ ~ scoreboard players operation @e[tag=TNpi2,c=1,r=8] TNpl = @e[type=ArmorStand,name=TBTNNum10] TNct

# Paddle accuracy for hitting
INIT:scoreboard objectives add TNpl dummy
entitydata @e[score_TNpl=1] {Pose:{RightArm:[0f,90f,186.66f]}}
entitydata @e[score_TNpl_min=2,score_TNpl=2] {Pose:{RightArm:[0f,90f,173.33f]}}
entitydata @e[score_TNpl_min=3,score_TNpl=3] {Pose:{RightArm:[0f,90f,159.99f]}}
entitydata @e[score_TNpl_min=4,score_TNpl=4] {Pose:{RightArm:[0f,90f,146.66f]}}
entitydata @e[score_TNpl_min=5,score_TNpl=5] {Pose:{RightArm:[0f,90f,133.33f]}}
entitydata @e[score_TNpl_min=6,score_TNpl=6] {Pose:{RightArm:[0f,90f,119.99f]}}
entitydata @e[score_TNpl_min=7,score_TNpl=7] {Pose:{RightArm:[0f,90f,106.66f]}}
entitydata @e[score_TNpl_min=8,score_TNpl=8] {Pose:{RightArm:[0f,90f,93.33f]}}
entitydata @e[score_TNpl_min=9] {Pose:{RightArm:[0f,90f,80f]}}

# Make the ball either move left or right, or stay in the same lane each time it is hit
INIT:scoreboard objectives add TNr dummy
scoreboard players set @e[tag=TNr] TNr 1
# Randomize then move
execute @e[name=TBTNBall,score_TNrev_min=1] ~ ~ ~ scoreboard players set @r[type=ArmorStand,score_TNr_min=1,r=8] TNr 2
execute @e[name=TBTNr1,score_TNr_min=2] ~ ~ ~ scoreboard players remove @e[type=ArmorStand,name=TBTNBall,score_TNbl_min=2] TNbl 1
execute @e[name=TBTNr3,score_TNr_min=2] ~ ~ ~ scoreboard players add @e[type=ArmorStand,name=TBTNBall,score_TNbl=8] TNbl 1

# Reversing the direction of the ball (Input from chunk above)
scoreboard players set @e[score_TNrev_min=1,score_TNto=-1,score_TNae=1] TNto 1
scoreboard players set @e[score_TNrev_min=1,score_TNto_min=1,score_TNae_min=2] TNto -1

# Give an id (1 and 2) to each paddle armorstand (changed to a tag that is given to them when they are summoned: TNpi)

# Missing the ball
INIT:scoreboard objectives add TNms dummy
# Add to the miss score when the player has not hit the ball back yet
scoreboard players add @e[score_TNae_min=1] TNms 1
scoreboard players set @e[score_TNae=0] TNms 0
# Only make the player actually miss if the miss score counts up to a certain number (for example, 5 would be 0.25 seconds before it counts it as a miss)
execute @e[score_TNms_min=5] ~ ~ ~ tellraw @a[r=12] [{"selector":"@e[type=!ArmorStand,c=1,r=5]","color":"blue"},{"text":" missed the ball!","color":"dark_aqua"}]
execute @e[score_TNms_min=5] ~ ~ ~ particle fireworksSpark ~ ~1 ~ 0 0 0 0.03 100
execute @e[score_TNms_min=5] ~ ~ ~ playsound entity.ghast.shoot neutral @a[r=10] ~ ~ ~ 1 2
execute @e[score_TNms_min=5] ~ ~ ~ execute @e[name=TBTNCenter,c=1,r=8] ~ ~1.5 ~0.5 summon Item ~ ~ ~ {Item:{id:"minecraft:snowball",Count:1,tag:{display:{Name:"Ping Pong Ball"}}}}
kill @e[type=ArmorStand,name=TBTNBall,score_TNms_min=5]

# Hit sounds
execute @e[name=TBTNBall,score_TNrev_min=1] ~ ~ ~ playsound entity.item.pickup neutral @a[r=10] ~ ~ ~ 1 2

For Minecraft version 1.10.2
Click here for other versions of this command!
How to use
Give yourself a command block with /give @p command_block. Place it then paste the command from below into it. One command creations are similar to Minecraft mods, but are much easier to add to your world!
Click here for other versions of this command!