Fireballs?

Discussion in 'Plugin Development' started by Jayjay110, Jun 4, 2011.

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

    Jayjay110

    How do we create them?
     
  2. Offline

    DreadKyller

    would require client mod. Sorry, new content can not be added, only new features like gameplay, but no new blocks/specialeffects/etc... are possible without clientside modding
     
  3. Offline

    Dreadreaver

    Fireballs are already there .. they are fired by Ghasts !
     
  4. Offline

    Jayjay110

    Exactly, but how do we spawn them, new EntityFireball?
     
  5. Offline

    Dreadreaver

    Havent looked into the technical details yet but it should be possible with (Craft)Bukkit! I added (Craft) as the methods might be missing in Bukkit yet.
     
  6. Offline

    DreadKyller

    Oo, I see, I thought you were asking something else. Ok, I'll look into this as well.
     
  7. Offline

    Jayjay110

    (Craft)Bukkit? whats that casting bukkit to craft?

    yer lol :p
     
  8. Offline

    Dreadreaver

    lol dont think too much code all the time ... I just meant that you might have to use craftbukkit instead of bukkit
     
  9. Offline

    Jayjay110

    OH lols :p
     
  10. Offline

    DreadKyller

    ok, I think I may have found a way, not sure, and I not going to take 2 hours (not that long really) to make it and test to see if it works.

    Basically import org.bukkit.entity.Fireball and create a new fireball object. then set its location to a position in the world and that should make it appear, then I think just set its velocity, as seeing it's an entity I think that's how you could do it.

    I've done it with other entities, like spawning creepers I just make a new Creep entity and set a location using the teleport and it appeared...
     
  11. Offline

    Jayjay110

    cool thanks :)
     
  12. Offline

    DreadKyller

    Like I said, not sure if it'll work, but worth a try
     
  13. Offline

    Jayjay110

    How do u actuall spawn it? so far I have Fireball f = new Fireball() , that failed :p
     
  14. Offline

    DreadKyller

    I forget, I'd have to look up my script again. making a new entity was hard, I was confused for like 2 weeks, cause it's an interface, there's no constructors, I found a way but... I'll get back to you when I get it again.
     
  15. Offline

    Jayjay110

    K thanks :)
     
  16. Offline

    anon

    Look at nathanwolf spells source code. His plugin allows users to cast and shoot fireballs.
     
    Jayjay110 likes this.
  17. Offline

    marinating

    Courtesy of Nathanwolf:
    CraftPlayer craftPlayer = (CraftPlayer) player;
    EntityLiving playerEntity = craftPlayer.getHandle();
    EntityFireball fireball = new EntityFireball(((CraftWorld) player.getWorld()).getHandle(), playerEntity, dx, dy, dz);

    // Start it off a bit away from the player
    double distance = 4;
    Vector aim = targeting.getAimVector();
    fireball.locX = playerLoc.getX() + aim.getX() * distance;
    fireball.locY = playerLoc.getY() + (height / 2.0) + 0.5;
    fireball.locZ = playerLoc.getZ() + aim.getZ() * distance;

    ((CraftWorld) player.getWorld()).getHandle().a(fireball);
     
  18. Offline

    Jayjay110

    Thanks I got it now :)

    Lol thankyou more thats better than what I got, except for the .a part crashes and thinks its a lightning strike, instead do .addEntity

    Although how do u get targeting?

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

    marinating

    I like to use

    Location target = null;
    for (Block b : player.getLineOfSight(null, 200) {
    if (!b.getType().equals(Material.AIR) { target= b.getLocation(); }
     
  20. Offline

    Jayjay110

    What about the direction we fire the fireball? how do we set the vector angle?
     
  21. Offline

    nisovin

    You'd probably want to do player.getLocation().getDirection().
     
  22. Offline

    Jayjay110

    ty :D
    But it doesnt give any accuracy the way Im doing it, how would I spawn it directly were Im aiming, it seems to change to different directions all the time, unles when I double fire it goes perfectly straight
     
  23. Offline

    sunkid

    Fireballs are really iffy, I think! I spent quite a bit of time making them available in Bukkit via the World.spawn(Location, Class<? extends Entity>) method.

    Basically, they need a direction vector that's a bit larger than a normalized direction vector for better accuracy. See the [CraftBukkit implementation](https://github.com/Bukkit/CraftBukkit/commit/7a32a38e72e605d3d2c7c7fb5f979ab50f799291) for an example. For my own plugin CannonBall (soon to be named "Cannons and Grenades"), I calculate the player's hand position to make them fly from about there (they explode right away if spawned in an occupied location).

    They will still fly a bit off target though since they use a built-in random spread factor. If there is enough interest in exposing that (like it is for arrows), I would be happy to have a go at that.
     
  24. Offline

    codename_B

    Check out my SlimePlusPlus plugin (source in the jar) for a way to spawn fireballs :)
     
  25. Offline

    Jayjay110

    thanks :D

    btw what is the entity fish?

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

    sunkid

    It's not a fish! It's the little bobber at the end of a fishing line when you fish. Someone misnamed it and the associated Bukkit interface. :rolleyes:
     
  27. Offline

    Jayjay110

    Oh lol, I thought It was like a secret new entity that noone told us about :p
    I could read the code and I noticed it had something to do with the bobber But I just didnt realise lol Btw how do you spawn a fish then? world.spawn(location,fish);?

    While I have you here, since when has the play effect method been there?
     
  28. Offline

    p000ison

    Boom, Now there a a very easy method in bukkit: livingentity.launchProjectile(Fireball.class)
     
  29. Offline

    Magi1053

    I dont know why you are having such a hard trouble finding a way to shoot fireballs. The Essentials plugin allows a player to /fireball as well as assign a command such as /fireball to an item using /pt
     
Thread Status:
Not open for further replies.

Share This Page