Solved Help with setting blocks air ?

Discussion in 'Plugin Development' started by _Error, Jul 15, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    _Error

    Its working fine but its not setting the block to air. Help?
    Code:
    @EventHandler
    public void cobbleGeneration(BlockFromToEvent e) {
    Block b = e.getToBlock();
    if (e.getToBlock().getRelative(e.getFace()).getType() == Material.STATIONARY_WATER) {
    Location loc = b.getLocation();
    Location loc1 = b.getLocation();
    loc1.setY(loc1.getY() - 1);
    Location loc2 = b.getLocation();
    loc2.setY(loc2.getY() - 2);
    Location loc3 = b.getLocation();
    loc3.setY(loc3.getY() - 3);
    if (loc1.getBlock().getType() == Material.COAL_BLOCK) {
    if (loc2.getBlock().getType() == Material.DIAMOND_BLOCK) {
    if (loc3.getBlock().getType() == Material.HOPPER) {
    loc.getBlock().setType(Material.AIR);
    Location locb = e.getToBlock().getLocation();
    locb.getBlock().setType(Material.AIR);
    BlockState state = loc3.getBlock().getState();
    if (state instanceof Hopper) {
    Hopper h = (Hopper) state;
    Inventory inv = h.getInventory();
    inv.addItem(new ItemStack(Material.COBBLESTONE, 1));
    }
    }
    }
    }
    Sorry for asking twice today.
     
  2. @_Error Do you know that it is actually getting to lines 16 and 18?
     
  3. Offline

    _Error

    Yes, And sorry for having 2 set airs.
    I can know because its putting items into the hoppers, and I added debug messages and it's still reaching there.
     
  4. Offline

    TarsisPisso

    Its beacuse you have to get the relative and set the type to air
     
  5. Offline

    _Error

    Mhm? What do you mean by that? And the relative of what?

    EDIT: Do you guys know how(if it's possible) to place lava thats not a source block?
     
    Last edited: Jul 16, 2015
  6. @_Error Debug print out the location of the block you are trying to set to air and see what block it is.
     
  7. Offline

    _Error

    I decided to cancel event and it works, MARKED AS SOLVED.
     
Thread Status:
Not open for further replies.

Share This Page