Solved Block remove ProjectileHitEvent

Discussion in 'Spigot Plugin Development' started by ytTobyo, Jul 10, 2018.

  1. Hey everyone,
    I need help to remove the block where the entity lands but it set only the block over, look at the photo to understand i know that is written complicated!

    Look like:
  2. ScarabCoder

    ScarabCoder Retired Resource Staff

    Get that block's location, decrease the Y value by one, then set the block type at that location to AIR.
  3. It is so or because it doesn´t run?
    Code (Text):
        public void onHit(ProjectileHitEvent e) {
            if(e.getEntity() instanceof Snowball) {
                World world = e.getEntity().getWorld();
                Location loc = e.getEntity().getLocation();
                    world.getBlockAt(0, -1, 0).setType(Material.AIR);
  4. Use the loc.add(0, -1, 0).getblock()
    Don't use world;)
    • Like Like x 1
  5. ScarabCoder

    ScarabCoder Retired Resource Staff

    As @nukels said, modify the location of the block. What you're doing is getting the block as world coordinates 0, -1, 0, which is actually below the void.
  6. Oh I'm so stupid, thanks to you :)