@Override
    public void process(double time) {
      energy -= powerLoad.getRpPower() * time;
      if (inventory.getStackInSlot(EggIncubatorContainer.EggSlotId) != null) {
        descriptor.setState(powerLoad, true);
        if (energy <= 0) {
          inventory.decrStackSize(EggIncubatorContainer.EggSlotId, 1);
          EntityChicken chicken = new EntityChicken(node.coordonate.world());
          chicken.setGrowingAge(-24000);
          EntityLiving entityliving = (EntityLiving) chicken;
          entityliving.setLocationAndAngles(
              node.coordonate.x + 0.5,
              node.coordonate.y + 0.5,
              node.coordonate.z + 0.5,
              MathHelper.wrapAngleTo180_float(node.coordonate.world().rand.nextFloat() * 360.0F),
              0.0F);
          entityliving.rotationYawHead = entityliving.rotationYaw;
          entityliving.renderYawOffset = entityliving.rotationYaw;
          entityliving.func_110161_a((EntityLivingData) null);
          node.coordonate.world().spawnEntityInWorld(entityliving);
          entityliving.playLivingSound();
          // node.coordonate.world().spawnEntityInWorld());
          resetEnergy();

          needPublish();
        }
      } else {
        descriptor.setState(powerLoad, false);
        resetEnergy();
      }

      if (Math.abs(powerLoad.Uc - lastVoltagePublish) / descriptor.nominalVoltage > 0.1)
        needPublish();
    }
Ejemplo n.º 2
0
  @Override
  protected void entityInit() {
    super.entityInit();
    this.dataWatcher.addObject(13, Integer.valueOf(0));
    this.dataWatcher.addObject(14, Float.valueOf(1.0f));
    this.dataWatcher.addObject(15, Integer.valueOf(0));

    this.dataWatcher.addObject(24, new Float(1));
    this.dataWatcher.addObject(25, new Float(1));
    this.dataWatcher.addObject(26, new Float(1));
    this.dataWatcher.addObject(27, new Float(1));
    this.dataWatcher.addObject(28, new Float(1));
    this.dataWatcher.addObject(29, new Float(1));
  }
Ejemplo n.º 3
0
  /** (abstract) Protected helper method to read subclass entity data from NBT. */
  @Override
  public void readEntityFromNBT(NBTTagCompound nbt) {
    super.readEntityFromNBT(nbt);
    sex = nbt.getInteger("Sex");
    size_mod = nbt.getFloat("Size Modifier");

    strength_mod = nbt.getFloat("Strength Modifier");
    aggression_mod = nbt.getFloat("Aggression Modifier");
    obedience_mod = nbt.getFloat("Obedience Modifier");
    colour_mod = nbt.getFloat("Colour Modifier");
    climate_mod = nbt.getFloat("Climate Adaptation Modifier");
    hard_mod = nbt.getFloat("Hardiness Modifier");

    hunger = nbt.getInteger("Hunger");
    mateSizeMod = nbt.getFloat("MateSize");
    this.dataWatcher.updateObject(15, nbt.getInteger("Age"));
    nextEgg = nbt.getLong("nextEgg");
  }
Ejemplo n.º 4
0
  /** (abstract) Protected helper method to write subclass entity data to NBT. */
  @Override
  public void writeEntityToNBT(NBTTagCompound nbt) {
    super.writeEntityToNBT(nbt);
    nbt.setInteger("Sex", sex);
    nbt.setFloat("Size Modifier", size_mod);

    nbt.setFloat("Strength Modifier", strength_mod);
    nbt.setFloat("Aggression Modifier", aggression_mod);
    nbt.setFloat("Obedience Modifier", obedience_mod);
    nbt.setFloat("Colour Modifier", colour_mod);
    nbt.setFloat("Climate Adaptation Modifier", climate_mod);
    nbt.setFloat("Hardiness Modifier", hard_mod);

    nbt.setInteger("Hunger", hunger);
    nbt.setFloat("MateSize", mateSizeMod);
    nbt.setInteger("Age", getBirthDay());
    nbt.setLong("nextEgg", nextEgg);
  }
