コード例 #1
0
ファイル: EntityAnimal.java プロジェクト: keepcalm/mc-dev
  protected void a(Entity entity, float f) {
    if (entity instanceof EntityHuman) {
      if (f < 3.0F) {
        double d0 = entity.locX - this.locX;
        double d1 = entity.locZ - this.locZ;

        this.yaw = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
        this.b = true;
      }

      EntityHuman entityhuman = (EntityHuman) entity;

      if (entityhuman.bT() == null || !this.c(entityhuman.bT())) {
        this.target = null;
      }
    } else if (entity instanceof EntityAnimal) {
      EntityAnimal entityanimal = (EntityAnimal) entity;

      if (this.getAge() > 0 && entityanimal.getAge() < 0) {
        if ((double) f < 2.5D) {
          this.b = true;
        }
      } else if (this.love > 0 && entityanimal.love > 0) {
        if (entityanimal.target == null) {
          entityanimal.target = this;
        }

        if (entityanimal.target == this && (double) f < 3.5D) {
          ++entityanimal.love;
          ++this.love;
          ++this.e;
          if (this.e % 4 == 0) {
            this.world.addParticle(
                "heart",
                this.locX
                    + (double) (this.random.nextFloat() * this.width * 2.0F)
                    - (double) this.width,
                this.locY + 0.5D + (double) (this.random.nextFloat() * this.length),
                this.locZ
                    + (double) (this.random.nextFloat() * this.width * 2.0F)
                    - (double) this.width,
                0.0D,
                0.0D,
                0.0D);
          }

          if (this.e == 60) {
            this.b((EntityAnimal) entity);
          }
        } else {
          this.e = 0;
        }
      } else {
        this.e = 0;
        this.target = null;
      }
    }
  }
コード例 #2
0
ファイル: EntityAnimal.java プロジェクト: keepcalm/mc-dev
  protected Entity findTarget() {
    if (this.c > 0) {
      return null;
    } else {
      float f = 8.0F;
      List list;
      int i;
      EntityAnimal entityanimal;

      if (this.love > 0) {
        list =
            this.world.a(
                this.getClass(), this.boundingBox.grow((double) f, (double) f, (double) f));

        for (i = 0; i < list.size(); ++i) {
          entityanimal = (EntityAnimal) list.get(i);
          if (entityanimal != this && entityanimal.love > 0) {
            return entityanimal;
          }
        }
      } else if (this.getAge() == 0) {
        list =
            this.world.a(
                EntityHuman.class, this.boundingBox.grow((double) f, (double) f, (double) f));

        for (i = 0; i < list.size(); ++i) {
          EntityHuman entityhuman = (EntityHuman) list.get(i);

          if (entityhuman.bT() != null && this.c(entityhuman.bT())) {
            return entityhuman;
          }
        }
      } else if (this.getAge() > 0) {
        list =
            this.world.a(
                this.getClass(), this.boundingBox.grow((double) f, (double) f, (double) f));

        for (i = 0; i < list.size(); ++i) {
          entityanimal = (EntityAnimal) list.get(i);
          if (entityanimal != this && entityanimal.getAge() < 0) {
            return entityanimal;
          }
        }
      }

      return null;
    }
  }
コード例 #3
0
  public void c() {
    if (this.world.isStatic) {
      this.f = Math.max(0, this.f - 1);
    }

    super.c();
  }
コード例 #4
0
  public void a(NBTTagCompound nbttagcompound) {
    super.a(nbttagcompound);
    this.o(nbttagcompound.getBoolean("EatingHaystack"));
    this.k(nbttagcompound.getBoolean("Bred"));
    this.setHasChest(nbttagcompound.getBoolean("ChestedHorse"));
    this.m(nbttagcompound.getBoolean("HasReproduced"));
    this.setType(nbttagcompound.getInt("Type"));
    this.setVariant(nbttagcompound.getInt("Variant"));
    this.setTemper(nbttagcompound.getInt("Temper"));
    this.setTame(nbttagcompound.getBoolean("Tame"));
    if (nbttagcompound.hasKeyOfType("OwnerUUID", 8)) {
      this.setOwnerUUID(nbttagcompound.getString("OwnerUUID"));
    }
    // CraftBukkit start
    if (nbttagcompound.hasKey("Bukkit.MaxDomestication")) {
      this.maxDomestication = nbttagcompound.getInt("Bukkit.MaxDomestication");
    }
    // CraftBukkit end
    AttributeInstance attributeinstance = this.bb().a("Speed");

    if (attributeinstance != null) {
      this.getAttributeInstance(GenericAttributes.d).setValue(attributeinstance.b() * 0.25D);
    }

    if (this.hasChest()) {
      NBTTagList nbttaglist = nbttagcompound.getList("Items", 10);

      this.loadChest();

      for (int i = 0; i < nbttaglist.size(); ++i) {
        NBTTagCompound nbttagcompound1 = nbttaglist.get(i);
        int j = nbttagcompound1.getByte("Slot") & 255;

        if (j >= 2 && j < this.inventoryChest.getSize()) {
          this.inventoryChest.setItem(j, ItemStack.createStack(nbttagcompound1));
        }
      }
    }

    ItemStack itemstack;

    if (nbttagcompound.hasKeyOfType("ArmorItem", 10)) {
      itemstack = ItemStack.createStack(nbttagcompound.getCompound("ArmorItem"));
      if (itemstack != null && a(itemstack.getItem())) {
        this.inventoryChest.setItem(1, itemstack);
      }
    }

    if (nbttagcompound.hasKeyOfType("SaddleItem", 10)) {
      itemstack = ItemStack.createStack(nbttagcompound.getCompound("SaddleItem"));
      if (itemstack != null && itemstack.getItem() == Items.SADDLE) {
        this.inventoryChest.setItem(0, itemstack);
      }
    } else if (nbttagcompound.getBoolean("Saddle")) {
      this.inventoryChest.setItem(0, new ItemStack(Items.SADDLE));
    }

    this.cO();
  }
