Minigun

Discussion in 'Plugin Development' started by goodstuff20, Mar 14, 2013.

Thread Status:
Not open for further replies.
  1. Hey guys,

    I wanted to make a mini gun plugin where when you have a special bow (shaped recipe) or just normal bow but for that eye of enter in inventory that you can shoot arrows 10 times as fast
    All help apreciated!
     
  2. Offline

    acerspyro

    You will need spout to do so, you know that?
     
  3. Offline

    Burnett1

    You could make a special bow from a recipe and make the new bow have a different name. So no i dont think you do need spout.
     
  4. Offline

    nicho96

    You could create a new ItemStack that would represent the minigun, create a custom crafting recipe to craft this new itemstack, then using an Event (PlayerInteractEvent perhaps?), check to see if the ItemInHand corresponds to your custom item stack, and if it does, run a bit of code that will shoot out arrows to your liking.

    Edit: I should add that spout would not be needed
     
  5. Offline

    TheButlah

    You could also rename it by getting the itemStack's ItemMeta and doing meta.setDisplayName("minigun")
     
  6. Thx guys I have already done some private plugins with recipes - I knew that - I was actioally just interested for the fast arrow shooting - thx though - could you pls explain it a bit more detailed pls?
     
  7. Offline

    nicho96

    What would you like explained more? The whole thing in general or the fast arrow shooting?
     
  8. Offline

    ZeusAllMighty11

    Check out my Github account, it contains a project called 'MoarStuff' that achieves this. :3

    Edit: Also, remember that copying is illegal under my license.
     
  9. Just the arrow shooting

    I though the plugin moat stuff is by this zombie guy?
    Ok I'll check it out

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

    fireblast709

    EntityShootBowEvent, anyone?
     
    XlegitXcrazymanX likes this.
  11. How can you shoot arrows so fast?

    Sry - never knew it was yours - wow you have sorted it very good

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

    fireblast709

    I ment that you should use it as the trigger of the minigun instead of PlayerInteractEvent. This gives you the LivingEntity that shoots, the ItemStack which shoots, the Projectile, and even the force (which you could use for a variable effect like amount or spread)
     
  13. Offline

    ZeusAllMighty11

    Are you able to change the projectile shot from it?
    Thanks.
     
  14. Offline

    fireblast709

  15. Offline

    Codex Arcanum

    Here is the way that I would do it. It probably isn't the best way, but oh well. Make an ArrayList<String>. Use that to store which players (stored by name) have a minigun turned on. Every time a player right-clicks with a minigun, remove them from the list if they were in it already, and add them if they weren't in it before. Start a synchronous repeating task that runs every tick or two that checks if each player in the list has the minigun in their hand and at least 1 arrow in their inventory. If they don't have one of those things, remove them from the list. Otherwise, remove one of the arrows, and fire an arrow in front of the player.
     
  16. Ok But with this i still can't change the amount of arrows per sercond (or is that the force)?

    Wait sry - I Didn't read right - but how can you change the amount of arrows because in the bukkit API setforce sais nothing

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

    fireblast709

    you cannot set the amount of arrows per second. But you can do several shots when firing once (including a small delay between the shots), using a BukkitRunnable (scheduler)
     
  18. ok and how does that work (bukkitrunnable does not tell me something)?

    how can you call the itemstackĀ“s itemmeta?

    I tried launchprojectile 10 times in a listener but they all shot at once - how can I set a small delay in bukkit?

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

    fireblast709

    Code:
    final Player player = (Player)event.getEntity();
    new BukkitRunnable()
    {
        int amount = 5;
        @Override
        public void run()
        {
            if(amount > 0)
            {
                player.launchProjectile(Arrow.class);
                amount--;
            }
            else
            {
                this.cancel();
            }
        }
    }.runTaskTimer(<plugin instance>, 0L, 5L);
    This code launches an arrow each 0.25 seconds, up to 5 arrows. I leave the rest of the checks to you.
     
  20. Offline

    chasechocolate

    PlayerInteractEvent. What do you mean "delay" a cool down?
     
  21. Offline

    caseif

  22. thx

    thx allot guys

    umm runTaskTimer(<plugin instance> dosent work :( it says its wrong

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

    MCForger

    I would recommend using something like this:
    Code:
            _plugin.getServer().getScheduler()
                    .scheduleSyncRepeatingTask(_plugin, new Runnable()
                    {
                        @Override
                        public void run()
                        {
                            teleportQue();
                            updateArenasPlayers();
                            updateSigns();
                        }
                    }, 40, 160);
    _plugin equals the plugin instance
     
  24. thx but what do you really mean by plugin instance - i thought it is if you do a seperate listener class then public goetterlistener(goetterschwert plugin) {
    plugin.getServer().getPluginManager().registerEvents(this, plugin);
    }
    but that would mean you have to make a seperate class - im a bit confiused
     
  25. Offline

    TheButlah

    once you have the ItemStack, do item.getItemMeta() to get an object representing the meta. Then once you have modified the meta how you want it, do item.setItemMeta(meta)
     
  26. Offline

    ZeusAllMighty11

    goodstuff20

    Because you do not seem to understand anything that anyone is saying of you, you are just copy and pasting!
     
  27. Offline

    fireblast709

    goodstuff20 Replace <plugin instance> with an instance of your plugin (and do not make a new one here, that is wrong). The instance of the plugin in the main class is 'this', otherwise you need to pass the 'this' along with the constructor (main class is the class that extends JavaPlugin)

    MCForger that code is the same as mine ;3 , yet I can cancel the task from the inside, and you cannot
     
  28. Thank you for helping me after all these questions!
     
Thread Status:
Not open for further replies.

Share This Page