Advertisement
CaptainLepidus

Copy Block

Dec 28th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. Block b = wo.getBlockAt(ox+i,oy+j,oz+k);
  2. Block nb = wo.getBlockAt(nx+i,ny+j,nz+k);
  3. nb.setType(b.getType());
  4. if (b.getType()!=Material.AIR) {
  5.     nb.setData(b.getData());
  6.     ///nb.getState().setData(b.getState().getData());
  7.     BlockState bs = b.getState();
  8.     BlockState nbs = nb.getState();
  9.     nbs.setType(bs.getType());
  10.     nbs.setData(bs.getData());
  11.     MaterialData md = bs.getData();
  12.     MaterialData nmd = nbs.getData();
  13.     nmd.setData(md.getData());
  14.     if (bs instanceof Sign) {
  15.         Sign s = (Sign) bs;
  16.         Sign ns = (Sign) nbs;
  17.         for(int z=0;z<4;z++) {
  18.             ns.setLine(z,s.getLine(z));
  19.         }
  20.         ns.setData(s.getData());
  21.         //neither setLine nor setData successfully copy the text on the sign.
  22.         //however, the sign's direction is properly copied
  23.     }
  24.     if (bs instanceof RedstoneTorch) {
  25.         //to-do
  26.         //the torches direction is not properly copied and thus they pop off the wall
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement