Craftsmoker cannot be cast to block.smoker

Discussion in 'Plugin Development' started by GigaChadCat, Nov 19, 2021.

  1. Offline

    GigaChadCat

    Hello guys. I am trying to set a smoker to burning. I did something like that but it didnt work. It shows a error on console. What should I do? Whats wrong?
    upload_2021-11-19_11-27-1.png
    upload_2021-11-19_11-27-17.png
     
  2. Offline

    pixelrider2000

    I think you imported the wrong Smoker. So check if all your imports are bukkit
     
  3. Offline

    GigaChadCat

    import org.bukkit.block.Smoker;

    I think this is right...
     
  4. Offline

    pixelrider2000

    Do you have any craftbukkit imports in your class?
     
  5. Offline

    GigaChadCat

    I fixed the error on the console but now it dont working. There is no error now but I think I did something wrong... Whats wrong with this code?
    https://streamable.com/3p4mza

    Code:
        Block block = p.getTargetBlockExact(5);
                    Material type = block.getType();
                    BlockState state = block.getState();
                    Smoker smok = (Smoker) state;
                    BlockData data = block.getState().getBlockData();
                    smok.setBurnTime((short) 23323);
                    state.setBlockData((BlockData) data);
                    state.update();
                    p.sendBlockChange(block.getLocation(), data);
     

Share This Page