[API] Flying blocks

Discussion in 'Resources' started by ase34, Mar 21, 2014.

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

    ase34

    flyingblocksapi
    API for developers to create flying and moving blocks

    This API will allow developers to make entities who appear to be a flying block, but are not affected by gravity unlike the ‘regular’ ones. The technique does not require constant cancellation of the gravity (by packets for example) and only uses the connection to the client during an explicit teleport or a change of the velocity.

    The technique is heavily inspired by Asdjke and his Holographic Displays. For further reading, please see the README of the project.

    If you want to use this API, please keep in mind that your pluign then depends on flyingblocksapi and that flyingblocksapi needs to be installed on the server. For downloads, please go to the BukkitDev project page.

    Showcase:
    Show Spoiler

    [​IMG]


    Usage Example:
    Show Spoiler

    To get a quick overview how easy it is to use the API, here's a bit of code spawning a block which constantly rises into the sky. However, there are a few more details you should know in the README.

    Code:java
    1. public class RisingBlockCommandExecutor implements CommandExecutor {
    2.  
    3. @Override
    4. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    5. // player check
    6. if (!(sender instanceof Player)) {
    7. sender.sendMessage("Only available as player!");
    8. return true;
    9. }
    10.  
    11. // variables
    12. final double velocity = args.length > 0 ? Double.parseDouble(args[0]) : 0.05;
    13.  
    14. // constants
    15. final Vector velocityVector = new Vector(0, velocity, 0);
    16. int trackerUpdateInterval = 4;
    17. // we can use a high update interval (0.5 seconds) because the velocity mainly handles the movement
    18.  
    19. // anonymous class
    20. FlyingBlock block = new FlyingBlock(Material.STONE, (byte) 0, trackerUpdateInterval) {
    21. @Override
    22. public void onTick() {
    23. // set velocity
    24. if (!this.getBukkitEntity().getVelocity().equals(velocityVector)) {
    25. // huh, wrong velocity, override...
    26. this.getBukkitEntity().setVelocity(velocityVector);
    27. }
    28. }
    29. };
    30. // spawn block
    31. block.spawn(((Player) sender).getLocation());
    32.  
    33. sender.sendMessage(ChatColor.GRAY + "Sucessfully spawned a rising block!");
    34. return true;
    35. }
    36.  
    37. }


    You just have to add the API to the classpath, but I also provide a maven repository. Please see in the README about more information.


     
    GrandmaJam, Aqua, TigerHix and 19 others like this.
  2. Offline

    axeldu18

    This API is very usefull, Thanks you ;)
     
    ase34 likes this.
  3. Offline

    ase34

    axeldu18 Thanks! However, this API was not used in another plugin yet (afaik). I am looking forward to the creations developers might make with this tool.
     
  4. Offline

    axeldu18

    I'll use it in one of my plugin for my server :) For decoration
     
  5. Offline

    SoThatsIt

    ase34 looks awesome! i did something similar to this where i made a falling sand ride a bat with custom ai with an invisibility potion:)
     
  6. Offline

    NinjaWAffles

    This looks pretty bad ass. The only thing is that the title of the topic bugs me, I'd rather it be, "[API] Flying Blocks." Just personal preference. Other than that, good job. :)
     
    Garris0n likes this.
  7. Offline

    Ultimate_n00b

    Why spawning a horse? But otherwise.. I was about to do this D: turns out you beat me to it. Good job on it by the way.
     
    ase34 likes this.
  8. Offline

    Gamecube762

    Looks nice, only problem is that the more entities, the higher the lag for weaker computers.
     
  9. Offline

    ItsLeoFTW

    Much wow, so cool, way amaze (this is epic!)
     
    GrandmaJam, JonasXPX and ase34 like this.
  10. Offline

    ase34

    Good suggestion, I'll change the title right now. :)
     
  11. Offline

    ase34

    Did someone actually created something with my API? I would really like to see the results.
     
  12. Offline

    Wizehh

    This is amazing!
     
  13. Is the wither skull invisible? In that case it woule be possible to make the falling sand entity ride the wither skull directly, wouldn't it?

    Awesome work, anyway!
     
  14. Offline

    Garris0n

    The wither skull is invisible when it has a velocity of 0, however this is setting the velocity of the skull to move the blocks smoothly.
     
  15. Offline

    ase34

    Garris0n is absolutely right. However, the actual skull is located 100 blocks above the appearance of the block (using the horses) and thus is too far away to be seen.
     
    MinecraftShamrock and Garris0n like this.
  16. Offline

    HeavyMine13

    Can I make a shape inside it?
     
  17. Offline

    ase34

    Inside what? I'm sorry, but could you please explain a bit more precisely to me?
     
  18. Offline

    HeavyMine13

    ase34 I meant like a black flag with an 8 inside!
     
  19. Offline

    ase34


    Of course, I am currently working on a plugin doing such tasks.
     
    HeavyMine13 likes this.
  20. Offline

    BungeeTheCookie

    ase34
    Could you make a version compatible with 1.6.4?
     
  21. Offline

    ase34

    It is quite a good idea making the entire plugin version-independent. Thanks for the idea, I'll try to implement that.
     
  22. Offline

    BungeeTheCookie


    It actually is impossible because some of your classes extend a craft class. You can't use reflection to bypass that. I was just wondering if you could make a github for a 1.6.4 version
     
  23. Offline

    ase34

  24. Offline

    GeorgeeeHD

    does anyone know how to recreate that flag?
     
  25. Offline

    Onlineids

    Code, this api, a minecraft server, and a minecraft account
     
  26. Offline

    GeorgeeeHD

    Thanks, got it working!
     
    TigerHix and ArthurMaker like this.
  27. Offline

    Ironfan

    Sorry to ask a maybe stupid question but for which Development Build exactly is the latest version of the api made for?
    I always get this Error when the plugin loads up http://pastebin.com/Fz0gXnj1 which then leads to more errors when I try to use the api from my plugin. :oops:

    Suggestion: I sometimes see the horse just for a split second... couldn't you just spawn it with a invisible potion effect with no particle animation and a very large duration? This way the client wouldn't even try to render it...

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

    ase34

    Ironfan Your information is correct, I made a quite stupid mistake, sorry. (note to self: test plugin first before pushing commit) I'm really sorry for the inconvenience. A working code (hopefully) was already pushed to GitHub (see commit ef23f8f).
     
  29. Offline

    Conarnar

    I think that if the client doesn't render the horse, it would make the blocks fall because the client thinks there is nothing under the blocks.
     
  30. Offline

    Monkeyboystein

    I find that this API cannot handle many flying blocks at once, i attempted to create a space ship out of them and it crashes the server evrytime, and i have it on a timer so its not spawning all the blocks at once
     
Thread Status:
Not open for further replies.

Share This Page