Solved Paintball gun

Discussion in 'Plugin Development' started by HelloThereItsMe, Jun 26, 2015.

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


    Can you give me tips on how to make a paintball gun and the blocks go back to it's original type after a while? Thanks!
  2. you can do that you shoot snowballs and maybe when you shoot them increase their velocity, and when they land you do something with the blocks. And to restore them I would recommend to create a class that contains all the data you want (the material, the byte 'data', the block state, the location), and when you do something with a block you add into a hashmap<int, blockdata> the time that you want it to be destroyed or changed, and the blockdata class you made. then in a timer you use go through every entry in the hashmap and remove on in the int, and when the int is 0 or lower, you remove it and set the block to the data stored in the blockdata class you made.
  3. Offline


    @HelloThereItsMe make a gun that shoots snowballs, listen on projectile hit event and turn the blocks to the colors, and make a bukkitrunnable to reset them back.
  4. Offline


    One trick that is important for something like this- when you color a block, check to see if that block is already colored- you'll need to keep a Map of all the blocks you've changed that are pending rollback.

    If the block is already colored, you need to save the original block state instead of the current.

    The reason is the following use case:

    1. I color a target white block red, it will rollback in 5 seconds by restoring the block to white
    2. 3 seconds later, I color that same block green, it will rollback in 5 seconds by restoring the block to red
    3. 2 seconds later, the block restores to white
    4. 3 seconds later the block "restores" back to red because #2 recorded it as red
    I hope that makes sense.
  5. Offline


    i have the effects and how to shoot... but i do not have the changing blocks to normal :)
  6. Offline


    Easy, in your event for when your projectile hits a block, make a BukkitRunnable

    new BukkitRunnable {
    public void run() {
    //do whatever you need here
    }.runTaskLater(plugin, 20 * how ever many seconds);
  7. Offline


    lol man.... thx but... the thread is from @HelloThereItsMe
  8. Offline


    One thing I have seen a plugin do for a similar task is, instead of storing the blocks you change and reverting, just use Player#sendBlockChange(). This has the effect of making the impact zone look "painted" but without any of the issues that may come with changing blocks (EG. a non-conductive block like glass transferring a redstone signal).
  9. Offline


    Whoops, idk why I tagged you xD
  10. Offline


    Thanks everybody! I made one
Thread Status:
Not open for further replies.

Share This Page