Placing Doors from Plugins

Discussion in 'Plugin Development' started by Guybrush, Jan 28, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Guybrush

    I currently have a bit of code where I attempt to make a square room, and place a door on one side of the room, depending on what direction the player is currently facing.
    Code:
    Block door = player.getWorld().getBlockAt(x, y+1, z+2);
        				Block door2 = player.getWorld().getBlockAt(x, y+2, z+2);
        				Block torch = player.getWorld().getBlockAt(x+1, y+2, z+1);
        				Block torch2 = player.getWorld().getBlockAt(x-1, y+2, z+1);
        				blocks.remove(door);
        				blocks.remove(door2);
        				torch.setType(Material.TORCH);
        				torch2.setType(Material.TORCH);
        				door.setType(Material.WOODEN_DOOR);
        				byte b2 = 0x3;
        				door2.setType(Material.WOODEN_DOOR);
        				byte b = 0x11;
        				door2.setData(b);
        				door.setData(b2);
    This bit of code is running and getting called, everything's going fine, except that the door breaks into items, two items, when I attempt to place it. However...
    Code:
    Block door = player.getWorld().getBlockAt(x+2, y+1, z);
        				Block door2 = player.getWorld().getBlockAt(x+2, y+2, z);
        				Block torch = player.getWorld().getBlockAt(x+1, y+2, z+1);
        				Block torch2 = player.getWorld().getBlockAt(x+1, y+2, z-1);
        				blocks.remove(door);
        				blocks.remove(door2);
        				door2.setType(Material.WOODEN_DOOR);
        				byte b = 0x8;
        				door2.setData(b);
        				door.setType(Material.WOODEN_DOOR);
        				torch.setType(Material.TORCH);
        				torch2.setType(Material.TORCH);
        				blocks.add(torch);
        				blocks.add(torch2);
        				blocks.add(door);
        				blocks.add(door2);
    This code is working like a charm. The top code bit for placing the door looked like the one that works. Well, I figured the empty spot should be facing a different direction, so perhaps the data for the door needs to be different. Place a door the direction a door should go in the opening, and get the data values for said door, and viola, it's 3 and 11. Try 3 and 11. Well, as I said it's not working. Anyone know why?
     
Thread Status:
Not open for further replies.

Share This Page