Guest User

Untitled

a guest
Mar 17th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.96 KB | None | 0 0
  1.     public void CreateRoad(World world, Location pos1, Location pos2, RoadStyle style)
  2.     {
  3.         @SuppressWarnings("unused")
  4.         int     xFrom,yFrom,zFrom,xTo,yTo,zTo;
  5.         boolean side;
  6.        
  7.         if(pos1.getBlockX() > pos2.getBlockX())
  8.         {
  9.             xFrom   = pos2.getBlockX();
  10.             xTo     = pos1.getBlockX();
  11.         }
  12.         else
  13.         {
  14.             xFrom   = pos1.getBlockX();
  15.             xTo     = pos2.getBlockX();
  16.         }
  17.         if(pos1.getBlockY() > pos2.getBlockY())
  18.         {
  19.             yFrom   = pos2.getBlockY();
  20.             yTo     = pos1.getBlockY();
  21.         }
  22.         else
  23.         {
  24.             yFrom   = pos1.getBlockY();
  25.             yTo     = pos2.getBlockY();
  26.         }
  27.         if(pos1.getBlockZ() > pos2.getBlockZ())
  28.         {
  29.             zFrom   = pos2.getBlockZ();
  30.             zTo     = pos1.getBlockZ();
  31.         }
  32.         else
  33.         {
  34.             zFrom   = pos1.getBlockZ();
  35.             zTo     = pos2.getBlockZ();
  36.         }
  37.        
  38.         Location    pointer = new Location(world, xFrom, yFrom, zFrom);
  39.         Block       block;
  40.        
  41.         if((zTo-zFrom)>(xTo-xFrom))
  42.         {
  43.             side = true;
  44.         }
  45.         else
  46.         {
  47.             side = false;
  48.         }
  49.        
  50.         for(int xz = (side?zFrom-style.Width:xFrom-style.Width); xz <= (side?zTo+style.Width:xTo+style.Width); xz++)
  51.         {
  52.             if(side) pointer.setZ(xz); else pointer.setX(xz);
  53.            
  54.             for(int w=0; w<=style.Width; w++)
  55.             {
  56.                 block = world.getBlockAt(pointer);
  57.                 if(w == 0)
  58.                 {
  59.                     if((xz >= (side?zFrom:xFrom)) && (xz <= (side?zTo:xTo)))
  60.                     {
  61.                         block.setTypeIdAndData(44, (byte) style.CenterSlabData, true);
  62.                     }
  63.                     else
  64.                     {
  65.                         if(block.getTypeId() != 44)
  66.                         {
  67.                             if(xz == (side?zFrom-style.Width:xFrom-style.Width))
  68.                             {
  69.                                 block.setTypeIdAndData(style.StairsId, (byte) (side?3:1), true);
  70.                             }
  71.                             else if(xz == (side?zTo+style.Width:xTo+style.Width))
  72.                             {
  73.                                 block.setTypeIdAndData(style.StairsId, (byte) (side?2:0), true);
  74.                             }
  75.                             else
  76.                             {
  77.                                 block.setTypeIdAndData(44, (byte) style.CornerSlabData, true);
  78.                             }
  79.                         }
  80.                     }
  81.                 }
  82.                 else if(w == style.Width)
  83.                 {
  84.                     if((xz == (side?zFrom-style.Width:xFrom-style.Width)) || (xz == (side?zTo+style.Width:xTo+style.Width)))
  85.                     {
  86.                         if(side) pointer.setX(xFrom+w); else pointer.setZ(zFrom+w);
  87.                         block = world.getBlockAt(pointer);
  88.                         if((block.getTypeId() != 44) && (block.getTypeId() != style.StairsId))
  89.                             block.setTypeId(style.BlockId);
  90.                        
  91.                         if(side) pointer.setX(xFrom-w); else pointer.setZ(zFrom-w);
  92.                         block = world.getBlockAt(pointer);
  93.                         if((block.getTypeId() != 44) && (block.getTypeId() != style.StairsId))
  94.                             block.setTypeId(style.BlockId);
  95.                     }
  96.                     else
  97.                     {
  98.                         if(side) pointer.setX(xFrom+w); else pointer.setZ(zFrom+w);
  99.                         block = world.getBlockAt(pointer);
  100.                         if(block.getTypeId() != 44)
  101.                         {
  102.                             if(block.getTypeId() == style.StairsId)
  103.                             {
  104.                                 if(block.getData() != (side?0:2))
  105.                                 {
  106.                                     block.setTypeIdAndData(44, (byte) style.CornerSlabData, true);
  107.                                 }
  108.                             }
  109.                             else
  110.                             {
  111.                                 block.setTypeIdAndData(style.StairsId, (byte) (side?0:2), true);
  112.                             }
  113.                         }
  114.                        
  115.                         if(side) pointer.setX(xFrom-w); else pointer.setZ(zFrom-w);
  116.                         block = world.getBlockAt(pointer);
  117.                         if(block.getTypeId() != 44)
  118.                         {
  119.                             if(block.getTypeId() == style.StairsId)
  120.                             {
  121.                                 if(block.getData() != (side?1:3))
  122.                                 {
  123.                                     block.setTypeIdAndData(44, (byte) style.CornerSlabData, true);
  124.                                 }
  125.                             }
  126.                             else
  127.                             {
  128.                                 block.setTypeIdAndData(style.StairsId, (byte) (side?1:3), true);
  129.                             }
  130.                         }
  131.  
  132.                     }
  133.                 }
  134.                 else
  135.                 {
  136.                     if(xz == (side?zFrom-style.Width:xFrom-style.Width))
  137.                     {
  138.                         if(side) pointer.setX(xFrom+w); else pointer.setZ(zFrom+w);
  139.                         block = world.getBlockAt(pointer);
  140.                         if(block.getTypeId() != 44) block.setTypeIdAndData(style.StairsId, (byte) (side?3:1), true);
  141.                         if(side) pointer.setX(xFrom-w); else pointer.setZ(zFrom-w);
  142.                         block = world.getBlockAt(pointer);
  143.                         if(block.getTypeId() != 44) block.setTypeIdAndData(style.StairsId, (byte) (side?3:1), true);
  144.                     }
  145.                     else if(xz == (side?zTo+style.Width:xTo+style.Width))
  146.                     {
  147.                         if(side) pointer.setX(xFrom+w); else pointer.setZ(zFrom+w);
  148.                         block = world.getBlockAt(pointer);
  149.                         if(block.getTypeId() != 44) block.setTypeIdAndData(style.StairsId, (byte) (side?2:0), true);
  150.                         if(side) pointer.setX(xFrom-w); else pointer.setZ(zFrom-w);
  151.                         block = world.getBlockAt(pointer);
  152.                         if(block.getTypeId() != 44) block.setTypeIdAndData(style.StairsId, (byte) (side?2:0), true);
  153.                     }
  154.                     else
  155.                     {
  156.                         if(side) pointer.setX(xFrom+w); else pointer.setZ(zFrom+w);
  157.                         block = world.getBlockAt(pointer);
  158.                         if(block.getTypeId() != 44)
  159.                         {
  160.                             block.setTypeIdAndData(44, (byte) style.CornerSlabData, true);
  161.                         }
  162.                        
  163.                         if(side) pointer.setX(xFrom-w); else pointer.setZ(zFrom-w);
  164.                         block = world.getBlockAt(pointer);
  165.                         if(block.getTypeId() != 44)
  166.                         {
  167.                             block.setTypeIdAndData(44, (byte) style.CornerSlabData, true);
  168.                         }
  169.                     }
  170.                 }
  171.             }
  172.             if(side) pointer.setX(xFrom); else pointer.setZ(zFrom);
  173.         }
  174.     }
Add Comment
Please, Sign In to add comment