Ejemplo n.º 5
0
  /**
   * Called frequently so the entity can update its state every tick as required. For example,
   * zombies and skeletons use this to react to sunlight and start to burn.
   */
  @Override
  public void onLivingUpdate() {
    // Handle Hunger ticking
    if (hunger > 168000) {
      hunger = 168000;
    }
    if (hunger > 0) {
      hunger--;
    }

    syncData();
    if (isAdult()) {
      setGrowingAge(0);
    } else {
      setGrowingAge(-1);
    }

    roosterCrow();

    // Make sure that the vanilla egg timer is never after to reach 0 but always setting it back to
    // 9999
    this.timeUntilNextEgg = 9999;
    /** This Cancels out the changes made to growingAge by EntityAgeable */
    TFC_Core.PreventEntityDataUpdate = true;
    if (getGender() == GenderEnum.MALE) {
      nextEgg = 10000;
    }

    super.onLivingUpdate();
    TFC_Core.PreventEntityDataUpdate = false;

    if (hunger > 144000
        && rand.nextInt(100) == 0
        && getHealth() < TFC_Core.getEntityMaxHealth(this)
        && !isDead) {
      this.heal(1);
    }
  }
Ejemplo n.º 6
0
 @Override
 protected void applyEntityAttributes() {
   super.applyEntityAttributes();
   this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(50); // MaxHealth
 }
Ejemplo n.º 7
0
  public IEntityLivingData a(
      DifficultyInstance difficultyinstance, IEntityLivingData ientitylivingdata) {
    Object ientitylivingdata1 = super.a(difficultyinstance, ientitylivingdata);
    float f0 = difficultyinstance.c();

    this.j(this.V.nextFloat() < 0.55F * f0);
    if (ientitylivingdata1 == null) {
      ientitylivingdata1 =
          new EntityZombie.GroupData(
              this.o.s.nextFloat() < 0.05F, this.o.s.nextFloat() < 0.05F, null);
    }

    if (ientitylivingdata1 instanceof EntityZombie.GroupData) {
      EntityZombie.GroupData entityzombie_groupdata = (EntityZombie.GroupData) ientitylivingdata1;

      if (entityzombie_groupdata.b) {
        this.m(true);
      }

      if (entityzombie_groupdata.a) {
        this.l(true);
        if ((double) this.o.s.nextFloat() < 0.05D) {
          List list =
              this.o.a(EntityChicken.class, this.aQ().b(5.0D, 3.0D, 5.0D), IEntitySelector.b);

          if (!list.isEmpty()) {
            EntityChicken entitychicken = (EntityChicken) list.get(0);

            entitychicken.l(true);
            this.a((Entity) entitychicken);
          }
        } else if ((double) this.o.s.nextFloat() < 0.05D) {
          EntityChicken entitychicken1 = new EntityChicken(this.o);

          entitychicken1.b(this.s, this.t, this.u, this.y, 0.0F);
          entitychicken1.a(difficultyinstance, (IEntityLivingData) null);
          entitychicken1.l(true);
          this.o.d((Entity) entitychicken1);
          this.a((Entity) entitychicken1);
        }
      }
    }

    this.a(this.V.nextFloat() < f0 * 0.1F);
    this.a(difficultyinstance);
    this.b(difficultyinstance);
    if (this.p(4) == null) {
      Calendar calendar = this.o.Y();

      if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.V.nextFloat() < 0.25F) {
        this.c(4, new ItemStack(this.V.nextFloat() < 0.1F ? Blocks.aZ : Blocks.aU));
        this.bh[4] = 0.0F;
      }
    }

    this.a(SharedMonsterAttributes.c)
        .b(
            new AttributeModifier(
                "Random spawn bonus", this.V.nextDouble() * 0.05000000074505806D, 0));
    double d0 = this.V.nextDouble() * 1.5D * (double) f0;

    if (d0 > 1.0D) {
      this.a(SharedMonsterAttributes.b)
          .b(new AttributeModifier("Random zombie-spawn bonus", d0, 2));
    }

    if (this.V.nextFloat() < f0 * 0.05F) {
      this.a(b)
          .b(new AttributeModifier("Leader zombie bonus", this.V.nextDouble() * 0.25D + 0.5D, 0));
      this.a(SharedMonsterAttributes.a)
          .b(new AttributeModifier("Leader zombie bonus", this.V.nextDouble() * 3.0D + 1.0D, 2));
      this.a(true);
    }

    return (IEntityLivingData) ientitylivingdata1;
  }