コード例 #5
0
 protected void c() {
   super.c();
   this.datawatcher.a(16, Integer.valueOf(0));
   this.datawatcher.a(19, Byte.valueOf((byte) 0));
   this.datawatcher.a(20, Integer.valueOf(0));
   this.datawatcher.a(21, String.valueOf(""));
   this.datawatcher.a(22, Integer.valueOf(0));
 }
コード例 #6
0
ファイル: EntityAnimal.java プロジェクト: keepcalm/mc-dev
  private void b(EntityAnimal entityanimal) {
    EntityAgeable entityageable = this.createChild(entityanimal);

    if (entityageable != null) {
      this.setAge(6000);
      entityanimal.setAge(6000);
      this.love = 0;
      this.e = 0;
      this.target = null;
      entityanimal.target = null;
      entityanimal.e = 0;
      entityanimal.love = 0;
      entityageable.setAge(-24000);
      entityageable.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);

      for (int i = 0; i < 7; ++i) {
        double d0 = this.random.nextGaussian() * 0.02D;
        double d1 = this.random.nextGaussian() * 0.02D;
        double d2 = this.random.nextGaussian() * 0.02D;

        this.world.addParticle(
            "heart",
            this.locX
                + (double) (this.random.nextFloat() * this.width * 2.0F)
                - (double) this.width,
            this.locY + 0.5D + (double) (this.random.nextFloat() * this.length),
            this.locZ
                + (double) (this.random.nextFloat() * this.width * 2.0F)
                - (double) this.width,
            d0,
            d1,
            d2);
      }

      this.world.addEntity(entityageable);
    }
  }
コード例 #7
0
  public void ab() {
    super.ab();
    if (this.bM > 0.0F) {
      float f = MathHelper.sin(this.aM * 3.1415927F / 180.0F);
      float f1 = MathHelper.cos(this.aM * 3.1415927F / 180.0F);
      float f2 = 0.7F * this.bM;
      float f3 = 0.15F * this.bM;

      this.passenger.setPosition(
          this.locX + (double) (f2 * f),
          this.locY + this.ad() + this.passenger.ac() + (double) f3,
          this.locZ - (double) (f2 * f1));
      if (this.passenger instanceof EntityLiving) {
        ((EntityLiving) this.passenger).aM = this.aM;
      }
    }
  }
コード例 #8
0
  public boolean mate(EntityAnimal entityanimal) {
    if (entityanimal == this) {
      return false;
    } else if (entityanimal.getClass() != this.getClass()) {
      return false;
    } else {
      EntityHorse entityhorse = (EntityHorse) entityanimal;

      if (this.cT() && entityhorse.cT()) {
        int i = this.getType();
        int j = entityhorse.getType();

        return i == j || i == 0 && j == 1 || i == 1 && j == 0;
      } else {
        return false;
      }
    }
  }
コード例 #9
0
  public void e() {
    if (this.random.nextInt(200) == 0) {
      this.cR();
    }

    super.e();
    if (!this.world.isStatic) {
      if (this.random.nextInt(900) == 0 && this.deathTicks == 0) {
        this.heal(1.0F, RegainReason.REGEN); // CraftBukkit
      }

      if (!this.cm()
          && this.passenger == null
          && this.random.nextInt(300) == 0
          && this.world.getType(
                  MathHelper.floor(this.locX),
                  MathHelper.floor(this.locY) - 1,
                  MathHelper.floor(this.locZ))
              == Blocks.GRASS) {
        this.o(true);
      }

      if (this.cm() && ++this.bD > 50) {
        this.bD = 0;
        this.o(false);
      }

      if (this.co() && !this.cb() && !this.cm()) {
        EntityHorse entityhorse = this.a(this, 16.0D);

        if (entityhorse != null && this.f(entityhorse) > 4.0D) {
          PathEntity pathentity =
              this.world.findPath(this, entityhorse, 16.0F, true, false, false, true);

          this.setPathEntity(pathentity);
        }
      }
    }
  }
