[Tutorial] How do entities work and what can we do with them!

Discussion in 'Resources' started by bigteddy98, May 1, 2014.

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

    bigteddy98

    This resource is no longer availabe.
     
    Goblom, LCastr0, Skyost and 5 others like this.
  2. Offline

    TryB4

  3. Offline

    bigteddy98

    Thanks ;)
     
    TryB4 likes this.
  4. Offline

    ZodiacTheories

  5. Offline

    Shadow_Parallax

    Could I get some help with the clearing the list part? I'm not all that familiar with Reflection. Have used it a couple of times, but I just can't figure it out.
     
  6. Offline

    dubknights

    Great tutorial, keep it up :D
     
  7. Offline

    sahand777

    This is perfect! I love tutorials like this; step by step AND in depth! Bukkit forums NEEDS more tutorials like this so it can educate newbie coders like myself!
     
  8. Offline

    ResultStatic

    bigteddy98 i had gotten into pathfinders and figured out how they work somewhat. they have methods that are called at certain times for instance
    here is my custom pathfinder that extends pathfinder

    public void e(){ is called multiple times per second not sure how many tps, updating status and location here.

    public boolean a() { is weather it should call public void e(){ or move onto the next priority pathfinder

    they also have more , i think public void c(){ is called when a() is true not 100% sure tho

    here is what i used on e(){
    Code:
        @Override
    public void e(){
    if (loc != null){
    if (player != null){
    if (loc.distance(player.getLocation()) > 3){
    float speed = (float) 1.4;
    PathEntity p = e.getNavigation().a(Nms.getCraftPlayer(player));
    e.getNavigation().a(p, 1.4);
    }
    if (loc.distance(player.getLocation()) < 3){
          e.getControllerLook().a(Nms.getCraftPlayer(player), 10, 0);
          Vector vector = player.getLocation().toVector().subtract(e.getBukkitEntity().getLocation().toVector());
          e.getBukkitEntity().getVelocity().copy(vector);
         
          e.getControllerJump().a();
          if (e instanceof CustomTameable){
        CustomTameable t = (CustomTameable) e;
      if (t.getOwner().getName().equals(player.getName())){
      return;
      }
          }
          Nms.getCraftPlayer(player).damageEntity(DamageSource.mobAttack(e), damage);
          PacketManager.sendPacketToAll(PacketManager.genPacket().getArmAnimation(e,0));
          return;
          }
    }
    }
     
    }
    [CODE]@Override
        public boolean a() {
            this.loc = e.getBukkitEntity().getLocation();
            HashMap<Double,Player> p = new HashMap<Double,Player>();
            Double least = 100.0;
            for (Entity ent: e.getBukkitEntity().getNearbyEntities(distance, 3, distance)){
            if (ent instanceof Player){
                    if (e instanceof CustomTameable) {
                        CustomTameable t = (CustomTameable) e;
                        if (t.isTamed()) {
                            if (t.getOwner() != null) {
                                if (t.getOwner().getName().equals(((Player) ent).getName())) {
                                    continue;
                                }
                            }
                        }
                    }
                p.put(ent.getLocation().distance(loc),(Player) ent);
                //Bukkit.broadcastMessage(((Player) ent).getName());
         
            }
            }
            for (Double d: p.keySet()){
            if (d < least) {
                least = d;
            }
            }
     
     
        Player player = p.get(least);
        this.player = player;
            return true;
        }
    basically a(){ returns true if there is a player nearby, then while true the npc runs to the player and if they are close enough they crit them and do damage.
     
  9. Offline

    ChipDev

    Didn't even read the tutorial yet. Just need to make one comment.
    Our custom entity:
    Code:java
    1. Skeleton skele = world.spawn(loc, Skeleton.class);
    2. skele.setCustomName("Kanss, special..");
    3. skele.setCustomNameVisible(true);
    4.  

    Now time to read the post :)
     
Thread Status:
Not open for further replies.

Share This Page