Creating an explosion if entity hits a wall

Discussion in 'Plugin Development' started by DS_STORE, Feb 6, 2016.

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

    DS_STORE

    I am currently using this code:
    Code:
    Entity snowball = player.getWorld().spawnEntity(loc.add(loc.getDirection).add(0, 1.5, 0), EntityType.SNOWBALL)
                snowball.setVelocity(loc.getDirection())
                new BukkitRunnable {
                  override def run(): Unit = {
                    Location loc = snowball.getLocation()
                    Boolean c = true
    
                    while (c) {
                      if (loc.equals(snowball.getLocation())) c = false
                      loc = snowball.getLocation()
                    }
    
                    loc.getWorld().createExplosion(loc, 3, true)
                  }
                }.runTaskAsynchronously(plugin)
    The problem is that it will shoot a snowball and create an explosion around me.
    Is there a way to check if the snowball hit a wall?
     
  2. Offline

    teej107

    @DS_STORE Yes there is, but more importantly stop violating thread safety and your code won't even compile.
    Show Spoiler
     
  3. Offline

    DS_STORE

    It may not compile because its some pseudo java i transscriped from my compiling scala source
    Thank you <3
     
Thread Status:
Not open for further replies.

Share This Page