Example #1
0
  /**
   * This function is used when two same-species animals in 'love mode' breed to generate the new
   * baby animal.
   */
  public EntityWolf spawnBabyAnimal(EntityAgeable par1EntityAgeable) {
    EntityWolf entitywolf = new EntityWolf(this.worldObj);
    String s = this.getOwnerName();

    if (s != null && s.trim().length() > 0) {
      entitywolf.setOwner(s);
      entitywolf.setTamed(true);
    }

    return entitywolf;
  }
Example #2
0
 /** Returns true if the mob is currently able to mate with the specified mob. */
 public boolean canMateWith(EntityAnimal par1EntityAnimal) {
   if (par1EntityAnimal == this) {
     return false;
   } else if (!this.isTamed()) {
     return false;
   } else if (!(par1EntityAnimal instanceof EntityWolf)) {
     return false;
   } else {
     EntityWolf entitywolf = (EntityWolf) par1EntityAnimal;
     return !entitywolf.isTamed()
         ? false
         : (entitywolf.isSitting() ? false : this.isInLove() && entitywolf.isInLove());
   }
 }
Example #3
0
  public boolean func_142018_a(
      EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase) {
    if (!(par1EntityLivingBase instanceof EntityCreeper)
        && !(par1EntityLivingBase instanceof EntityGhast)) {
      if (par1EntityLivingBase instanceof EntityWolf) {
        EntityWolf entitywolf = (EntityWolf) par1EntityLivingBase;

        if (entitywolf.isTamed() && entitywolf.func_130012_q() == par2EntityLivingBase) {
          return false;
        }
      }

      return par1EntityLivingBase instanceof EntityPlayer
              && par2EntityLivingBase instanceof EntityPlayer
              && !((EntityPlayer) par2EntityLivingBase)
                  .canAttackPlayer((EntityPlayer) par1EntityLivingBase)
          ? false
          : !(par1EntityLivingBase instanceof EntityHorse)
              || !((EntityHorse) par1EntityLivingBase).isTame();
    } else {
      return false;
    }
  }
