public void spawn(Vector3f pos, String name) throws ScriptErrorException {
   EntityLiving ent = null;
   if (name.equals("creeper")) {
     ent = new EntityCreeper(_world);
   } else if (name.equals("zombie")) {
     ent = new EntityZombie(_world);
   } else if (name.equals("spider")) {
     ent = new EntitySpider(_world);
   } else if (name.equals("skeleton")) {
     ent = new EntitySkeleton(_world);
   } else if (name.equals("pig")) {
     ent = new EntityPig(_world);
   } else if (name.equals("cow")) {
     ent = new EntityCow(_world);
   } else if (name.equals("chicken")) {
     ent = new EntityChicken(_world);
   } else if (name.equals("pigzombie")) {
     ent = new EntityPigZombie(_world);
   } else if (name.equals("enderman")) {
     ent = new EntityEnderman(_world);
   } else if (name.equals("enderdragon")) {
     ent = new EntityDragon(_world);
   } else if (name.equals("bat")) {
     ent = new EntityBat(_world);
   } else if (name.equals("villager")) {
     ent = new EntityVillager(_world);
   } else {
     throw new ScriptErrorException("Ent not found");
   }
   ent.initCreature();
   ent.setPosition(pos.getX(), pos.getY(), pos.getZ());
   _world.spawnEntityInWorld(ent);
 }
  private void spawnMob() {
    // TODO Check how many mobs are in the local area and don't spawn if > configurable amount

    @SuppressWarnings("unchecked")
    Iterator<EntityEggInfo> iterator = EntityList.entityEggs.values().iterator();
    List<Integer> ids = new ArrayList<Integer>();
    while (iterator.hasNext()) {
      EntityEggInfo entityegginfo = iterator.next();
      ids.add(entityegginfo.spawnedID);
    }
    // shuffle and pick from IDs
    Collections.shuffle(ids);
    int id = ids.get(0);
    Entity entity = null;
    entity = EntityList.createEntityByID(id, worldObj);

    if (entity != null && entity instanceof EntityLivingBase) {
      EntityLiving entityliving = (EntityLiving) entity;
      entity.setLocationAndAngles(
          xCoord + 2 + MathHelper.randomDoubleInRange(0, xLength - 3),
          yCoord + 1.0,
          zCoord + 2 + MathHelper.randomDoubleInRange(0, zLength - 3),
          net.minecraft.util.MathHelper.wrapAngleTo180_float(worldObj.rand.nextFloat() * 360.0f),
          0.0f);
      worldObj.spawnEntityInWorld(entity);
      entityliving.playLivingSound();
    }
  }
  public Entity spawnEntity(Entity par1Entity) {

    if (par1Entity instanceof EntityLivingBase && par1Entity.worldObj != null) {
      if (par1Entity instanceof EntitySkeleton) {
        ((EntitySkeleton) par1Entity).setSkeletonType(skeletonType);
        if (skeletonType == 1) {
          par1Entity.setCurrentItemOrArmor(0, new ItemStack(Items.stone_sword));
          ((EntitySkeleton) par1Entity).setEquipmentDropChance(0, 0f);
        } else {
          par1Entity.setCurrentItemOrArmor(0, new ItemStack(Items.bow));
        }
      } else ((EntityLiving) par1Entity).onSpawnWithEgg(null);

      if (!requiresPlayer) {
        ((EntityLiving) par1Entity).func_110163_bv();
        par1Entity
            .getEntityData()
            .setLong("SpawnedByDESpawner", getSpawnerWorld().getTotalWorldTime());
      }

      this.getSpawnerWorld().spawnEntityInWorld(par1Entity);
    }

    return par1Entity;
  }
Ejemplo n.º 4
0
  @Override
  public void onEntityCollidedWithBlock(
      World par1World, int par2, int par3, int par4, Entity entity) {
    if (entity.ticksExisted % 3 == 0
        && (entity instanceof EntityLiving)
        && !(entity.ridingEntity instanceof EntityBoat)) {
      // depth determines strength of hunger and weakness up to 3fold.
      int intensity =
          par1World.getBlockMaterial(par2, par3 + 1, par4)
                  == par1World.getBlockMaterial(par2, par3, par4)
              ? par1World.getBlockMaterial(par2, par3 + 2, par4)
                      == par1World.getBlockMaterial(par2, par3, par4)
                  ? 3
                  : 2
              : 1;

      EntityLiving entityliving = (EntityLiving) entity;

      PotionEffect weakness =
          entityliving.isEntityUndead()
              ? new PotionEffect(Potion.damageBoost.id, 24, 1)
              : new PotionEffect(Potion.weakness.id, 24, 1 * intensity);
      PotionEffect hunger = new PotionEffect(Potion.hunger.id, 6, 8 * intensity);
      entityliving.addPotionEffect(weakness);
      entityliving.addPotionEffect(hunger);
      if (entity instanceof EntityWaterMob && new Random().nextInt(500) < 1) {
        PotionEffect harm = new PotionEffect(Potion.harm.id, 1, 0);
        entityliving.addPotionEffect(harm);
      }
    }
  }
 protected PathNavigate getNavigator() {
   if (entityHost.isRiding()) {
     Entity ent = entityHost.ridingEntity;
     if (ent instanceof EntityLiving) {
       return ((EntityLiving) ent).getNavigator();
     }
   }
   return entityHost.getNavigator();
 }
  /** Updates the task */
  @Override
  public void updateTask() {
    double distToTargetSq =
        entityHost.getDistanceSq(
            attackTarget.posX, attackTarget.boundingBox.minY, attackTarget.posZ);
    boolean canSeeTarget = entityHost.getEntitySenses().canSee(attackTarget);

    if (canSeeTarget) {
      ++timeTargetVisible;
    } else {
      timeTargetVisible = 0;
    }

    boolean runningAway = isRunningAway();
    if (!runningAway) {
      runAwayTimer--;
    }

    if (!runningAway && distToTargetSq <= attackRangeSq && timeTargetVisible >= 20) {
      getNavigator().clearPathEntity();
    } else if (distToTargetSq > (attackRangeSq * 0.9)) {
      getNavigator().tryMoveToEntityLiving(attackTarget, getMoveSpeed());
    }

    if (canSeeTarget
        && entityHost.isRiding()
        && distToTargetSq < 36
        && runAwayTimer <= 0
        && runAway()) {
      --timeUntilNextAttack;
      return;
    }

    if (runningAway) {
      --timeUntilNextAttack;
      return;
    }

    entityHost.getLookHelper().setLookPositionWithEntity(attackTarget, 30.0F, 30.0F);

    if (--timeUntilNextAttack == 0) {
      if (distToTargetSq > attackRangeSq || !canSeeTarget) {
        return;
      }
      float rangeRatio = MathHelper.sqrt_double(distToTargetSq) / attackRange;
      rangeRatio = MathHelper.clamp_float(rangeRatio, 0.1f, 1);
      rangedAttackEntityHost.attackEntityWithRangedAttack(attackTarget, rangeRatio);
      timeUntilNextAttack =
          MathHelper.floor_float(
              rangeRatio * (maxRangedAttackTime - minRangedAttackTime) + minRangedAttackTime);
    } else if (timeUntilNextAttack < 0) {
      float rangeRatio = MathHelper.sqrt_double(distToTargetSq) / attackRange;
      timeUntilNextAttack =
          MathHelper.floor_float(
              rangeRatio * (maxRangedAttackTime - minRangedAttackTime) + minRangedAttackTime);
    }
  }
  @Override
  public boolean shouldAnimate() {
    // accessor method in AIAnimation that gives access to the entity
    EntityLiving living = getEntity();

    // must have an attack target
    if (living.getAttackTarget() == null) return false;

    return cooldownTicks-- <= 0;
  }
Ejemplo n.º 8
0
 @Override
 protected void applyAttackEffectsToEntity(World world, EntityLiving el) {
   double x = el.posX;
   double y = el.posY;
   double z = el.posZ;
   el.clearActivePotions();
   for (int h = 0; h < 5 && !(el instanceof EntityPlayer); h++) {
     ItemStack held = el.getCurrentItemOrArmor(h);
     el.setCurrentItemOrArmor(h, null);
     if (!world.isRemote && held != null) {
       EntityItem ei = new EntityItem(world, x, y, z, held);
       ReikaEntityHelper.addRandomDirVelocity(ei, 0.2);
       ei.delayBeforeCanPickup = 300;
       world.spawnEntityInWorld(ei);
     }
   }
   // ReikaChatHelper.writeEntity(world, el);
   if (el instanceof EntityDragon) {
     ((EntityDragon) el)
         .attackEntityFromPart(
             ((EntityDragon) el).dragonPartHead,
             DamageSource.setExplosionSource(new Explosion(worldObj, this, x, y, z, 20)),
             this.getAttackDamage());
     if (el.isDead || el.getHealth() <= 0) {
       RotaryAchievements.RAILDRAGON.triggerAchievement(gun.getPlacer());
     }
   } else el.attackEntityFrom(DamageSource.generic, this.getAttackDamage());
   if (el instanceof EntityPlayer) {
     if (el.isDead || el.getHealth() <= 0)
       RotaryAchievements.RAILKILLED.triggerAchievement((EntityPlayer) el);
   }
   el.motionX = motionX * power / 15F;
   el.motionY = motionY * power / 15F;
   el.motionZ = motionZ * power / 15F;
 }
