Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.68 KB | None | 0 0
  1. import:
  2.     org.bukkit.util.BoundingBox
  3.     org.bukkit.block.data.Bisected$Half
  4.     org.bukkit.block.BlockFace
  5.     org.bukkit.block.data.type.Stairs$Shape
  6.    
  7. options:
  8.     nw-eigth : (new BoundingBox(0, 0.5, 0, 0.5, 1, 0.5))
  9.     ne-eigth : (new BoundingBox(0.5, 0.5, 0, 1, 1, 0.5))
  10.     se-eigth : (new BoundingBox(0.5, 0.5, 0.5, 1, 1, 1))
  11.     sw-eigth : (new BoundingBox(0, 0.5, 0.5, 0.5, 1, 1))
  12.    
  13. function getStairAABB(b: block) :: objects:
  14.    
  15.     {_b}.toString() contains "stair"
  16.    
  17.     set {_v} to {_b}.getLocation().toVector()
  18.    
  19.     set {_data} to {_b}.getBlockData()
  20.     set {_face} to {_data}.getFacing().getOppositeFace()
  21.     set {_shape} to {_data}.getShape()
  22.    
  23.     if {_face} = BlockFace.NORTH!:
  24.         if {_shape} = Shape.STRAIGHT!:
  25.             set {_strip} to (new BoundingBox(0, 0.5, 0.5, 1, 1, 1))
  26.         else if {_shape} = Shape.INNER_LEFT!:
  27.             set {_strip} to (new BoundingBox(0, 0.5, 0.5, 1, 1, 1))
  28.             set {_eigth} to {@ne-eigth}
  29.         else if {_shape} = Shape.INNER_RIGHT!:
  30.             set {_strip} to (new BoundingBox(0, 0.5, 0.5, 1, 1, 1))
  31.             set {_eigth} to {@nw-eigth}
  32.         else if {_shape} = Shape.OUTER_LEFT!:
  33.             set {_eigth} to {@se-eigth}
  34.         else if {_shape} = Shape.OUTER_RIGHT!:
  35.             set {_eigth} to {@sw-eigth}
  36.    
  37.     else if {_face} = BlockFace.EAST!:
  38.         if {_shape} = Shape.STRAIGHT!:
  39.             set {_strip} to (new BoundingBox(0, 0.5, 0, 0.5, 1, 1))
  40.         else if {_shape} = Shape.INNER_LEFT!:
  41.             set {_strip} to (new BoundingBox(0, 0.5, 0, 0.5, 1, 1))
  42.             set {_eigth} to {@se-eigth}
  43.         else if {_shape} = Shape.INNER_RIGHT!:
  44.             set {_strip} to (new BoundingBox(0, 0.5, 0, 0.5, 1, 1))
  45.             set {_eigth} to {@ne-eigth}
  46.         else if {_shape} = Shape.OUTER_LEFT!:
  47.             set {_eigth} to {@sw-eigth}
  48.         else if {_shape} = Shape.OUTER_RIGHT!:
  49.             set {_eigth} to {@nw-eigth}
  50.    
  51.     else if {_face} = BlockFace.SOUTH!:
  52.         if {_shape} = Shape.STRAIGHT!:
  53.             set {_strip} to (new BoundingBox(0, 0.5, 0, 1, 1, 0.5))
  54.         else if {_shape} = Shape.INNER_LEFT!:
  55.             set {_strip} to (new BoundingBox(0, 0.5, 0, 1, 1, 0.5))
  56.             set {_eigth} to {@sw-eigth}
  57.         else if {_shape} = Shape.INNER_RIGHT!:
  58.             set {_strip} to (new BoundingBox(0, 0.5, 0, 1, 1, 0.5))
  59.             set {_eigth} to {@se-eigth}
  60.         else if {_shape} = Shape.OUTER_LEFT!:
  61.             set {_eigth} to {@nw-eigth}
  62.         else if {_shape} = Shape.OUTER_RIGHT!:
  63.             set {_eigth} to {@ne-eigth}
  64.            
  65.     else if {_face} = BlockFace.WEST!:
  66.         if {_shape} = Shape.STRAIGHT!:
  67.             set {_strip} to (new BoundingBox(0.5, 0.5, 0, 1, 1, 1))
  68.         else if {_shape} = Shape.INNER_LEFT!:
  69.             set {_strip} to (new BoundingBox(0.5, 0.5, 0, 1, 1, 1))
  70.             set {_eigth} to {@nw-eigth}
  71.         else if {_shape} = Shape.INNER_RIGHT!:
  72.             set {_strip} to (new BoundingBox(0.5, 0.5, 0, 1, 1, 1))
  73.             set {_eigth} to {@sw-eigth}
  74.         else if {_shape} = Shape.OUTER_LEFT!:
  75.             set {_eigth} to {@ne-eigth}
  76.         else if {_shape} = Shape.OUTER_RIGHT!:
  77.             set {_eigth} to {@se-eigth}
  78.            
  79.    
  80.     set {_slab} to (new BoundingBox(0, 0, 0, 1, 0.5, 1)).shift({_v})
  81.    
  82.     {_strip} is set:
  83.         {_strip}.shift({_v})
  84.     {_eigth} is set:
  85.         {_eigth}.shift({_v})
  86.    
  87.     {_data}.getHalf() = Half.TOP!:
  88.         {_slab}.shift(vector(0, 0.5, 0))
  89.         {_strip} is set:
  90.             {_strip}.shift(vector(0, -0.5, 0))
  91.         {_eigth} is set:
  92.             {_eigth}.shift(vector(0, -0.5, 0))
  93.  
  94.     return ({_slab}, {_strip}, {_eigth})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement