Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void CreateRoad(World world, Location pos1, Location pos2, RoadStyle style)
- {
- @SuppressWarnings("unused")
- int xFrom,yFrom,zFrom,xTo,yTo,zTo;
- boolean side;
- if(pos1.getBlockX() > pos2.getBlockX())
- {
- xFrom = pos2.getBlockX();
- xTo = pos1.getBlockX();
- }
- else
- {
- xFrom = pos1.getBlockX();
- xTo = pos2.getBlockX();
- }
- if(pos1.getBlockY() > pos2.getBlockY())
- {
- yFrom = pos2.getBlockY();
- yTo = pos1.getBlockY();
- }
- else
- {
- yFrom = pos1.getBlockY();
- yTo = pos2.getBlockY();
- }
- if(pos1.getBlockZ() > pos2.getBlockZ())
- {
- zFrom = pos2.getBlockZ();
- zTo = pos1.getBlockZ();
- }
- else
- {
- zFrom = pos1.getBlockZ();
- zTo = pos2.getBlockZ();
- }
- Location pointer = new Location(world, xFrom, yFrom, zFrom);
- Block block;
- if((zTo-zFrom)>(xTo-xFrom))
- {
- side = true;
- }
- else
- {
- side = false;
- }
- for(int xz = (side?zFrom-style.Width:xFrom-style.Width); xz <= (side?zTo+style.Width:xTo+style.Width); xz++)
- {
- if(side) pointer.setZ(xz); else pointer.setX(xz);
- for(int w=0; w<=style.Width; w++)
- {
- block = world.getBlockAt(pointer);
- if(w == 0)
- {
- if((xz >= (side?zFrom:xFrom)) && (xz <= (side?zTo:xTo)))
- {
- block.setTypeIdAndData(44, (byte) style.CenterSlabData, true);
- }
- else
- {
- if(block.getTypeId() != 44)
- {
- if(xz == (side?zFrom-style.Width:xFrom-style.Width))
- {
- block.setTypeIdAndData(style.StairsId, (byte) (side?3:1), true);
- }
- else if(xz == (side?zTo+style.Width:xTo+style.Width))
- {
- block.setTypeIdAndData(style.StairsId, (byte) (side?2:0), true);
- }
- else
- {
- block.setTypeIdAndData(44, (byte) style.CornerSlabData, true);
- }
- }
- }
- }
- else if(w == style.Width)
- {
- if((xz == (side?zFrom-style.Width:xFrom-style.Width)) || (xz == (side?zTo+style.Width:xTo+style.Width)))
- {
- if(side) pointer.setX(xFrom+w); else pointer.setZ(zFrom+w);
- block = world.getBlockAt(pointer);
- if((block.getTypeId() != 44) && (block.getTypeId() != style.StairsId))
- block.setTypeId(style.BlockId);
- if(side) pointer.setX(xFrom-w); else pointer.setZ(zFrom-w);
- block = world.getBlockAt(pointer);
- if((block.getTypeId() != 44) && (block.getTypeId() != style.StairsId))
- block.setTypeId(style.BlockId);
- }
- else
- {
- if(side) pointer.setX(xFrom+w); else pointer.setZ(zFrom+w);
- block = world.getBlockAt(pointer);
- if(block.getTypeId() != 44)
- {
- if(block.getTypeId() == style.StairsId)
- {
- if(block.getData() != (side?0:2))
- {
- block.setTypeIdAndData(44, (byte) style.CornerSlabData, true);
- }
- }
- else
- {
- block.setTypeIdAndData(style.StairsId, (byte) (side?0:2), true);
- }
- }
- if(side) pointer.setX(xFrom-w); else pointer.setZ(zFrom-w);
- block = world.getBlockAt(pointer);
- if(block.getTypeId() != 44)
- {
- if(block.getTypeId() == style.StairsId)
- {
- if(block.getData() != (side?1:3))
- {
- block.setTypeIdAndData(44, (byte) style.CornerSlabData, true);
- }
- }
- else
- {
- block.setTypeIdAndData(style.StairsId, (byte) (side?1:3), true);
- }
- }
- }
- }
- else
- {
- if(xz == (side?zFrom-style.Width:xFrom-style.Width))
- {
- if(side) pointer.setX(xFrom+w); else pointer.setZ(zFrom+w);
- block = world.getBlockAt(pointer);
- if(block.getTypeId() != 44) block.setTypeIdAndData(style.StairsId, (byte) (side?3:1), true);
- if(side) pointer.setX(xFrom-w); else pointer.setZ(zFrom-w);
- block = world.getBlockAt(pointer);
- if(block.getTypeId() != 44) block.setTypeIdAndData(style.StairsId, (byte) (side?3:1), true);
- }
- else if(xz == (side?zTo+style.Width:xTo+style.Width))
- {
- if(side) pointer.setX(xFrom+w); else pointer.setZ(zFrom+w);
- block = world.getBlockAt(pointer);
- if(block.getTypeId() != 44) block.setTypeIdAndData(style.StairsId, (byte) (side?2:0), true);
- if(side) pointer.setX(xFrom-w); else pointer.setZ(zFrom-w);
- block = world.getBlockAt(pointer);
- if(block.getTypeId() != 44) block.setTypeIdAndData(style.StairsId, (byte) (side?2:0), true);
- }
- else
- {
- if(side) pointer.setX(xFrom+w); else pointer.setZ(zFrom+w);
- block = world.getBlockAt(pointer);
- if(block.getTypeId() != 44)
- {
- block.setTypeIdAndData(44, (byte) style.CornerSlabData, true);
- }
- if(side) pointer.setX(xFrom-w); else pointer.setZ(zFrom-w);
- block = world.getBlockAt(pointer);
- if(block.getTypeId() != 44)
- {
- block.setTypeIdAndData(44, (byte) style.CornerSlabData, true);
- }
- }
- }
- }
- if(side) pointer.setX(xFrom); else pointer.setZ(zFrom);
- }
- }
Add Comment
Please, Sign In to add comment