Solved How do you place a door?

Discussion in 'Spigot Plugin Development' started by Hex_27, Feb 1, 2020.

  1. This is my code
    Code (Java):
    data.setType(x,y,z,mat);
            data.setType(x,y+1,z,mat);
            //Bukkit.getLogger().info( data.getBlockData(x, y, z).getClass().getName());
            Door door = (Door) Bukkit.createBlockData(mat);
            door.setFacing(dir);
            door.setHalf(Half.BOTTOM);
            data.setBlockData(x,y,z,door);
           
            door = (Door) Bukkit.createBlockData(mat);;
            door.setFacing(dir);
            door.setHalf(Half.TOP);
            data.setBlockData(x,y+1,z,door);
    the data object
    Code (Java):
    public class PopulatorDataPostGen extends PopulatorDataAbstract {
        private World w;
        private Chunk c;
        public PopulatorDataPostGen(Chunk c){
            this.w = c.getWorld();
            this.c = c;
        }

        @Override
        public Material getType(int x, int y, int z) {
            return w.getBlockAt(x,y,z).getType();
        }

        @Override
        public BlockData getBlockData(int x, int y, int z) {
            return w.getBlockAt(x,y,z).getBlockData();
        }

        @Override
        public void setType(int x, int y, int z, Material type) {
            //if(type == Material.DIRT) Bukkit.getLogger().info("Set " + x + "," + y + "," + z + " to dirt.");
       
            w.getBlockAt(x, y, z).setType(type);
        }

        @Override
        public void setBlockData(int x, int y, int z, BlockData data) {
            w.getBlockAt(x,y,z).setBlockData(data);
        }

        @Override
        public Biome getBiome(int rawX, int rawY, int rawZ) {
            return w.getBlockAt(rawX,rawY,rawZ).getBiome();
        }

        @Override
        public int getChunkX() {
            return c.getX();
        }

        @Override
        public int getChunkZ() {
            return c.getZ();
        }

        @Override
        public void addEntity(int rawX, int rawY, int rawZ, EntityType type) {
            c.getWorld().spawnEntity(new Location(c.getWorld(),rawX,rawY,rawZ), type);
        }

    }
    Placing doors seems to break them, and though the doors are set, 2 iron door drops spawn with every door.
     
  2. Code (Java):
    protected void putDoor(final DoorPlacementInstruction instr) {
    final Block bottom = getWorld().getBlockAt(
    (int) instr.x(),
    (int) instr.y(),
    (int) instr.z()
    );
    final Block top = bottom.getRelative(BlockFace.UP, 1);
    top.setType(instr.material());
    bottom.setType(instr.material());
    top.setTypeIdAndData(64, (byte) 0x8, true);
    bottom.setTypeIdAndData(64, (byte) 0x4, true);
    }
     
  3. md_5

    Administrator Developer

    That's not 1.15.1 code

    @Hex_27 you probably need applyPhysics=false on (at least) the first half set
     
    • Agree Agree x 1
  4. You’re totally right, my bad
     
  5. I'll try that
     
  6. Yep worked
     
  7. How you can place door ?
    I'm looking and I can't find, you know?