Exemplo n.º 1
0
  public void sendData(Player[] players, EntityMetadata data) {
    SetEntityDataPacket pk = new SetEntityDataPacket();
    pk.eid = this.getId();
    pk.metadata = data == null ? this.dataProperties : data;

    Server.broadcastPacket(players, pk);
  }
Exemplo n.º 2
0
  @Override
  public void attack(EntityDamageEvent source) {
    super.attack(source);
    if (source.isCancelled()) return;
    if (source instanceof EntityDamageByEntityEvent) {
      Entity damager = ((EntityDamageByEntityEvent) source).getDamager();
      if (damager instanceof Player) {
        if (((Player) damager).isCreative()) {
          this.kill();
        }
        if (this.getHealth() <= 0) {
          if (((Player) damager).isSurvival()) {
            this.level.dropItem(this, new ItemBoat());
          }
          this.close();
        }
      }
    }

    EntityEventPacket pk = new EntityEventPacket();
    pk.eid = this.getId();
    pk.event =
        this.getHealth() <= 0
            ? EntityEventPacket.DEATH_ANIMATION
            : EntityEventPacket.HURT_ANIMATION;
    Server.broadcastPacket(this.hasSpawned.values(), pk);
  }