How do I create a door?

Discussion in 'Plugin Development' started by X21_Eagle_X21, Aug 4, 2020.

  1. Offline

    X21_Eagle_X21

    Placing a door using code seems to be harder than I thought...

    I used the method I found here (but replacing MaterialData with BlockData because of deprecation), but I can't cast it to a door.

    I tried using a delayed task as well, but it just drops the door as an item...

    Code:
            p.getWorld().getBlockAt(3, 100, 1).setType(Material.IRON_DOOR);
            p.getWorld().getBlockAt(3, 101, 1).setType(Material.IRON_DOOR);
           
            scheduler.scheduleSyncDelayedTask(plugin, new Runnable() {
                public void run() {
                    Door d = (Door) p.getWorld().getBlockAt(3, 101, 1).getBlockData();
                    d.setHalf(Half.TOP);
                }
            }, 1);
     

Share This Page