コード例 #10
0
  public void b(NBTTagCompound nbttagcompound) {
    super.b(nbttagcompound);
    nbttagcompound.setBoolean("EatingHaystack", this.cm());
    nbttagcompound.setBoolean("ChestedHorse", this.hasChest());
    nbttagcompound.setBoolean("HasReproduced", this.cp());
    nbttagcompound.setBoolean("Bred", this.co());
    nbttagcompound.setInt("Type", this.getType());
    nbttagcompound.setInt("Variant", this.getVariant());
    nbttagcompound.setInt("Temper", this.getTemper());
    nbttagcompound.setBoolean("Tame", this.isTame());
    nbttagcompound.setString("OwnerUUID", this.getOwnerUUID());
    nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
    if (this.hasChest()) {
      NBTTagList nbttaglist = new NBTTagList();

      for (int i = 2; i < this.inventoryChest.getSize(); ++i) {
        ItemStack itemstack = this.inventoryChest.getItem(i);

        if (itemstack != null) {
          NBTTagCompound nbttagcompound1 = new NBTTagCompound();

          nbttagcompound1.setByte("Slot", (byte) i);
          itemstack.save(nbttagcompound1);
          nbttaglist.add(nbttagcompound1);
        }
      }

      nbttagcompound.set("Items", nbttaglist);
    }

    if (this.inventoryChest.getItem(1) != null) {
      nbttagcompound.set("ArmorItem", this.inventoryChest.getItem(1).save(new NBTTagCompound()));
    }

    if (this.inventoryChest.getItem(0) != null) {
      nbttagcompound.set("SaddleItem", this.inventoryChest.getItem(0).save(new NBTTagCompound()));
    }
  }
コード例 #11
0
 public void die(DamageSource damagesource) {
   super.die(damagesource);
   if (!this.world.isStatic) {
     this.cK();
   }
 }
コード例 #12
0
 protected void aC() {
   super.aC();
   this.bb().b(attributeJumpStrength);
   this.getAttributeInstance(GenericAttributes.a).setValue(53.0D);
   this.getAttributeInstance(GenericAttributes.d).setValue(0.22499999403953552D);
 }
コード例 #13
0
ファイル: EntityPig.java プロジェクト: DaMarine/Alkazia
 protected void h() {
   super.h();
   this.datawatcher.a(16, Byte.valueOf((byte) 0));
 }
コード例 #14
0
ファイル: EntityPig.java プロジェクト: DaMarine/Alkazia
 public void b(NBTTagCompound nbttagcompound) {
   super.b(nbttagcompound);
   nbttagcompound.setBoolean("Saddle", this.hasSaddle());
 }
コード例 #15
0
ファイル: EntityPig.java プロジェクト: DaMarine/Alkazia
 protected void aW() {
   super.aW();
   this.getAttributeInstance(GenericAttributes.maxHealth).setValue(10.0D);
   this.getAttributeInstance(GenericAttributes.d).setValue(0.25D);
 }
コード例 #16
0
ファイル: EntityPig.java プロジェクト: DaMarine/Alkazia
 public void a(NBTTagCompound nbttagcompound) {
   super.a(nbttagcompound);
   this.setSaddle(nbttagcompound.getBoolean("Saddle"));
 }
コード例 #17
0
 protected void a() {
   super.a();
   this.datawatcher.a(16, new Byte((byte) 0));
 }
コード例 #18
0
 protected void bl() {
   this.f = this.g.f();
   super.bl();
 }
コード例 #19
0
 public void a(NBTTagCompound nbttagcompound) {
   super.a(nbttagcompound);
   this.setSheared(nbttagcompound.getBoolean("Sheared"));
   this.setColor(nbttagcompound.getByte("Color"));
 }
コード例 #20
0
 public void b(NBTTagCompound nbttagcompound) {
   super.b(nbttagcompound);
   nbttagcompound.setBoolean("Sheared", this.isSheared());
   nbttagcompound.setByte("Color", (byte) this.getColor());
 }
