Shoot block then remove and explode on hit

Discussion in 'Plugin Development' started by creatorfromhell, Jun 30, 2013.

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


    Hello, I'm currently stuck on a small portion of my plugin. I want to spawn a projectile block per say, but when it hits the ground of an entity I want to remove the spawned dropped item, and then create an explosion where it hit.

    I've finished making the projectile block itself, but I'm stuck on the removing, and creating an explosion where it hits part.

    The section of my interact event code:
    else if(event.getMaterial().equals(Material.IRON_BLOCK)) {
                    Item item = player.getWorld().dropItemNaturally(player.getEyeLocation(), new ItemStack(Material.IRON_BLOCK, 1));

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 2, 2016
  2. Offline


    Since it isn't a typical projectile you obviously can't use the event onHit so in cases like this I create a repeating task to monitor the velocity. I conclude that a "projectile" has hit something when any of the three axis reach a certain threshold. This threshold is the hard part to get how you want it though.

    Also what you can do is on each iteration of the runnable save the Vector in a class variable and check to see if the change is greater than say 10% for any of the three axis and if it is then act on it.

    Keep in mind that this idea may be weak against "projectiles" being shot straight up/down and might not work as expected.
  3. Offline

    Omega Haxors

    I have an idea! Launch it as a fallingblock and than use the falling block land event (whatever it's called) and check for the data within the entity you launched. Afterwards you can cancel the event (preventing the launched block from turning into an item or block) and run your code there.
  4. Offline


    jep, would be my opinion, too! the event is called entitychangeblockevent and in this case the entity is the fallingblock.
Thread Status:
Not open for further replies.

Share This Page