Hello everyone! I cannot for the life of me figure out how to place a torch on a wall programmatically. What I tried so far is the following, but in both cases the torches just hover in mid air in an upright position right in front of the wall I want to place them on.
The first idea was doing the following (for simplicity just assume that I determined the correct block face beforehand):
The second idea was to set the "facing" of the torch block to the opposite value of the wall face, but that also doesn't help:
What is the general procedure of placing a torch on a wall?
The first idea was doing the following (for simplicity just assume that I determined the correct block face beforehand):
Java:
Block blkWall = world.getBlockAt(x, y, z);
Block blkTorch = blkWall.getRelative(BlockFace.WEST);
blkTorch.setType(Material.TORCH);
The second idea was to set the "facing" of the torch block to the opposite value of the wall face, but that also doesn't help:
Java:
Block blkWall = world.getBlockAt(x, y, z);
BlockFace bfWall = BlockFace.WEST;
BlockFace bfTorch = BlockFace.EAST;
Block blkTorch = blkWall.getRelative(bfWall);
blkTorch.setType(Material.TORCH);
BlockData blockData = blkTorch.getBlockData();
if (blockData instanceof Directional dir) {
dir.setFacing(bfTorch);
blkTorch.setBlockData(dir);
}
What is the general procedure of placing a torch on a wall?
Last edited: