Make Snowman shoot snowballs mush faster

Discussion in 'Plugin Development' started by Pr0_fAssEr, Apr 9, 2015.

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

    Pr0_fAssEr

    i want snowman to shoot snowballs very fast (The snowman not the snowball them self)

    I dont care of the speed of the snowballs only the snowman's speed can you please help me?


    i dont have any idea of a code for this


    Code:
    package me.xeng.pvp;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Snowball;
    import org.bukkit.entity.Snowman;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageByEntityEvent;
    import org.bukkit.event.entity.ProjectileHitEvent;
    import org.bukkit.event.entity.ProjectileLaunchEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    import org.bukkit.scoreboard.Scoreboard;
    
    public class compass extends JavaPlugin implements Listener {
       
        Scoreboard board;
       
        public void onEnable() {
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
    }
       
        public void onDisable() {
           
        }
       
        @EventHandler
        public void snowball(EntityDamageByEntityEvent e) {
            if(e.getEntity() instanceof Player) {
                Player p = (Player) e.getEntity();
                if(e.getDamager() instanceof Snowball) {
                    Snowball sb = (Snowball) e.getDamager();
                    if(sb.getShooter() instanceof Snowman) {
                        e.setDamage(1);
                    }
                }
            }
        }
    
        public boolean onCommand(CommandSender sender, Command cmd, String tag, String[] args) {
            if(tag.equalsIgnoreCase("test")) {
                Player p = (Player)sender;
                for(int i=0; i < 3; i++) {
                    Snowman bro = (Snowman) p.getWorld().spawnEntity(p.getLocation(), EntityType.SNOWMAN);
                    bro.setCustomName(ChatColor.YELLOW + p.getName());
                    bro.setCustomNameVisible(true);
                    bro.setMaxHealth(20);
                    bro.setHealth(20);
                    bro.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100000, 2));
                    for(Entity ent : bro.getNearbyEntities(10 , 10, 10)) {
                        if(ent instanceof Player) {
                            Player nearby = (Player)ent;
                            bro.setTarget(p);
                        }
                    }
                    Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                       
                        @Override
                        public void run() {
                            bro.remove();
                           
                        }
                    }, 20 * 10);
                }
            }
            return false;
        }
    }
     
  2. Offline

    mine-care

    Read my signature.
    Follow naming convention.

    I am not aware of a way to do this by the api but from nms :3 (there is a method in CraftLivingEntity that is superclass of CraftSnowman)
     
  3. Offline

    Konato_K

    @Pr0_fAssEr A bukkit solution would be to use Snowman#launchProjectile

    A NMS one may require to override the mob and apply the PathfinderGoalArrowAttack with different parameters
     
  4. Offline

    Schaffer79

Thread Status:
Not open for further replies.

Share This Page