Solved Trying to spawn a static non-moving fireball

Discussion in 'Spigot Plugin Development' started by Steve362, Jun 14, 2018 at 3:11 AM.

  1. So basically I've searched the whole of the internet trying to figure out how to summon a ghast fireball that doesn't move and so the player can aim it and set its direction. I found I was able to do this with the vanilla command summoning the fireball with no direction or velocity. You can see what I am trying to do in the youtube video here:




    So what I am asking is if anyone can point me in the right direction to be able to use spigot api to do something like the video?
     
  2. Just spawn the fireball entity and set the velocity to 0. I'm not sure how well this will work though because the javadoc says fireballs don't take setVelocity well.
     
    • Like Like x 1
  3. maybe spawn an armorstand and put a fireball item as its helmet (or put on its main hand)
    when a player interacts at the armorstand, you can remove it and spawns a fireball
     
    • Like Like x 1
    • Agree Agree x 1
  4. since its an entity, make it ride another entity, like the armor stand for instance. not sure if that would work. what happens if you simply set the velocity to 0? fireballs arent affected by gravity
     
    • Like Like x 1
  5. Thanks everyone for the responses, I have set the fireball on the armor stand, but I have trouble detecting when a player left clicks the fireball / armor stand, as most of the block interact / entity interact events only seem to have just right clicking. Does anyone know what event I can use to detect when a player left clicks the armor stand or fireball?
     
  6. EntityDamageByEntityEvent is fired when a player left clicks an armor stand. I have no idea if it triggers for a fireball though.
     
  7. Are invisible armor stands clickable?
     
  8. Just spawn the fireball and set its movement speed to 0.
     
  9. Doesn't work, I've tried setting the velocity to 0, but it wont spawn without a direction.
     
  10. uses both EntityDamageByEntityEvent and PlayerArmorStandManipulateEvent, I've just tested it, worked for invisible armor stand
    Code (Text):

        private void spawnArmorStand(Player player) {
            Location location = player.getLocation().add(player.getLocation().getDirection().normalize().multiply(1.5));
            ArmorStand armorStand = player.getWorld().spawn(location, ArmorStand.class);
            armorStand.setHelmet(new ItemStack(Material.FIREBALL, 1));
            armorStand.setGravity(false);
            armorStand.setVisible(false);
            armorStand.setMetadata("fireball", new FixedMetadataValue(this, ""));
        }

        @EventHandler
        public void event(EntityDamageByEntityEvent e){
            if(e.getDamager() instanceof Player && e.getEntity() instanceof ArmorStand &&
                    e.getEntity().hasMetadata("fireball")){
                e.getEntity().remove();
                Player player = (Player) e.getDamager();
                Location location = player.getLocation().add(player.getLocation().getDirection().normalize().multiply(1.5));
                Fireball fireBall = player.getWorld().spawn(location, Fireball.class);
                fireBall.setDirection(player.getLocation().getDirection().normalize().multiply(5));
                e.setCancelled(true);
            }
        }

        @EventHandler
        public void event(PlayerArmorStandManipulateEvent e){
            if(e.getRightClicked().hasMetadata("fireball")){
                e.getRightClicked().remove();
                Player player = e.getPlayer();
                Location location = player.getLocation().add(player.getLocation().getDirection().normalize().multiply(1.5));
                Fireball fireBall = player.getWorld().spawn(location, Fireball.class);
                fireBall.setDirection(player.getEyeLocation().getDirection().normalize().multiply(5));
                e.setCancelled(true);
            }
        }
    or you can spawn a fake fireball using packets
     
    #10 AnhCraft, Jun 15, 2018 at 12:46 AM
    Last edited: Jun 15, 2018 at 3:29 AM
    • Informative Informative x 1
  11. Thank you so much, appreciate the help :)
     

Share This Page