spawn a door

Discussion in 'Plugin Development' started by Synchroneyes, Mar 20, 2020.

  1. Offline

    Synchroneyes

    Hello,
    i'm currently struggling trying to set a door to a location.
    I am working on saving blocks to a file, and set them back to their location.

    I am currently saving thses information about blocks
    Code:
    int posX, posY, posZ;
    Material material;
    Byte blockByte;
    BlockData blockData;
    
    function saveBlock:
    Code:
    public SaveableBlock(Block b) {
    this.posX = (int) b.getLocation().getX();
    this.posY = (int) b.getLocation().getY();
    this.posZ = (int) b.getLocation().getZ();
    this.world = b.getLocation().getWorld();
    this.location = b.getLocation();
    this.material = b.getType();
    this.blockByte = b.getState().getData().getData();
    this.blockData = b.getBlockData();
    }
    
    function revertBlock:
    Code:
    public void setBlock() {
     Location location = new Location(this.world, this.posX, this.posY, this.posZ);
     Block block = location.getBlock();
     block.setType(this.material);
     block.setBlockData(this.blockData);
     block.getState().getData().setData(this.blockByte);
    
     if (this.material.toString().toLowerCase().contains("door")) {
      Block top = block.getRelative(BlockFace.UP, 1);
      Door door = (Door) top.getState();
      door.setHalf(Bisected.Half.TOP);
    
    
     }
    
     block.getState().update();
    }
    
    I am able to save & revert every normal block, but i cant revert a door. It only set the lower body of the door, and i can't get it to set the upper part.
    I'm looking for a way to set the door to the "full state", where i can have either the lower part, and the lower part.

    I'm using the latest bukkit version, craftbukkit-1.15.1-R0.1-SNAPSHOT
     
    Last edited: Mar 20, 2020
  2. Offline

    Synchroneyes

    Anyone can give me advice or tell me how they would do it? :)
     
  3. Offline

    Synchroneyes

    bump :(
    Even if my code doesnt look correct, anyone ever successfully spawned a door ?
     

Share This Page