Custom projectile or Block Iterator?

Discussion in 'Plugin Development' started by filoghost, Jul 8, 2013.

  1. Offline

    filoghost

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Hello, I'm coding a private Quake plugin. I searched on the forum, for other quake plugin, but I couldn't found something useful. I need to make a player shoot a very fast projectile, that cannot be seen, or to use a block iterator that can detect collisions with entities. How could I make a custom projectile entity, or a block iterator that detect entities?
  2. Offline

    Bart

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    You might be able to .setVelocity on an Arrow to speed it up.. I don't think a Block iterator is what you want.
  3. Offline

    MUG806

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    This may help, I modified this from code posted by Dirty Starfish to get the entity a player is looking at:
    Code:java
    1. //gets the first living entity the player is looking at within the range
    2. //modified from code by "Dirty Starfish"
    3. public static LivingEntity getTargetEntity(Player p, int range)
    4. {
    5. //get all entities near the player
    6. List<Entity> nearbyE = p.getNearbyEntities(range, range, range);
    7.  
    8. //find just living entities
    9. ArrayList<LivingEntity> livingE = new ArrayList<LivingEntity>();
    10. for (Entity e : nearbyE)
    11. {
    12. if (e instanceof LivingEntity)
    13. {
    14. livingE.add((LivingEntity) e);
    15. }
    16. }
    17.  
    18. //LivingEntity target = null;
    19. BlockIterator bItr = new BlockIterator(p, range);
    20. Block block;
    21. Location loc;
    22. int bx, by, bz;
    23. double ex, ey, ez;
    24. // loop through player's line of sight
    25. while (bItr.hasNext())
    26. {
    27. block = bItr.next();
    28. bx = block.getX();
    29. by = block.getY();
    30. bz = block.getZ();
    31. // check for entities near this block in the line of sight
    32. for (LivingEntity e : livingE)
    33. {
    34. loc = e.getLocation();
    35. ex = loc.getX();
    36. ey = loc.getY();
    37. ez = loc.getZ();
    38. if ((bx - .75 <= ex && ex <= bx + 1.75) && (bz - .75 <= ez && ez <= bz + 1.75) && (by - 1 <= ey && ey <= by + 2.5))
    39. {
    40. // entity is close enough, set target and stop
    41. return e;
    42. }
    43. }
    44. }
    45. return null;
    46. }

    This post has been edited 1 time. It was last edited by MUG806 Jul 8, 2013.
  4. Offline

    filoghost

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    The arrow would made a noise and would be affected by gravity...the problem of the block iterator is that doesn't look at collision boxes of blocks like fences and sugar canes...How could I make an invisible fireball, but that is a custom entity? I need a custom entity that as the same behaviour of the fireball...
  5. Online

    xTrollxDudex

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @filoghost
    You might as well setVelocity() on an arrow with MAX_INTEGER so it goes to fast to be seen? Then listen for arrow hit event and find out if what it hit was a Living Entity
  6. Offline

    filoghost

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    This could be a good idea, but I don't know if this will handle correctly collision box. I'm trying it right now :)
  7. Offline

    filoghost

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    At the end, the best way to do this is to spawn a super-fast arrow. How could I remove the sound effect, or better: how could I create a custom entity, that is like an arrow, but doesn't make sounds and is not affected by gravity? I tried with the source code, extending EntityArrow, but still nothing...

Share This Page