Custom projectile or Block Iterator?

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

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

    filoghost

    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

    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

    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. }
     
  4. Offline

    filoghost

    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. Offline

    xTrollxDudex

    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

    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

    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...
     
Thread Status:
Not open for further replies.

Share This Page