Curcuit_Blocks

Minecraft Line Drawing algorithm *Commands*

Feb 11th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.94 KB | None | 0 0
  1. One Time Run.
  2.  
  3. /scoreboard players tag @e remove LowestX
  4. /execute @e[tag=LineDraw] ~ ~ ~ scoreboard players operation @e[c=1,tag=LineDraw] OrXL = @e[c=1,tag=LineDraw] OrX
  5. /scoreboard players set LOWEST OrX 2147483647
  6. /scoreboard players operation LOWEST OrX < @e[tag=LineDraw] OrX
  7. /scoreboard players operation @e[tag=LineDraw] OrXL -= LOWEST OrX
  8. /scoreboard players tag @e[score_OrXL=0,tag=LineDraw] add LowestX
  9. /execute @e[score_OrX=2147483647,tag=!LowestX] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["LinePart","LineCon"],NoGravity:1b}
  10. /scoreboard players set 1000 OrX 100000
  11. scoreboard players operation @e[c=1,tag=LineCon] ChangeX = @e[c=1,tag=LowestX] OrX
  12. scoreboard players operation @e[c=1,tag=LineCon] ChangeY = @e[c=1,tag=LowestX] OrY
  13. scoreboard players operation @e[c=1,tag=LineCon] ChangeX -= @e[score_OrX=2147483647,tag=!LowestX] OrX
  14. scoreboard players operation @e[c=1,tag=LineCon] ChangeY -= @e[score_OrX=2147483647,tag=!LowestX] OrY
  15. /scoreboard players set -1 OrX -1
  16. /scoreboard players tag @e[tag=LineCon] add DivideX
  17. /scoreboard players tag @e[tag=LineCon,score_ChangeX_min=0,score_ChangeX=0] remove DivideX
  18. /scoreboard players tag @e[tag=LineCon,score_ChangeX_min=0,score_ChangeX=0] add DivideY
  19. scoreboard players tag @e[tag=DivideY,score_ChangeY_min=0,score_ChangeY=0] add LineEr
  20. execute @e[tag=LineEr] ~ ~ ~ /tellraw @p ["",{"text":"Error ","color":"red","bold":true},{"text":"Line cannot be drawn!","color":"red","bold":false}]
  21. kill @e[tag=LineEr]
  22. execute @e[tag=DivideX] ~ ~ ~ scoreboard players operation @e[c=1,tag=LineCon] YMultSign = @e[c=1,tag=LineCon] ChangeY
  23. execute @e[tag=DivideY] ~ ~ ~ scoreboard players operation @e[c=1,tag=LineCon] XMultSign = @e[c=1,tag=LineCon] ChangeX
  24. /scoreboard players operation @e[tag=DivideX] ChangeY *= 1000 OrX
  25. /scoreboard players operation @e[tag=DivideY] ChangeX *= 1000 OrX
  26. execute @e[tag=DivideX] ~ ~ ~ /scoreboard players operation @e[tag=LineCon] ChangeY /= @e[c=1,tag=LineCon] ChangeX
  27. execute @e[tag=DivideY] ~ ~ ~ /scoreboard players operation @e[tag=LineCon] ChangeX /= @e[c=1,tag=LineCon] ChangeY
  28. /scoreboard players operation @e[tag=DivideX,score_YMultSign_min=1,score_ChangeY=-1] ChangeY *= -1 OrX
  29. /scoreboard players operation @e[tag=DivideX,score_YMultSign=-1,score_ChangeY_min=1] ChangeY *= -1 OrX
  30. /scoreboard players operation @e[tag=DivideY,score_XMultSign_min=1,score_ChangeX=-1] ChangeX *= -1 OrX
  31. /scoreboard players operation @e[tag=DivideY,score_XMultSign=-1,score_ChangeX_min=1] ChangeX *= -1 OrX
  32. /scoreboard players operation @e[tag=LineCon] YTravel = @e[tag=LineCon] ChangeY
  33. /scoreboard players operation @e[tag=LineCon] XTravel = @e[tag=LineCon,c=1] ChangeX
  34. /scoreboard players set @e[tag=LineCon] DrawState 0
  35. /execute @e[tag=LinePoint] ~ ~ ~ setblock ~ ~-1 ~ wool 15
  36.  
  37. On a Clock (or you know, hit a button repetitively for a long time...)
  38.  
  39. /execute @e[tag=LineCon] ~ ~ ~ setblock ~ ~-2 ~ wool 15
  40. /scoreboard players operation @e[score_DrawState_min=0,score_DrawState=0] YMove += @e[c=1,score_DrawState_min=0,score_DrawState=0] YTravel
  41. /scoreboard players set @e[score_YMove_min=100000] DrawState 1
  42. /scoreboard players set @e[score_YMove=-100000] DrawState 1
  43. tp @e[score_DrawState_min=1,score_DrawState=1,score_YTravel=-1] ~ ~ ~-1
  44. tp @e[score_DrawState_min=1,score_DrawState=1,score_YTravel_min=1] ~ ~ ~1
  45. scoreboard players remove @e[score_DrawState_min=1,score_DrawState=1] YMove 100000
  46. /scoreboard players set @e[score_YMove=99999] DrawState 0
  47. /tp @e[score_DrawState_min=0,score_DrawState=0,score_XTravel_min=1] ~1 ~ ~
  48. /tp @e[score_DrawState_min=0,score_DrawState=0,score_XTravel=-1] ~-1 ~ ~
  49. /scoreboard players remove @e[score_DrawState_min=0,score_DrawState=0,score_XTravel_min=1] XTravel 1
  50. /scoreboard players add @e[score_DrawState_min=0,score_DrawState=0,score_XTravel=-1] XTravel 1
  51. /execute @e[tag=LowestX] ~ ~1 ~ teleport @e[r=1,tag=LineCon] ~ ~ ~
  52. /execute @e[tag=LineCon] ~ ~ ~ setblock ~ ~-2 ~ wool 15
  53. kill @e[score_XTravel=0,score_XTravel_min=0]
  54.  
  55. Scoreboards (need to be added in order for this to work)
  56.  
  57. /scoreboard objectives add ChangeX dummy
  58. /scoreboard objectives add ChangeY dummy
  59. /scoreboard objectives add DrawState dummy
  60. /scoreboard objectives add OrX dummy
  61. /scoreboard objectives add OrXL dummy
  62. /scoreboard objectives add OrY dummy
  63. /scoreboard objectives add XMultSign dummy
  64. /scoreboard objectives add XTravel dummy
  65. /scoreboard objectives add YMove dummy
  66. /scoreboard objectives add YMultSign dummy
  67. /scoreboard objectives add YTravel dummy
  68.  
  69. -_-Info-_-
  70. I am not responsible for any broken worlds, I just quickly threw this together
  71. I may have misspellde some Scoreboards, for my commands adding them were rudely destroyed
  72. If anything does not work I would be glad to take a look
  73. Coordinates of armor_stands must be kept in OrX and OrY, please no negatives
  74. Does not have to be Minecraft's coordinates
  75. armor_stand points must have Tags:["LinePoint","LineDraw","LinePart"]
  76. must be only 2 armor_stand points.
  77. I may have forgot to list something in this list, get over it.
  78. Chow!
Advertisement
Add Comment
Please, Sign In to add comment