Example #4
0
 @Override
 public boolean onSkillTrigger(EntityPlayer player) {
   if (!canPlayerUseSkill(player)) return false;
   player.inventory.consumeInventoryItem(Items.bone);
   player.worldObj.playSoundAtEntity(player, "mob.ghast.fireball", 1.0F, 1.0F);
   EntityWolf wolf = new EntityWolf(player.worldObj);
   wolf.setLocationAndAngles(
       player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
   wolf.spawnExplosionParticle();
   if (!player.worldObj.isRemote) {
     wolf.setTamed(true);
     wolf.getNavigator().clearPathEntity();
     wolf.setAttackTarget(null);
     wolf.setSitting(false);
     wolf.setHealth(20);
     wolf.setOwnerId(player.getUniqueID().toString());
     player.worldObj.setEntityState(wolf, (byte) 7);
     player.worldObj.spawnEntityInWorld(wolf);
   }
   return true;
 }
Example #5
0
  @Override
  public void setLivingAnimations(
      EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) {
    EntityWolf entitywolf = (EntityWolf) par1EntityLivingBase;

    if (entitywolf.isAngry()) {
      this.wolfTail.rotateAngleY = 0.0F;
    } else {
      this.wolfTail.rotateAngleY = MathHelper.cos(par2 * 0.6662F) * 1.4F * par3;
    }

    if (entitywolf.isSitting()) {
      this.wolfMane.setRotationPoint(-1.0F, 16.0F, -3.0F);
      this.wolfMane.rotateAngleX = ((float) Math.PI * 2F / 5F);
      this.wolfMane.rotateAngleY = 0.0F;
      this.wolfBody.setRotationPoint(0.0F, 18.0F, 0.0F);
      this.wolfBody.rotateAngleX = ((float) Math.PI / 4F);
      this.wolfTail.setRotationPoint(-1.0F, 21.0F, 6.0F);
      this.wolfLeg1.setRotationPoint(-2.5F, 22.0F, 2.0F);
      this.wolfLeg1.rotateAngleX = ((float) Math.PI * 3F / 2F);
      this.wolfLeg2.setRotationPoint(0.5F, 22.0F, 2.0F);
      this.wolfLeg2.rotateAngleX = ((float) Math.PI * 3F / 2F);
      this.wolfLeg3.rotateAngleX = 5.811947F;
      this.wolfLeg3.setRotationPoint(-2.49F, 17.0F, -4.0F);
      this.wolfLeg4.rotateAngleX = 5.811947F;
      this.wolfLeg4.setRotationPoint(0.51F, 17.0F, -4.0F);
    } else {
      this.wolfBody.setRotationPoint(0.0F, 14.0F, 2.0F);
      this.wolfBody.rotateAngleX = ((float) Math.PI / 2F);
      this.wolfMane.setRotationPoint(-1.0F, 14.0F, -3.0F);
      this.wolfMane.rotateAngleX = this.wolfBody.rotateAngleX;
      this.wolfTail.setRotationPoint(-1.0F, 12.0F, 8.0F);
      this.wolfLeg1.setRotationPoint(-2.5F, 16.0F, 7.0F);
      this.wolfLeg2.setRotationPoint(0.5F, 16.0F, 7.0F);
      this.wolfLeg3.setRotationPoint(-2.5F, 16.0F, -4.0F);
      this.wolfLeg4.setRotationPoint(0.5F, 16.0F, -4.0F);
      this.wolfLeg1.rotateAngleX = MathHelper.cos(par2 * 0.6662F) * 1.4F * par3;
      this.wolfLeg2.rotateAngleX = MathHelper.cos(par2 * 0.6662F + (float) Math.PI) * 1.4F * par3;
      this.wolfLeg3.rotateAngleX = MathHelper.cos(par2 * 0.6662F + (float) Math.PI) * 1.4F * par3;
      this.wolfLeg4.rotateAngleX = MathHelper.cos(par2 * 0.6662F) * 1.4F * par3;
    }

    this.wolfHeadMain.rotateAngleZ =
        entitywolf.getInterestedAngle(par4) + entitywolf.getShakeAngle(par4, 0.0F);
    this.wolfMane.rotateAngleZ = entitywolf.getShakeAngle(par4, -0.08F);
    this.wolfBody.rotateAngleZ = entitywolf.getShakeAngle(par4, -0.16F);
    this.wolfTail.rotateAngleZ = entitywolf.getShakeAngle(par4, -0.2F);
  }
 @Override
 protected Optional<DyeColor> getVal(EntityWolf container) {
   return Optional.of((DyeColor) (Object) container.getCollarColor());
 }
 @Override
 protected boolean set(EntityWolf container, DyeColor value) {
   container.setCollarColor((EnumDyeColor) (Object) value);
   return true;
 }
Example #8
0
  @Override
  public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) {
    if (ForgeHooks.onLivingAttack(this, par1DamageSource, par2)) return false;
    if (this.isEntityInvulnerable()) {
      return false;
    } else if (this.worldObj.isRemote) {
      return false;
    } else {
      this.entityAge = 0;

      if (this.getHealth() <= 0.0F) {
        return false;
      } else if (par1DamageSource.isFireDamage() && this.isPotionActive(Potion.fireResistance)) {
        return false;
      } else {
        if ((par1DamageSource == DamageSource.anvil
                || par1DamageSource == DamageSource.fallingBlock)
            && this.getCurrentItemOrArmor(4) != null) {
          this.getCurrentItemOrArmor(4)
              .damageItem((int) (par2 * 4.0F + this.rand.nextFloat() * par2 * 2.0F), this);
          par2 *= 0.75F;
        }

        this.limbSwingAmount = 1.5F;
        boolean flag = true;

        if ((float) this.hurtResistantTime > (float) this.maxHurtResistantTime / 2.0F) {
          if (par2 <= this.lastDamage) {
            return false;
          }

          this.damageEntity(par1DamageSource, par2 - this.lastDamage);
          this.lastDamage = par2;
          flag = false;
        } else {
          this.lastDamage = par2;
          this.prevHealth = this.getHealth();
          this.hurtResistantTime = this.maxHurtResistantTime;
          this.damageEntity(par1DamageSource, par2);
          this.hurtTime = this.maxHurtTime = 10;
        }

        this.attackedAtYaw = 0.0F;
        Entity entity = par1DamageSource.getEntity();

        if (entity != null) {
          if (entity instanceof EntityLivingBase) {
            this.setRevengeTarget((EntityLivingBase) entity);
          }

          if (entity instanceof EntityPlayer) {
            this.recentlyHit = 100;
            this.attackingPlayer = (EntityPlayer) entity;
          } else if (entity instanceof EntityWolf) {
            EntityWolf entitywolf = (EntityWolf) entity;

            if (entitywolf.isTamed()) {
              this.recentlyHit = 100;
              this.attackingPlayer = null;
            }
          }
        }

        if (flag) {
          this.worldObj.setEntityState(this, (byte) 2);

          if (par1DamageSource != DamageSource.drown) {
            this.setBeenAttacked();
          }

          if (entity != null) {
            double d0 = entity.posX - this.posX;
            double d1;

            for (d1 = entity.posZ - this.posZ;
                d0 * d0 + d1 * d1 < 1.0E-4D;
                d1 = (Math.random() - Math.random()) * 0.01D) {
              d0 = (Math.random() - Math.random()) * 0.01D;
            }

            this.attackedAtYaw = (float) (Math.atan2(d1, d0) * 180.0D / Math.PI) - this.rotationYaw;
            this.knockBack(entity, par2, d0, d1);
          } else {
            this.attackedAtYaw = (float) ((int) (Math.random() * 2.0D) * 180);
          }
        }

        if (this.getHealth() <= 0.0F) {
          if (flag) {
            this.playSound(this.getDeathSound(), this.getSoundVolume(), this.getSoundPitch());
          }

          this.onDeath(par1DamageSource);
        } else if (flag) {
          this.playSound(this.getHurtSound(), this.getSoundVolume(), this.getSoundPitch());
        }

        return true;
      }
    }
  }
  @Override
  public List<RandomMob> getRandomMobs(World world) {
    List<RandomMob> mobs = new ArrayList<RandomMob>();

    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityMooshroom.class, world), 20));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntitySlime.class, world), 20));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityCow.class, world), 100));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityChicken.class, world), 100));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntitySheep.class, world), 100));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityWitch.class, world), 10));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityGhast.class, world), 15));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityPig.class, world), 100));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityCreeper.class, world), 25));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntitySquid.class, world), 30));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityOcelot.class, world), 20));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityWolf.class, world), 20));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityBat.class, world), 35));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityHorse.class, world), 20));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityMinecartHopper.class, world), 15));

    EntityCreeper chargedCreeper = (EntityCreeper) MFRUtil.prepareMob(EntityCreeper.class, world);
    NBTTagCompound creeperNBT = new NBTTagCompound();
    chargedCreeper.writeToNBT(creeperNBT);
    creeperNBT.setBoolean("powered", true);
    creeperNBT.setShort("Fuse", (short) 120);
    chargedCreeper.readFromNBT(creeperNBT);
    mobs.add(new RandomMob(chargedCreeper, 5));

    EntityTNTPrimed armedTNT = (EntityTNTPrimed) MFRUtil.prepareMob(EntityTNTPrimed.class, world);
    armedTNT.fuse = 120;
    mobs.add(new RandomMob(armedTNT, 5));

    EntitySlime invisislime = (EntitySlime) MFRUtil.prepareMob(EntitySlime.class, world);
    invisislime.addPotionEffect(new PotionEffect(Potion.invisibility.id, 120 * 20));
    mobs.add(new RandomMob(invisislime, 5));

    EntityMooshroom invisishroom =
        (EntityMooshroom) MFRUtil.prepareMob(EntityMooshroom.class, world);
    invisishroom.addPotionEffect(new PotionEffect(Potion.invisibility.id, 120 * 20));
    mobs.add(new RandomMob(invisishroom, 5));

    EntityWolf invisiwolf = (EntityWolf) MFRUtil.prepareMob(EntityWolf.class, world);
    invisiwolf.addPotionEffect(new PotionEffect(Potion.invisibility.id, 120 * 20));
    invisiwolf.setAngry(true);
    mobs.add(new RandomMob(invisiwolf, 5));

    EntityTNTPrimed tntJockey = (EntityTNTPrimed) MFRUtil.prepareMob(EntityTNTPrimed.class, world);
    EntityBat tntMount = (EntityBat) MFRUtil.prepareMob(EntityBat.class, world);
    tntJockey.fuse = 120;
    tntJockey.mountEntity(tntMount);
    mobs.add(new RandomMob(tntMount, 2));

    EntitySkeleton skeleton1 = (EntitySkeleton) MFRUtil.prepareMob(EntitySkeleton.class, world);
    EntitySkeleton skeleton2 = (EntitySkeleton) MFRUtil.prepareMob(EntitySkeleton.class, world);
    EntitySkeleton skeleton3 = (EntitySkeleton) MFRUtil.prepareMob(EntitySkeleton.class, world);
    EntitySkeleton skeleton4 = (EntitySkeleton) MFRUtil.prepareMob(EntitySkeleton.class, world);
    skeleton4.mountEntity(skeleton3);
    skeleton3.mountEntity(skeleton2);
    skeleton2.mountEntity(skeleton1);
    mobs.add(new RandomMob(skeleton1, 2));

    EntityBlaze blazeJockey = (EntityBlaze) MFRUtil.prepareMob(EntityBlaze.class, world);
    EntityGhast blazeMount = (EntityGhast) MFRUtil.prepareMob(EntityGhast.class, world);
    blazeJockey.mountEntity(blazeMount);
    mobs.add(new RandomMob(blazeMount, 2));

    EntityCreeper creeperJockey = (EntityCreeper) MFRUtil.prepareMob(EntityCreeper.class, world);
    EntityCaveSpider creeperMount =
        (EntityCaveSpider) MFRUtil.prepareMob(EntityCaveSpider.class, world);
    creeperJockey.mountEntity(creeperMount);
    mobs.add(new RandomMob(creeperMount, 2));

    tntJockey = (EntityTNTPrimed) MFRUtil.prepareMob(EntityTNTPrimed.class, world);
    EntityXPOrb tntMount2 = (EntityXPOrb) MFRUtil.prepareMob(EntityXPOrb.class, world);
    tntJockey.fuse = 120;
    tntMount2.xpValue = 1;
    tntMount2.xpOrbAge = Short.MIN_VALUE;
    tntMount2.field_70532_c = Short.MAX_VALUE;
    tntJockey.mountEntity(tntMount2);
    mobs.add(new RandomMob(tntMount2, 2));

    creeperJockey = (EntityCreeper) MFRUtil.prepareMob(EntityCreeper.class, world);
    EntityXPOrb creeperMount2 = (EntityXPOrb) MFRUtil.prepareMob(EntityXPOrb.class, world);
    creeperMount2.xpValue = 1;
    creeperMount2.xpOrbAge = Short.MIN_VALUE;
    creeperMount2.field_70532_c = Short.MAX_VALUE;
    creeperJockey.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 20));
    creeperJockey.onStruckByLightning(null);
    creeperJockey.mountEntity(creeperMount2);
    mobs.add(new RandomMob(creeperMount2, 1));

    EntityEnderman direBane = (EntityEnderman) MFRUtil.prepareMob(EntityEnderman.class, world);
    direBane.addPotionEffect(new PotionEffect(Potion.regeneration.id, 120 * 20));
    direBane.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 120 * 20));
    direBane.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(120);
    direBane.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.7);
    direBane.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(15);
    direBane.getEntityAttribute(SharedMonsterAttributes.followRange).setAttribute(32);
    direBane.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setAttribute(1);
    direBane.stepHeight = 2;
    EntityPlayer player = world.getPlayerEntityByName("direwolf20");
    if (player != null) {
      direBane.setCustomNameTag("Bane of direwolf");
      direBane.setAlwaysRenderNameTag(true);
      direBane.func_110163_bv();
      ItemStack armor = new ItemStack(Item.plateGold);
      AutoEnchantmentHelper.addRandomEnchantment(direBane.getRNG(), armor, 60);
      int i = EntityLiving.getArmorPosition(armor);
      direBane.setCurrentItemOrArmor(i, armor);
      direBane.setEquipmentDropChance(i, 2.0F);
    }
    mobs.add(new RandomMob(direBane, 1));

    return mobs;
  }