コード例 #21
0
  public void h() {
    super.h();
    if (this.world.isStatic && this.datawatcher.a()) {
      this.datawatcher.e();
      this.cP();
    }

    if (this.bE > 0 && ++this.bE > 30) {
      this.bE = 0;
      this.b(128, false);
    }

    if (!this.world.isStatic && this.bF > 0 && ++this.bF > 20) {
      this.bF = 0;
      this.p(false);
    }

    if (this.bp > 0 && ++this.bp > 8) {
      this.bp = 0;
    }

    if (this.bq > 0) {
      ++this.bq;
      if (this.bq > 300) {
        this.bq = 0;
      }
    }

    this.bK = this.bJ;
    if (this.cm()) {
      this.bJ += (1.0F - this.bJ) * 0.4F + 0.05F;
      if (this.bJ > 1.0F) {
        this.bJ = 1.0F;
      }
    } else {
      this.bJ += (0.0F - this.bJ) * 0.4F - 0.05F;
      if (this.bJ < 0.0F) {
        this.bJ = 0.0F;
      }
    }

    this.bM = this.bL;
    if (this.cn()) {
      this.bK = this.bJ = 0.0F;
      this.bL += (1.0F - this.bL) * 0.4F + 0.05F;
      if (this.bL > 1.0F) {
        this.bL = 1.0F;
      }
    } else {
      this.bI = false;
      this.bL += (0.8F * this.bL * this.bL * this.bL - this.bL) * 0.6F - 0.05F;
      if (this.bL < 0.0F) {
        this.bL = 0.0F;
      }
    }

    this.bO = this.bN;
    if (this.x(128)) {
      this.bN += (1.0F - this.bN) * 0.7F + 0.05F;
      if (this.bN > 1.0F) {
        this.bN = 1.0F;
      }
    } else {
      this.bN += (0.0F - this.bN) * 0.7F - 0.05F;
      if (this.bN < 0.0F) {
        this.bN = 0.0F;
      }
    }
  }
コード例 #22
0
ファイル: EntityAnimal.java プロジェクト: keepcalm/mc-dev
 public boolean mate(EntityAnimal entityanimal) {
   return entityanimal == this
       ? false
       : (entityanimal.getClass() != this.getClass() ? false : this.r() && entityanimal.r());
 }
コード例 #23
0
  public void e(float f, float f1) {
    if (this.passenger != null && this.passenger instanceof EntityLiving && this.cu()) {
      this.lastYaw = this.yaw = this.passenger.yaw;
      this.pitch = this.passenger.pitch * 0.5F;
      this.b(this.yaw, this.pitch);
      this.aO = this.aM = this.yaw;
      f = ((EntityLiving) this.passenger).bd * 0.5F;
      f1 = ((EntityLiving) this.passenger).be;
      if (f1 <= 0.0F) {
        f1 *= 0.25F;
        this.bP = 0;
      }

      if (this.onGround && this.bt == 0.0F && this.cn() && !this.bI) {
        f = 0.0F;
        f1 = 0.0F;
      }

      if (this.bt > 0.0F && !this.cj() && this.onGround) {
        this.motY = this.getJumpStrength() * (double) this.bt;
        if (this.hasEffect(MobEffectList.JUMP)) {
          this.motY +=
              (double) ((float) (this.getEffect(MobEffectList.JUMP).getAmplifier() + 1) * 0.1F);
        }

        this.j(true);
        this.al = true;
        if (f1 > 0.0F) {
          float f2 = MathHelper.sin(this.yaw * 3.1415927F / 180.0F);
          float f3 = MathHelper.cos(this.yaw * 3.1415927F / 180.0F);

          this.motX += (double) (-0.4F * f2 * this.bt);
          this.motZ += (double) (0.4F * f3 * this.bt);
          this.makeSound("mob.horse.jump", 0.4F, 1.0F);
        }

        this.bt = 0.0F;
      }

      this.W = 1.0F;
      this.aQ = this.bk() * 0.1F;
      if (!this.world.isStatic) {
        this.i((float) this.getAttributeInstance(GenericAttributes.d).getValue());
        super.e(f, f1);
      }

      if (this.onGround) {
        this.bt = 0.0F;
        this.j(false);
      }

      this.aE = this.aF;
      double d0 = this.locX - this.lastX;
      double d1 = this.locZ - this.lastZ;
      float f4 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F;

      if (f4 > 1.0F) {
        f4 = 1.0F;
      }

      this.aF += (f4 - this.aF) * 0.4F;
      this.aG += this.aF;
    } else {
      this.W = 0.5F;
      this.aQ = 0.02F;
      super.e(f, f1);
    }
  }
コード例 #24
0
ファイル: EntityPig.java プロジェクト: DaMarine/Alkazia
 public void e(float f, float f1) {
   super.e(f, f1);
   if (f > 5.0F && this.passenger instanceof EntityHuman) {
     ((EntityHuman) this.passenger).b((Statistic) AchievementList.u);
   }
 }