Ejemplo n.º 9
0
 private void setDisplayNameFromEntityNameTag(ItemStack item, Entity ent) {
   if (ent instanceof EntityLiving) {
     EntityLiving entLiv = (EntityLiving) ent;
     if (entLiv.hasCustomNameTag()) {
       String name = entLiv.getCustomNameTag();
       if (name.length() > 0) {
         item.setStackDisplayName(name);
       }
     }
   }
 }
Ejemplo n.º 10
0
  /**
   * Renders the entity shadows at the position, shadow alpha and partialTickTime. Args: entity, x,
   * y, z, shadowAlpha, partialTickTime
   */
  private void renderShadow(
      Entity entityIn, double x, double y, double z, float shadowAlpha, float partialTicks) {
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(770, 771);
    this.renderManager.renderEngine.bindTexture(shadowTextures);
    World world = this.getWorldFromRenderManager();
    GlStateManager.depthMask(false);
    float f = this.shadowSize;

    if (entityIn instanceof EntityLiving) {
      EntityLiving entityliving = (EntityLiving) entityIn;
      f *= entityliving.getRenderSizeModifier();

      if (entityliving.isChild()) {
        f *= 0.5F;
      }
    }

    double d5 =
        entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double) partialTicks;
    double d0 =
        entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double) partialTicks;
    double d1 =
        entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double) partialTicks;
    int i = MathHelper.floor_double(d5 - (double) f);
    int j = MathHelper.floor_double(d5 + (double) f);
    int k = MathHelper.floor_double(d0 - (double) f);
    int l = MathHelper.floor_double(d0);
    int i1 = MathHelper.floor_double(d1 - (double) f);
    int j1 = MathHelper.floor_double(d1 + (double) f);
    double d2 = x - d5;
    double d3 = y - d0;
    double d4 = z - d1;
    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);

    for (BlockPos blockpos :
        BlockPos.getAllInBoxMutable(new BlockPos(i, k, i1), new BlockPos(j, l, j1))) {
      Block block = world.getBlockState(blockpos.down()).getBlock();

      if (block.getRenderType() != -1 && world.getLightFromNeighbors(blockpos) > 3) {
        this.func_180549_a(block, x, y, z, blockpos, shadowAlpha, f, d2, d3, d4);
      }
    }

    tessellator.draw();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.disableBlend();
    GlStateManager.depthMask(true);
  }
  /** Returns whether the EntityAIBase should begin execution. */
  public boolean shouldExecute() {
    if (!this.theDefendingTameable.isTamed()) {
      return false;
    } else {
      EntityLiving entityliving = this.theDefendingTameable.getOwner();

      if (entityliving == null) {
        return false;
      } else {
        this.theOwnerAttacker = entityliving.getAITarget();
        return this.isSuitableTarget(this.theOwnerAttacker, false);
      }
    }
  }
Ejemplo n.º 12
0
 // Extract to NBT
 public boolean writenbt(String[] nbtOperations) {
   try {
     NBTTagCompound entityNBT = new NBTTagCompound();
     entity.writeToNBT(entityNBT);
     new NBTWriter(nbtOperations).writeToNBT(entityNBT);
     entity.readFromNBT(entityNBT);
     return true;
   } catch (IllegalFormatException e) {
     JASLog.log().severe("Skipping NBT Write due to %s", e.getMessage());
   } catch (IllegalArgumentException e) {
     JASLog.log().severe("Skipping NBT Write due to %s", e.getMessage());
   }
   return false;
 }
Ejemplo n.º 13
0
  @SuppressWarnings("unchecked")
  @Override
  protected void onImpact(MovingObjectPosition par1MovingObjectPosition) {

    if (isExplode) {
      this.explodeSize = 3.0F;
    }

    if (isNuke) {
      this.explodeSize = 35.0F;
    }

    if (par1MovingObjectPosition.entityHit != null) {
      par1MovingObjectPosition.entityHit.attackEntityFrom(
          DamageSource.causeThrownDamage(this, this.getThrower()), 2);
      par1MovingObjectPosition.entityHit.setFire(5);
    }

    if (!this.worldObj.isRemote && !isNuke) {
      this.worldObj.newExplosion(
          (Entity) null, this.posX, this.posY, this.posZ, explodeSize, onFire, true);
      this.isDead = true;
    } else if (!this.worldObj.isRemote && isNuke) {
      this.worldObj.newExplosion(
          (Entity) null, this.posX, this.posY, this.posZ, explodeSize, onFire, true);
      Iterator<EntityLiving> itr =
          this.worldObj
              .getEntitiesWithinAABB(EntityLiving.class, this.boundingBox.expand(30, 30, 30))
              .iterator();
      while (itr.hasNext()) {
        EntityLiving entity = itr.next();
        double dx = Math.abs(entity.posX - this.posX);
        double dy = Math.abs(entity.posY - this.posY);
        double dz = Math.abs(entity.posZ - this.posZ);
        int distance = (int) Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2) + Math.pow(dz, 2));
        if (30 - distance >= 0) {
          entity.addPotionEffect(
              new PotionEffect(2, (60 + (30 - distance)) * 20, (30 - distance) / 5));
          entity.addPotionEffect(
              new PotionEffect(4, (60 + (30 - distance)) * 20, (30 - distance) / 5));
          entity.addPotionEffect(
              new PotionEffect(18, (60 + (30 - distance)) * 20, (30 - distance) / 5));
          entity.addPotionEffect(
              new PotionEffect(19, (60 + (30 - distance)) * 20, (30 - distance) / 5));
        }
      }
      this.isDead = true;
    }
  }
  /** Called when this EntityThrowable hits a block or entity. */
  @Override
  protected void onImpact(MovingObjectPosition mop) {
    this.spawnParticles();
    AxisAlignedBB bb = boundingBox.expand(4.0D, 2.0D, 4.0D);
    List eList = worldObj.getEntitiesWithinAABB(EntityLiving.class, bb);
    Iterator i = eList.iterator();
    while (i.hasNext()) {
      EntityLiving e = (EntityLiving) i.next();
      e.addPotionEffect(new PotionEffect(Potion.weakness.id, 1200, 0));
      e.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 1200, 0));
      e.addPotionEffect(new PotionEffect(Potion.poison.id, 1200, 0));
    }

    this.setDead();
  }
Ejemplo n.º 15
0
  /** (abstract) Protected helper method to read subclass entity data from NBT. */
  public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {

    if (par1NBTTagCompound.hasKey("Is Grounded")) {
      this.dataWatcher.updateObject(17, par1NBTTagCompound.getByte("Is Grounded"));
    }
    super.readEntityFromNBT(par1NBTTagCompound);
  }
 public static void dropCoins(EntityLiving entity) {
   if (isHostileEntity(entity) && !world.isRemote) {
     for (int i = 0; i < 15; i++) {
       entity.dropItem(InitItems.ItemCoins.itemID, 1);
     }
   }
 }
Ejemplo n.º 17
0
 public static String defaultGetBloodTexture(EntityLiving living) {
   return living instanceof EntitySquid
       ? "/ayamitsu/gore/misc/ink.png"
       : living.getCreatureAttribute() == EnumCreatureAttribute.ARTHROPOD
           ? "/ayamitsu/gore/misc/blood_blue.png"
           : "/ayamitsu/gore/misc/blood_red.png";
 }
Ejemplo n.º 18
0
 public EntityBKnife(World var1, EntityLiving var2) {
   super(var1);
   this.owner = var2;
   this.renderDistanceWeight = 10.0D;
   this.doesArrowBelongToPlayer = var2 instanceof EntityPlayer;
   this.setSize(0.5F, 0.5F);
   this.setLocationAndAngles(
       var2.posX,
       var2.posY + (double) var2.getEyeHeight(),
       var2.posZ,
       var2.rotationYaw,
       var2.rotationPitch);
   this.posX -= (double) (MathHelper.cos(this.rotationYaw / 180.0F * 3.141593F) * 0.16F);
   this.posY -= 0.10000000149011612D;
   this.posZ -= (double) (MathHelper.sin(this.rotationYaw / 180.0F * 3.141593F) * 0.16F);
   this.setPosition(this.posX, this.posY, this.posZ);
   this.yOffset = 0.0F;
   this.motionX =
       (double)
           (-MathHelper.sin(this.rotationYaw / 180.0F * 3.141593F)
               * MathHelper.cos(this.rotationPitch / 180.0F * 3.141593F));
   this.motionZ =
       (double)
           (MathHelper.cos(this.rotationYaw / 180.0F * 3.141593F)
               * MathHelper.cos(this.rotationPitch / 180.0F * 3.141593F));
   this.motionY = (double) (-MathHelper.sin(this.rotationPitch / 180.0F * 3.141593F));
   this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, 1.5F, 1.0F);
 }
Ejemplo n.º 19
0
  public EntityNutsCall(
      World par1World,
      EntityLiving par2EntityLiving,
      EntityLiving par3EntityLiving,
      float par4,
      float par5) {
    super(par1World);
    isImmuneToFire = true;
    this.renderDistanceWeight = 10.0D;
    this.shootingEntity = par2EntityLiving;

    if (par2EntityLiving instanceof EntityPlayer) {
      this.canBePickedUp = 1;
    }

    this.posY =
        par2EntityLiving.posY + (double) par2EntityLiving.getEyeHeight() - 0.10000000149011612D;
    double d0 = par3EntityLiving.posX - par2EntityLiving.posX;
    double d1 =
        par3EntityLiving.boundingBox.minY + (double) (par3EntityLiving.height / 3.0F) - this.posY;
    double d2 = par3EntityLiving.posZ - par2EntityLiving.posZ;
    double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2);

    if (d3 >= 1.0E-7D) {
      float f2 = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
      float f3 = (float) (-(Math.atan2(d1, d3) * 180.0D / Math.PI));
      double d4 = d0 / d3;
      double d5 = d2 / d3;
      this.setLocationAndAngles(
          par2EntityLiving.posX + d4, this.posY, par2EntityLiving.posZ + d5, f2, f3);
      this.yOffset = 0.0F;
      float f4 = (float) d3 * 0.2F;
      this.setThrowableHeading(d0, d1 + (double) f4, d2, par4, par5);
    }
  }
Ejemplo n.º 20
0
  public EntityNutsCall(World par1World, EntityLiving par2EntityLiving, float par3) {
    super(par1World);
    isImmuneToFire = true;
    this.renderDistanceWeight = 10.0D;
    this.shootingEntity = par2EntityLiving;

    if (par2EntityLiving instanceof EntityPlayer) {
      this.canBePickedUp = 1;
    }

    this.setSize(1.5F, 0.5F);
    this.setLocationAndAngles(
        par2EntityLiving.posX,
        par2EntityLiving.posY + (double) par2EntityLiving.getEyeHeight(),
        par2EntityLiving.posZ,
        par2EntityLiving.rotationYaw,
        par2EntityLiving.rotationPitch);
    this.posX -= (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F);
    this.posY -= 0.10000000149011612D;
    this.posZ -= (double) (MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F);
    this.setPosition(this.posX, this.posY, this.posZ);
    this.yOffset = 0.0F;
    this.motionX =
        (double)
            (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI)
                * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI));
    this.motionZ =
        (double)
            (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI)
                * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI));
    this.motionY = (double) (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI));
    this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, par3 * 1.5F, 1.0F);
  }
 public static int getMaxSpawnPackSize(EntityLiving entity) {
   LivingPackSizeEvent maxCanSpawnEvent = new LivingPackSizeEvent(entity);
   MinecraftForge.EVENT_BUS.post(maxCanSpawnEvent);
   return maxCanSpawnEvent.getResult() == Result.ALLOW
       ? maxCanSpawnEvent.maxPackSize
       : entity.getMaxSpawnedInChunk();
 }
Ejemplo n.º 22
0
 public EntityPokeBall(
     World world, EntityLiving entityliving, EntityPixelmon e, EnumPokeballs type) {
   super(world, entityliving);
   thrower = entityliving;
   endRotationYaw = entityliving.rotationYawHead;
   pixelmon = e;
   dataWatcher.addObject(10, type.getIndex());
   mode = Mode.full;
   float speed = 0.3f;
   this.setLocationAndAngles(
       entityliving.posX,
       entityliving.posY + (double) entityliving.getEyeHeight(),
       entityliving.posZ,
       entityliving.rotationYaw,
       entityliving.rotationPitch);
   this.posX -= (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F);
   this.posY -= 0.10000000149011612D;
   this.posZ -= (double) (MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F);
   this.setPosition(this.posX, this.posY, this.posZ);
   this.yOffset = 0.0F;
   this.motionX =
       (double)
               (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI)
                   * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI))
           * 0.8;
   this.motionZ =
       (double)
               (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI)
                   * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI))
           * 0.8;
   this.motionY = (double) (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI)) * 0.8;
 }
Ejemplo n.º 23
0
  /** This method gets called when the entity kills another one. */
  public void onKillEntity(EntityLiving par1EntityLiving) {
    super.onKillEntity(par1EntityLiving);

    if (this.worldObj.difficultySetting >= 2 && par1EntityLiving instanceof EntityVillager) {
      if (this.worldObj.difficultySetting == 2 && this.rand.nextBoolean()) {
        return;
      }

      bioZombie entityzombie =
          new bioZombie(
              this.worldObj,
              health,
              width,
              height,
              drops,
              experienceValue,
              AttackStrength,
              IsHostile);
      entityzombie.func_82149_j(par1EntityLiving);
      this.worldObj.removeEntity(par1EntityLiving);
      entityzombie.initCreature();
      entityzombie.setVillager(true);

      if (par1EntityLiving.isChild()) {
        entityzombie.setChild(true);
      }

      this.worldObj.spawnEntityInWorld(entityzombie);
      this.worldObj.playAuxSFXAtEntity(
          (EntityPlayer) null, 1016, (int) this.posX, (int) this.posY, (int) this.posZ, 0);
    }
  }
Ejemplo n.º 24
0
 protected void func_82420_a(EntityLiving par1EntityLiving, ItemStack par2ItemStack) {
   this.field_82423_g.heldItemRight =
       this.field_82425_h.heldItemRight =
           this.modelBipedMain.heldItemRight = par2ItemStack != null ? 1 : 0;
   this.field_82423_g.isSneak =
       this.field_82425_h.isSneak = this.modelBipedMain.isSneak = par1EntityLiving.isSneaking();
 }
 public EntityThrowable(World par1World, EntityLiving par2EntityLiving) {
   super(par1World);
   xTile = -1;
   yTile = -1;
   zTile = -1;
   inTile = 0;
   inGround = false;
   throwableShake = 0;
   ticksInAir = 0;
   thrower = par2EntityLiving;
   setSize(0.25F, 0.25F);
   setLocationAndAngles(
       par2EntityLiving.posX,
       par2EntityLiving.posY + (double) par2EntityLiving.getEyeHeight(),
       par2EntityLiving.posZ,
       par2EntityLiving.rotationYaw,
       par2EntityLiving.rotationPitch);
   posX -= MathHelper.cos((rotationYaw / 180F) * (float) Math.PI) * 0.16F;
   posY -= 0.10000000149011612D;
   posZ -= MathHelper.sin((rotationYaw / 180F) * (float) Math.PI) * 0.16F;
   setPosition(posX, posY, posZ);
   yOffset = 0.0F;
   float f = 0.4F;
   motionX =
       -MathHelper.sin((rotationYaw / 180F) * (float) Math.PI)
           * MathHelper.cos((rotationPitch / 180F) * (float) Math.PI)
           * f;
   motionZ =
       MathHelper.cos((rotationYaw / 180F) * (float) Math.PI)
           * MathHelper.cos((rotationPitch / 180F) * (float) Math.PI)
           * f;
   motionY = -MathHelper.sin(((rotationPitch + func_40074_d()) / 180F) * (float) Math.PI) * f;
   setThrowableHeading(motionX, motionY, motionZ, func_40077_c(), 1.0F);
 }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotNumber) {
    ItemStack stack = null;
    Slot slot = (Slot) inventorySlots.get(slotNumber);

    if ((slot != null) && (slot.getHasStack())) {
      ItemStack stack1 = slot.getStack();
      stack = stack1.copy();
      EntityEquipmentSlot desiredSlot = EntityLiving.getSlotForItemStack(stack);

      if (slotNumber == 0) // CraftingResult
      {
        if (!mergeItemStack(stack1, 13, 49, true)) return ItemStack.field_190927_a;

        slot.onSlotChange(stack1, stack);
      } else if ((slotNumber >= 1) && (slotNumber < 5)) // CraftingGrid
      {
        if (!mergeItemStack(stack1, 13, 49, false)) return ItemStack.field_190927_a;
      } else if ((slotNumber >= 5) && (slotNumber < 13)) // NormalArmor & CosmeticArmor
      {
        if (!mergeItemStack(stack1, 13, 49, false)) return ItemStack.field_190927_a;
      } else if (desiredSlot.getSlotType() == EntityEquipmentSlot.Type.ARMOR
          && !inventorySlots
              .get(8 - desiredSlot.getIndex())
              .getHasStack()) // ItemArmor - check NormalArmor slots
      {
        int j = 8 - desiredSlot.getIndex();

        if (!mergeItemStack(stack1, j, j + 1, false)) return ItemStack.field_190927_a;
      } else if (desiredSlot.getSlotType() == EntityEquipmentSlot.Type.ARMOR
          && !inventorySlots
              .get(12 - desiredSlot.getIndex())
              .getHasStack()) // ItemArmor - check CosmeticArmor slots
      {
        int j = 12 - desiredSlot.getIndex();

        if (!mergeItemStack(stack1, j, j + 1, false)) return ItemStack.field_190927_a;
      } else if ((slotNumber >= 13) && (slotNumber < 40)) // PlayerInventory
      {
        if (!mergeItemStack(stack1, 40, 49, false)) return ItemStack.field_190927_a;
      } else if ((slotNumber >= 40) && (slotNumber < 49)) // PlayerHotBar
      {
        if (!mergeItemStack(stack1, 13, 40, false)) return ItemStack.field_190927_a;
      } else if (!mergeItemStack(stack1, 13, 49, false)) {
        return ItemStack.field_190927_a;
      }

      if (stack1.func_190916_E() == 0) slot.putStack(ItemStack.field_190927_a);
      else slot.onSlotChanged();

      if (stack1.func_190916_E() == stack.func_190916_E()) return ItemStack.field_190927_a;

      slot.func_190901_a(player, stack1);

      if (slotNumber == 0) player.dropItem(stack1, false);
    }

    return stack;
  }
 /**
  * Triggered whenever an entity collides with this block (enters into the block). Args: world, x,
  * y, z, entity
  */
 @Override
 public void onEntityCollidedWithBlock(World par1World, int x, int y, int z, Entity par5Entity) {
   if (par5Entity instanceof EntityLiving) {
     if (par5Entity.isInsideOfMaterial(this.blockMaterial)) {
       ((EntityLiving) par5Entity).addPotionEffect(new PotionEffect(Potion.blindness.id, 20, 2));
     }
   }
 }
  public void invocaMob(EntityLiving mob, int v, int x, int y, int z) {

    if (!this.worldObj.isRemote) {
      mob.setPositionAndRotation(posX + x, posY + y, posZ + z, 0, 0);

      worldObj.spawnEntityInWorld(mob);
    }
  }
Ejemplo n.º 29
0
  public EntityAIDoorInteract(EntityLiving p_i1621_1_) {
    this.field_179507_b = BlockPos.ORIGIN;
    this.theEntity = p_i1621_1_;

    if (!(p_i1621_1_.getNavigator() instanceof PathNavigateGround)) {
      throw new IllegalArgumentException("Unsupported mob type for DoorInteractGoal");
    }
  }
Ejemplo n.º 30
0
  public static void onAttackEntityFrom(DamageSource damage, EntityLiving living) {
    if (living.getHealth() > 0 && living.hurtTime <= 0) {
      float f = 0.41F;

      if (living.canBleed() && living.canBleedByDamage(damage)) {
        Entity entity = damage.getEntity();

        if (GoreRegistry.containsFarDamage(damage.damageType)) {
          produceBlood(MathHelper.floor_double(GoreRegistry.AMOUT_PARTICLES * f), false, living);
        } else if (entity instanceof EntityPlayer) {
          ItemStack is = ((EntityPlayer) entity).getCurrentEquippedItem();

          if (living.canHurtByItem(is)) {
            f = 1.0F;
            living.isBleeding = true;
            living.ticksActuallyBleeding = 0;
            living.ticksNoBlood = 0;
            produceBlood(MathHelper.floor_double(GoreRegistry.AMOUT_PARTICLES * f), false, living);
          }
        } else {
          produceBlood(MathHelper.floor_double(GoreRegistry.AMOUT_PARTICLES * f), false, living);
        }
      }
    }
  }