Advertisement
Guest User

data/scripts/functions/main.mcfunction

a guest
Jun 23rd, 2020
5,644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.03 KB | None | 0 0
  1. ##### IMPORTS #####
  2. #/summon minecraft:armor_stand ~ ~ ~ {NoGravity:1b,Invulnerable:1b,Invisible:1,Marker:1b,Tags:["grid"],DisabledSlots:4144959,ArmorItems:[{},{},{},{id:"minecraft:jigsaw",Count:1b,tag:{CustomModelData:0}}]}
  3. #/setworldspawn 250 63 19
  4. effect give @p instant_health 9999 0 true
  5. effect give @p resistance 9999 100 true
  6. effect give @p saturation 9999 0 true
  7. effect give @p invisibility 9999 0 true
  8. effect give @p night_vision 9999 0 true
  9. kill @e[type=item,x=0,y=235,z=3,dx=34,dy=20,dz=-2]
  10. scoreboard objectives add facing dummy
  11. execute as @e[tag=sprite] if data entity @s {Rotation:[90f]} run scoreboard players set facing facing 0
  12. execute as @e[tag=sprite] if data entity @s {Rotation:[-90f]} run scoreboard players set facing facing 1
  13. team add nocoll
  14. team modify nocoll collisionRule never
  15. team join nocoll @e[tag=click_detect]
  16. experience set @p 99 levels
  17. experience set @p 732 points
  18. kill @e[type=minecraft:experience_orb]
  19. kill @e[type=minecraft:arrow]
  20. kill @e[type=minecraft:fireball]
  21. execute as @e[tag=spawnpoint] at @s run forceload add ~ ~
  22.  
  23.  
  24.  
  25. ##### MAIN #####
  26. ## Spawnpoint
  27. execute as @e[tag=looking_at] at @s if block ~ ~ ~ #minecraft:beds run forceload remove all
  28. execute as @e[tag=looking_at] at @s run forceload add 250 19
  29. execute as @e[tag=looking_at] at @s if block ~ ~ ~ #minecraft:beds run kill @e[tag=spawnpoint]
  30. execute as @e[tag=looking_at] at @s if block ~ ~ ~ #minecraft:beds run summon minecraft:armor_stand ~ ~ ~ {NoGravity:1b,Invulnerable:1b,Invisible:1,Marker:1b,Tags:["spawnpoint"],DisabledSlots:4144959}
  31. execute as @e[tag=spawnpoint] at @s unless block ~ ~ ~ #minecraft:beds run kill @s
  32.  
  33. ## If player not found...
  34. execute unless entity @e[tag=player] run summon armor_stand 245 64 15 {Tags:["player","spawn"],Invulnerable:1,Pose:{Head:[0f,15f,0f]}}
  35. execute as @e[tag=player,tag=spawn] at @e[tag=spawnpoint,limit=1] run tp @s ~1 ~ ~
  36. execute as @e[tag=player,tag=spawn] as @p at @s run playsound minecraft:entity.player.death master @s
  37. execute as @e[tag=player,tag=spawn] run tellraw @a {"text":"Player fell out of the world"}
  38. tag @e[tag=player,tag=spawn] remove spawn
  39.  
  40. ## Stay on axis
  41. scoreboard objectives add player_z dummy
  42. execute as @e[tag=player] store result score @s player_z run data get entity @s Pos[2]
  43. execute as @e[tag=player] at @s unless score @s player_z matches 15 run tp @s ~ ~ 15
  44.  
  45.  
  46. ## Visuals
  47. execute as @e[tag=sprite] run data merge entity @s {HandItems:[{},{}],ArmorItems:[{},{},{},{id:"minecraft:player_head",Count:1b}]}
  48. execute as @e[tag=sprite] run data modify entity @s HandItems[0] merge from entity @p SelectedItem
  49. execute as @e[tag=sprite] run data modify entity @s HandItems[1] merge from entity @p Inventory[{Slot:-106b}]
  50. execute as @e[tag=sprite] run data modify entity @s ArmorItems[3] merge from entity @p Inventory[{Slot:103b}]
  51. execute as @e[tag=sprite] run data modify entity @s ArmorItems[2] merge from entity @p Inventory[{Slot:102b}]
  52. execute as @e[tag=sprite] run data modify entity @s ArmorItems[1] merge from entity @p Inventory[{Slot:101b}]
  53. execute as @e[tag=sprite] run data modify entity @s ArmorItems[0] merge from entity @p Inventory[{Slot:100b}]
  54.  
  55. ## Time detect
  56. scoreboard objectives add time dummy
  57. execute store result score time time run time query daytime
  58.  
  59. ## Screen (16:9, or 32x18)
  60. execute unless score time time matches 12541..23458 run fill 1 254 1 32 237 1 minecraft:light_blue_concrete
  61. execute if score time time matches 12541..23458 run fill 1 254 1 32 237 1 minecraft:black_concrete
  62.  
  63. ## Clone screen
  64. execute as @e[tag=player] at @s run setworldspawn ~ ~ ~
  65. scoreboard objectives add clone_delay dummy
  66. scoreboard players add delay clone_delay 1
  67. execute if score delay clone_delay matches 5.. run scoreboard players set delay clone_delay 0
  68. execute if score delay clone_delay matches 0 run execute as @e[tag=player] at @s run clone ~-15 ~-2 ~ ~16 ~15 ~ 1 237 2
  69.  
  70.  
  71. ## Screen movement
  72. #execute unless entity @e[tag=sprite] run summon armor_stand 16 239 2 {Tags:["sprite"],Invulnerable:1,NoGravity:1,ShowArms:1,Rotation:[-90f],NoBasePlate:1,ArmorItems:[{},{},{},{id:"minecraft:player_head",Count:1b}],Pose:{Head:[0f,15f,0f],RightArm:[340f,0f,0f],LeftArm:[340f,0f,0f]}}
  73. execute as @e[tag=sprite] at @s run tp @s ~ 239 ~
  74.  
  75. #Rotation
  76. execute as @e[tag=player] store result entity @s Pose.Head[0] float 2.5 run data get entity @p Rotation[1]
  77. execute as @e[tag=sprite] store result entity @s Pose.Head[0] float 1 run data get entity @e[tag=player,limit=1] Pose.Head[0]
  78.  
  79. #Movement
  80. scoreboard objectives add player_pos dummy
  81. scoreboard objectives add in_motion dummy
  82. scoreboard players set @p in_motion 0
  83. execute store result score x player_pos run data get entity @p Pos[0] 100
  84. execute store result score y player_pos run data get entity @p Pos[1] 100
  85. execute store result score z player_pos run data get entity @p Pos[2] 100
  86. execute if score x player_pos matches 1651.. run scoreboard players set @p in_motion 1
  87. execute if score x player_pos matches 1651.. run execute as @e[tag=player] run data merge entity @s {Motion:[0.2,0.01,0.0]}
  88. execute if score x player_pos matches 1651.. run execute as @e[tag=sprite] run data merge entity @s {Rotation:[-90f]}
  89. execute if score x player_pos matches ..1649 run scoreboard players set @p in_motion 1
  90. execute if score x player_pos matches ..1649 run execute as @e[tag=player] run data merge entity @s {Motion:[-0.2,0.01,0.0]}
  91. execute if score x player_pos matches ..1649 run execute as @e[tag=sprite] run data merge entity @s {Rotation:[90f]}
  92. execute as @e[tag=sprite] at @s if block ~ ~-1 ~ #scripts:non_solid as @e[tag=player] at @s align x run tp @s ~0.5 ~-0.1 ~
  93. #Animate
  94. execute as @e[tag=sprite] if data entity @s {Pose:{LeftLeg:[355f,0f,0f],RightLeg:[-355f,0f,0f]}} run data merge entity @s {Pose:{LeftLeg:[0f,0f,0f],RightLeg:[0f,0f,0f]}}
  95. execute as @e[tag=sprite] if data entity @s {Pose:{LeftLeg:[350f,0f,0f],RightLeg:[-350f,0f,0f]}} run data merge entity @s {Pose:{LeftLeg:[355f,0f,0f],RightLeg:[-355f,0f,0f]}}
  96. execute as @e[tag=sprite] if data entity @s {Pose:{LeftLeg:[345f,0f,0f],RightLeg:[-345f,0f,0f]}} run data merge entity @s {Pose:{LeftLeg:[350f,0f,0f],RightLeg:[-350f,0f,0f]}}
  97. execute as @e[tag=sprite] if data entity @s {Pose:{LeftLeg:[340f,0f,0f],RightLeg:[-340f,0f,0f]}} run data merge entity @s {Pose:{LeftLeg:[345f,0f,0f],RightLeg:[-345f,0f,0f]}}
  98. execute as @e[tag=sprite] if data entity @s {Pose:{LeftLeg:[335f,0f,0f],RightLeg:[-335f,0f,0f]}} run data merge entity @s {Pose:{LeftLeg:[340f,0f,0f],RightLeg:[-340f,0f,0f]}}
  99. execute as @e[tag=sprite] if data entity @s {Pose:{LeftLeg:[325f,0f,0f],RightLeg:[-325f,0f,0f]}} run data merge entity @s {Pose:{LeftLeg:[335f,0f,0f],RightLeg:[-335f,0f,0f]}}
  100. execute as @e[tag=sprite] if score @p in_motion matches 1 run data merge entity @s {Pose:{LeftLeg:[325f,0f,0f],RightLeg:[-325f,0f,0f]}}
  101.  
  102. #Auto-jump
  103. execute if score x player_pos matches 1651.. as @e[tag=player] at @s unless block ~1 ~ ~ #scripts:non_solid if block ~1 ~1 ~ #scripts:non_solid if block ~1 ~2 ~ #scripts:non_solid run tp @s ~0.5 ~1 ~
  104. execute if score x player_pos matches ..1649 as @e[tag=player] at @s unless block ~-1 ~ ~ #scripts:non_solid if block ~-1 ~1 ~ #scripts:non_solid if block ~-1 ~2 ~ #scripts:non_solid run tp @s ~-0.5 ~1 ~
  105. execute as @e[tag=player] at @s unless block ~ ~ ~ #scripts:non_solid if block ~ ~1 ~ #scripts:non_solid if block ~ ~2 ~ #scripts:non_solid run tp @s ~ ~1.5 ~
  106.  
  107. execute unless score x player_pos matches 1650 run tp @p 16.5 241 13
  108. execute unless score y player_pos matches 24100 run tp @p 16.5 241 13
  109. execute unless score z player_pos matches 1350 run tp @p 16.5 241 13
  110.  
  111.  
  112. ## Looking at
  113. scoreboard objectives add pitch dummy
  114. #execute unless entity @e[tag=looking_at] as @e[tag=player] at @s positioned ~ ~ ~ run summon armor_stand ~ ~ ~ {Invisible:1,Invulnerable:1,NoGravity:1,Tags:["looking_at"]}
  115.  
  116. execute store result score pitch pitch run data get entity @p Rotation[1]
  117. execute if score facing facing matches 0 if score pitch pitch matches 26..90 run execute as @e[tag=player] at @s run tp @e[tag=looking_at] ~ ~-1 ~
  118. execute if score facing facing matches 0 if score pitch pitch matches 9..25 run execute as @e[tag=player] at @s run tp @e[tag=looking_at] ~-1 ~ ~
  119. execute if score facing facing matches 0 if score pitch pitch matches -8..8 run execute as @e[tag=player] at @s run tp @e[tag=looking_at] ~-1 ~1 ~
  120. execute if score facing facing matches 0 if score pitch pitch matches -16..-9 run execute as @e[tag=player] at @s run tp @e[tag=looking_at] ~-1 ~2 ~
  121. execute if score facing facing matches 0 if score pitch pitch matches -90..-17 run execute as @e[tag=player] at @s run tp @e[tag=looking_at] ~ ~2 ~
  122. execute if score facing facing matches 1 if score pitch pitch matches 26..90 run execute as @e[tag=player] at @s run tp @e[tag=looking_at] ~ ~-1 ~
  123. execute if score facing facing matches 1 if score pitch pitch matches 9..25 run execute as @e[tag=player] at @s run tp @e[tag=looking_at] ~1 ~ ~
  124. execute if score facing facing matches 1 if score pitch pitch matches -8..8 run execute as @e[tag=player] at @s run tp @e[tag=looking_at] ~1 ~1 ~
  125. execute if score facing facing matches 1 if score pitch pitch matches -16..-9 run execute as @e[tag=player] at @s run tp @e[tag=looking_at] ~1 ~2 ~
  126. execute if score facing facing matches 1 if score pitch pitch matches -90..-17 run execute as @e[tag=player] at @s run tp @e[tag=looking_at] ~ ~2 ~
  127. execute as @e[tag=looking_at] at @s run clone ~ ~ ~ ~ ~ ~ 11 242 7
  128.  
  129. #execute unless entity @e[tag=sprite_looking_at] as @e[tag=sprite] at @s positioned ~ ~ ~ run summon armor_stand ~ ~ ~ {Invisible:1,Invulnerable:1,NoGravity:1,Tags:["sprite_looking_at"],Glowing:1b,Small:1b,NoBasePlate:1,Rotation:[90f]}
  130. execute if score facing facing matches 0 if score pitch pitch matches 26..90 run execute as @e[tag=sprite] at @s run tp @e[tag=sprite_looking_at] ~ ~-1 ~
  131. execute if score facing facing matches 0 if score pitch pitch matches 9..25 run execute as @e[tag=sprite] at @s run tp @e[tag=sprite_looking_at] ~-1 ~ ~
  132. execute if score facing facing matches 0 if score pitch pitch matches -8..8 run execute as @e[tag=sprite] at @s run tp @e[tag=sprite_looking_at] ~-1 ~1 ~
  133. execute if score facing facing matches 0 if score pitch pitch matches -16..-9 run execute as @e[tag=sprite] at @s run tp @e[tag=sprite_looking_at] ~-1 ~2 ~
  134. execute if score facing facing matches 0 if score pitch pitch matches -90..-17 run execute as @e[tag=sprite] at @s run tp @e[tag=sprite_looking_at] ~ ~2 ~
  135. execute if score facing facing matches 1 if score pitch pitch matches 26..90 run execute as @e[tag=sprite] at @s run tp @e[tag=sprite_looking_at] ~ ~-1 ~
  136. execute if score facing facing matches 1 if score pitch pitch matches 9..25 run execute as @e[tag=sprite] at @s run tp @e[tag=sprite_looking_at] ~1 ~ ~
  137. execute if score facing facing matches 1 if score pitch pitch matches -8..8 run execute as @e[tag=sprite] at @s run tp @e[tag=sprite_looking_at] ~1 ~1 ~
  138. execute if score facing facing matches 1 if score pitch pitch matches -16..-9 run execute as @e[tag=sprite] at @s run tp @e[tag=sprite_looking_at] ~1 ~2 ~
  139. execute if score facing facing matches 1 if score pitch pitch matches -90..-17 run execute as @e[tag=sprite] at @s run tp @e[tag=sprite_looking_at] ~ ~2 ~
  140.  
  141.  
  142. ## Detect click
  143. scoreboard objectives add right_click minecraft.custom:minecraft.talked_to_villager
  144. scoreboard objectives add left_click dummy
  145. execute as @e[tag=click_detect] if data entity @s {HurtTime:9s} run scoreboard players set @p left_click 1
  146.  
  147. effect give @e[tag=click_detect] invisibility 9999 0 true
  148. effect give @e[tag=click_detect] resistance 9999 100 true
  149. effect give @e[tag=click_detect] instant_health 9999 100 true
  150. execute as @e[tag=click_detect] run data merge entity @s {VillagerData:{profession:"minecraft:none"}}
  151. execute unless entity @e[tag=click_detect] as @p at @s positioned ~ ~1 ~ run summon villager ~ ~ ~ {Invulnerable:0b,Silent:1b,NoAI:1b,Tags:["click_detect"],VillagerData:{profession:"minecraft:none"},Offers:{}}
  152. execute as @p at @s positioned ~ ~1 ~ run tp @e[tag=click_detect] ^ ^ ^2
  153. execute as @e[tag=click_detect] at @s unless block ~ ~ ~ #scripts:non_solid run tp @s 16 241 11
  154.  
  155. #Left (Break)
  156. execute if score @p left_click matches 1.. run execute as @e[tag=looking_at] at @s run loot give @p mine ~ ~ ~ mainhand
  157. execute if score @p left_click matches 1.. run execute as @e[tag=looking_at] at @s run execute as @p at @s run playsound minecraft:block.stone.break master @s
  158. execute if score @p left_click matches 1.. run execute as @e[tag=looking_at] at @s unless block ~ ~ ~ bedrock run setblock ~ ~ ~ air destroy
  159.  
  160. #Animate
  161. execute if score @p left_click matches 1.. run execute as @e[tag=sprite] run data merge entity @s {Pose:{RightArm:[280f,0f,0f]}}
  162. execute as @e[tag=sprite] if data entity @s {Pose:{RightArm:[335f,0f,0f]}} run data merge entity @s {Pose:{RightArm:[340f,0f,0f]}}
  163. execute as @e[tag=sprite] if data entity @s {Pose:{RightArm:[325f,0f,0f]}} run data merge entity @s {Pose:{RightArm:[335f,0f,0f]}}
  164. execute as @e[tag=sprite] if data entity @s {Pose:{RightArm:[310f,0f,0f]}} run data merge entity @s {Pose:{RightArm:[325f,0f,0f]}}
  165. execute as @e[tag=sprite] if data entity @s {Pose:{RightArm:[290f,0f,0f]}} run data merge entity @s {Pose:{RightArm:[310f,0f,0f]}}
  166. execute as @e[tag=sprite] if data entity @s {Pose:{RightArm:[280f,0f,0f]}} run data merge entity @s {Pose:{RightArm:[290f,0f,0f]}}
  167. scoreboard players set @p[scores={left_click=1..}] left_click 0
  168.  
  169. #Right (Place)
  170. scoreboard players set @p[nbt=!{SelectedItem:{}}] right_click 0
  171. execute as @e[tag=looking_at] at @s unless block ~ ~ ~ #scripts:non_solid unless score pitch pitch matches 26..90 run scoreboard players set @p[scores={right_click=1..}] right_click 0
  172. execute as @e[tag=player] at @s if score pitch pitch matches 26..90 unless block ~ ~2 ~ #scripts:non_solid run scoreboard players set @p[scores={right_click=1..}] right_click 0
  173.  
  174. execute if score @p right_click matches 1.. run summon item 16 236 20 {Item:{id:"minecraft:oak_log",Count:1b},Tags:["hold"]}
  175. execute if score @p right_click matches 1.. run execute as @e[tag=hold] store result entity @s Item.Count byte 1 run data get entity @p SelectedItem.Count
  176. execute if score @p right_click matches 1.. run execute as @e[tag=hold] run data modify entity @s Item set from entity @p SelectedItem
  177. scoreboard objectives add hold_count dummy
  178. execute store result score @p hold_count run data get entity @p SelectedItem.Count
  179. execute store result score minus_1 hold_count run data get entity @p SelectedItem.Count
  180. scoreboard players remove minus_1 hold_count 1
  181.  
  182. execute if score @p right_click matches 1.. if score pitch pitch matches 26..90 run execute as @e[tag=looking_at] at @s run tp @s ~ ~1 ~
  183. execute if score @p right_click matches 1.. run function scripts:block_ids
  184. execute if score @p right_click matches 1.. run replaceitem entity @p weapon.mainhand air
  185. execute if score @p right_click matches 1.. run tp @e[tag=hold] @p
  186. execute if score @p right_click matches 1.. run execute as @p at @s run playsound minecraft:block.stone.place master @s
  187. #Animate (imports from #Left)
  188. execute if score @p right_click matches 1.. run execute as @e[tag=sprite] run data merge entity @s {Pose:{RightArm:[280f,0f,0f]}}
  189. scoreboard players set @p[scores={right_click=1..}] right_click 0
  190.  
  191.  
  192. ## GUIs
  193. scoreboard objectives add gui dummy
  194. execute as @e[tag=player] at @s unless block ~ ~-1 ~ #scripts:guis run scoreboard players set @p gui 0
  195. execute if score @p in_motion matches 1 run scoreboard players set @p gui 0
  196. execute as @e[tag=player] at @s if block ~ ~-1 ~ #scripts:guis run scoreboard players add @p[scores={gui=0..1}] gui 1
  197. execute as @e[tag=player] at @s if block ~ ~-1 ~ crafting_table unless block 16 240 13 crafting_table if score @p gui matches 1 run clone ~ ~-1 ~ ~ ~-1 ~ 16 240 13
  198. execute as @e[tag=player] at @s if block ~ ~-1 ~ furnace unless block 16 240 13 furnace if score @p gui matches 1 run clone ~ ~-1 ~ ~ ~-1 ~ 16 240 13
  199. execute as @e[tag=player] at @s if block ~ ~-1 ~ anvil unless block 16 240 13 anvil if score @p gui matches 1 run clone ~ ~-1 ~ ~ ~-1 ~ 16 240 13
  200. execute as @e[tag=player] at @s if block ~ ~-1 ~ dispenser unless block 16 240 13 dispenser if score @p gui matches 1 run clone ~ ~-1 ~ ~ ~-1 ~ 16 240 13
  201. execute as @e[tag=player] at @s if block ~ ~-1 ~ dropper unless block 16 240 13 dropper if score @p gui matches 1 run clone ~ ~-1 ~ ~ ~-1 ~ 16 240 13
  202. execute as @e[tag=player] at @s if block ~ ~-1 ~ loom unless block 16 240 13 loom if score @p gui matches 1 run clone ~ ~-1 ~ ~ ~-1 ~ 16 240 13
  203. execute as @e[tag=player] at @s if block ~ ~-1 ~ barrel unless block 16 240 13 barrel if score @p gui matches 1 run clone ~ ~-1 ~ ~ ~-1 ~ 16 240 13
  204. execute as @e[tag=player] at @s if block ~ ~-1 ~ smoker unless block 16 240 13 smoker if score @p gui matches 1 run clone ~ ~-1 ~ ~ ~-1 ~ 16 240 13
  205. execute as @e[tag=player] at @s if block ~ ~-1 ~ blast_furnace unless block 16 240 13 blast_furnace if score @p gui matches 1 run clone ~ ~-1 ~ ~ ~-1 ~ 16 240 13
  206. execute as @e[tag=player] at @s if block ~ ~-1 ~ cartography_table unless block 16 240 13 cartography_table if score @p gui matches 1 run clone ~ ~-1 ~ ~ ~-1 ~ 16 240 13
  207. execute as @e[tag=player] at @s if block ~ ~-1 ~ smithing_table unless block 16 240 13 smithing_table if score @p gui matches 1 run clone ~ ~-1 ~ ~ ~-1 ~ 16 240 13
  208.  
  209. execute if score @p gui matches 2 as @e[tag=player] at @s if block ~ ~-1 ~ furnace if block 16 240 13 furnace run clone 16 240 13 16 240 13 ~ ~-1 ~
  210. execute if score @p gui matches 2 as @e[tag=player] at @s if block ~ ~-1 ~ dispenser if block 16 240 13 dispenser run clone 16 240 13 16 240 13 ~ ~-1 ~
  211. execute if score @p gui matches 2 as @e[tag=player] at @s if block ~ ~-1 ~ barrel if block 16 240 13 barrel run clone 16 240 13 16 240 13 ~ ~-1 ~
  212. execute if score @p gui matches 2 as @e[tag=player] at @s if block ~ ~-1 ~ smoker if block 16 240 13 smoker run clone 16 240 13 16 240 13 ~ ~-1 ~
  213. execute if score @p gui matches 2 as @e[tag=player] at @s if block ~ ~-1 ~ blast_furnace if block 16 240 13 blast_furnace run clone 16 240 13 16 240 13 ~ ~-1 ~
  214. execute if score @p gui matches 0 run setblock 16 240 13 sea_lantern
  215.  
  216. ## Move items to player
  217. execute as @p at @s run tp @e[type=item,distance=..20] @p
  218. execute as @e[tag=player] at @s run tp @e[type=item,distance=..2] @p
  219.  
  220.  
  221. ## Mobs ??
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement