1.15.2 Making custom projectiles?

Discussion in 'Spigot Plugin Development' started by hidden1nin, Feb 16, 2020.

Thread Status:
Not open for further replies.
  1. I want to have a spider fling webs, but I dont want to have a create a whole new class for it, as I also want to have a pistol that fires flint, and many more things, I thought of spawning an item in front of the player and giving it velocity, but how do I know if it hits? And how can I make something like a water gun where it's just water particles and no collisions between item and mob. Any assistance would be greatly appreciated.
     
  2. To add to this, how would I set the item type if I did summon and item, and how do I make it unnable to be picked up( I can make a scheduled task to delete it)
     
  3. I’m pretty sure there’s a very simple method like isNotNull() or something like that or isInAir() maybe?
     
  4. I'll give that a look, but if someone wouldn't mine helping me with the vector math required from shooting it away from a player if the player is firing it
     
  5. You can just shoot a regular projectile and use packets to remove it from the client(s) and to spawn another fake projectile for the visuals.
     
  6. Okay i got this from another post, but i don't know how to apply effects or damage after collision
    Code (Java):
       if(p.getInventory().getItemInMainHand().getType() == Material.CARROT){
                 Snowball projectile = p.launchProjectile(Snowball.class);
                 ((CraftSnowball) projectile).getHandle().setItem(CraftItemStack.asNMSCopy(new ItemStack(Material.CARROT)));
            }
     
    • Optimistic Optimistic x 1
  7. https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/pull-requests/475/overview

    There is an API for that in the pipeline. For setting the displayed ItemStack.
     
  8. huh, I didnt understand that, should i be listening for an event to be called when the carrot snoball hits an entity?
     
  9. Code (Java):
        @EventHandler(priority=EventPriority.HIGH)
        public void onProjectileHit(EntityDamageByEntityEvent event) {
            if(event.getDamager() instanceof Projectile&&event.getDamager()instanceof Snowball) {
                Snowball projectile = (Snowball) event.getDamager();
                Bukkit.broadcastMessage(projectile.getShooter().toString());

            }
        }
    is what im using for the collisions, it broadcasts the players name, but how do i see wht item the snowball is set to, i have only been able to set the value, not read the value
     
  10. The .getArmorItems returns blank
     
  11. If you want to make somethink like guns (or like perks on Mineplex) you must create own listener for PlayerInteractEvent and HashMap with special items
     
  12. so map the item the player is holding and their player ? okay thats useful
     
  13. yes, like that
    public static HashMap<Player, HashMap<ItemStack, SuperItem>> store = new HashMap<Player, HashMap<ItemStack, SuperItem>>();
     
  14. That works perfectly Thanks to everyone who helped!
     
Thread Status:
Not open for further replies.