Difficulty with fireballs instantly blowing up.

Discussion in 'Plugin Development' started by Father Of Time, Apr 20, 2012.

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

    Father Of Time

    Good afternoon all,

    This is a quick one, but does anyone know why fireballs are blowing up on me the second I spawn them? I've tried setting their fuse time, but they inherit from the explosives class and not primedTNT, so their is no fuse. I then thought it might just be an issue with collision because that seems to be what triggers the fireball explosion, so I tried spawning the fireball 5 tiles above me and make it shot straight up to test this, but it still instantly blew up...

    At this point I am just trying to get a fireball to spawn without instantly blowing up, the velocity and direction and all of that I can figure out no problem. Does anyone see how I can fix this issue with the following code:

    I've tried setting the player as the shooter of the fireball, but that didn't seem to resolve anything. My ultimate goal is to simple shot a fireball in the direction a player is looking as part of a larger project.

    If you have any suggestions please don't hesitate to share; Thank you in advance to all who lend a hand!
     
  2. Well, I'm personally use .setDirection instead of setting the velocity but that shouldn't be the problem...
     
  3. Offline

    Father Of Time

    Yes, I've tried both; setting the direction with the players direction then applying a velocity but unfortunately that didn't resolve the issue.

    So it sounds like you have tried this, and yours don't blow up?
     
  4. Offline

    nisovin

    Is there a reason you aren't using launchProjectile?
     
  5. I knew there was a method like this but I couldn't thought of the name.
     
  6. Offline

    Father Of Time

    Only because I tried that first and it did the exact same thing. The above was simply an attempt to do it manually since my hypothesis was that the fireball was instantly exploding because it was "colliding" with me while launching out of me, but that ended up not being the case (proven by spawning the fireball above me by 5 blocks).

    I've tried about 20 ways of coding this, but all end up in the fireball instantly exploding (except for spawncreature function, which just throws a casting exception).

    any idea why?
     
  7. Code:
    Fireball fb = this.b.getEntity().launchProjectile(Fireball.class);
    fb.setYield(range);
    fb.setBounce(false);
    fb.setDirection(p.getPlayer().getVelocity().add(p.getPlayer().getLocation().toVector().subtract(this.b.getEntity().getLocation().toVector()).normalize().multiply(Integer.MAX_VALUE)));
    I've been using this code which works just fine (well used the .spawn method earlier but it doesn't make any difference)
     
  8. Offline

    Father Of Time

    in your example what is p.getPlayer and what is this.b.getEntity? I'm assuming this.b.getEntity is the "shooter" and p.getPlayer is the target?
     
  9. Offline

    Taco

    You can use the method you originally had, but you need to add a line to set the shooter or else it won't work.
     
  10. Correct!
     
  11. Offline

    Tezlastorme

    I'm having the same problem and I'm still not understanding what p.getPlayer and this.b.getEntity are :eek:
     
  12. Both are entities whereas p.getPlayer returns the target, which is in this case a player (but doesn't really matter as long as you can get the location from it) and b.getEntity returns the entity that actually shoots the fireball which should be at least a living entity.
     
  13. Offline

    Tezlastorme

    :/ Well this is what I have so far:

    Code:
    @EventHandler(priority = EventPriority.NORMAL)
        public void onPlayerMove(PlayerMoveEvent event) {
                Fireball fireball = player.launchProjectile(Fireball.class);
        }
    How do I make this not blow up immediately?
     
  14. Offline

    Rockslide

    Fireballs blow up immediately if you do not do setShooter() for them.

    Fix:
    Code:
               
    Fireball fb = player.launchProjectile(Fireball.class);
    fb.setShooter(player);
    
    Thought I'd post that cause the question never got answered.

    If anyone would like the return the favor; tell me how to make fireballs not flicker as they fly :)
     
    CoDGuardian likes this.
Thread Status:
Not open for further replies.

Share This Page