Package net.minecraft.entity

Examples of net.minecraft.entity.EntityLiving


      return true;
    if(currentItem != null && currentItem.getItem() instanceof ItemLead)
    {
      if(riddenByEntity != null && riddenByEntity instanceof EntityLiving && !(riddenByEntity instanceof EntityPlayer))
      {
        EntityLiving mob = (EntityLiving)riddenByEntity;
        riddenByEntity.mountEntity(null);
        mob.setLeashedToEntity(entityplayer, true);
        return true;
      }
      double checkRange = 10;
      List nearbyMobs = worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(posX - checkRange, posY - checkRange, posZ - checkRange, posX + checkRange, posY + checkRange, posZ + checkRange));
      for(Object obj : nearbyMobs)
      {
        EntityLiving entity = (EntityLiving)obj;
        if(entity.getLeashed() && entity.getLeashedToEntity() == entityplayer)
        {
          entity.mountEntity(this);
          looking.setAngles(-entity.rotationYaw, entity.rotationPitch, 0F);
          entity.clearLeashed(true, !entityplayer.capabilities.isCreativeMode);
        }
      }
      return true;
    }
    //Put them in the seat
View Full Code Here


    Entity entity = EntityList.createEntityByName(id, world);
    Handler handler = getHandler(id);
   
    if ((entity != null) && (handler != null) &&
        (entity instanceof EntityLiving)) {
      EntityLiving slime = (EntityLiving)entity;
     
      float rotation = MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F);
      slime.setLocationAndAngles(x + 0.5, y, z + 0.5, rotation, 0.0F);
      slime.rotationYawHead = slime.renderYawOffset = rotation;
     
      if (name != null) slime.setCustomNameTag(name);
      handler.setSize(slime, 1);
     
      NBTTagList effectList = (NBTTagList)StackUtils.getTag(stack, "Effects");
      if (effectList != null)
        for (int i = 0; i < effectList.tagCount(); i++)
          slime.addPotionEffect(PotionEffect.readCustomPotionEffectFromNBT(
              effectList.getCompoundTagAt(i)));
     
      world.spawnEntityInWorld(slime);
      slime.playSound("mob.slime.big", 1.2F, 0.6F);
     
      player.setCurrentItemOrArmor(EquipmentSlot.HELD, new ItemStack(Items.bucket));
    }
   
    return true;
View Full Code Here

  public static Entity spawnEntity(World world, Entity spawn, double x, double y, double z) {

    if (spawn != null && spawn instanceof EntityLiving) {

      EntityLiving living = (EntityLiving) spawn;
      spawn.setLocationAndAngles(x, y, z, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0f), 0.0f);
      living.rotationYawHead = living.rotationYaw;
      living.renderYawOffset = living.rotationYaw;
      living.onSpawnWithEgg((IEntityLivingData) null);
      world.spawnEntityInWorld(spawn);
      living.playLivingSound();
    }

    return spawn;
  }
View Full Code Here

                return;

            double x = posX + (rand.nextDouble() - rand.nextDouble()) * SPAWN_DIST;
            double y = (double) (posY + mob.height + rand.nextInt(3));
            double z = posZ + (rand.nextDouble() - rand.nextDouble()) * SPAWN_DIST;
            EntityLiving living = mob instanceof EntityLiving ? (EntityLiving) mob : null;
            mob.setLocationAndAngles(x, y, z, rand.nextFloat() * 360.0F, 0.0F);

            if (worldObj.checkNoEntityCollision(mob.boundingBox) && worldObj.getCollidingBoundingBoxes(mob, mob.boundingBox).isEmpty() && !worldObj.isAnyLiquid(mob.boundingBox)) {

                if (mob instanceof EntitySkeleton) {
                    EntitySkeleton skel = (EntitySkeleton) mob;
                    if (rand.nextInt(4) == 0) {
                        skel.tasks.addTask(4, new EntityAIAttackOnCollide(skel, EntityPlayer.class, 0.25F, false));
                        skel.setSkeletonType(1);
                        skel.setCurrentItemOrArmor(0, new ItemStack(Items.stone_sword));
                    } else {
                        skel.tasks.addTask(4, new EntityAIArrowAttack(skel, 0.25F, 60, 10.0F));
                        skel.setCurrentItemOrArmor(0, new ItemStack(Items.bow));
                    }

                    mob.setCurrentItemOrArmor(4, new ItemStack(this.rand.nextFloat() < 0.25F ? Blocks.lit_pumpkin : Blocks.pumpkin));
                } else if (living != null)
                    living.onSpawnWithEgg(null);

                this.worldObj.spawnEntityInWorld(mob);
                this.worldObj.playAuxSFX(2004, (int) x, (int) y, (int) z, 0);

                if (living != null)
                    living.spawnExplosionParticle();
            }
        }
    }
View Full Code Here

    {
        EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata());
        double d0 = par1IBlockSource.getX() + (double) enumfacing.getFrontOffsetX();
        double d1 = (double) ((float) par1IBlockSource.getYInt() + 0.2F);
        double d2 = par1IBlockSource.getZ() + (double) enumfacing.getFrontOffsetZ();
        EntityLiving entity = TitleIcon.activateSpawnEgg(par2ItemStack, par1IBlockSource.getWorld(), d0, d1, d2, 0);

        if (par2ItemStack.hasDisplayName())
        {
            ((EntityLiving) entity).setCustomNameTag(par2ItemStack.getDisplayName());
        }
View Full Code Here

                              if (var22 == null) {
                                break label103;
                              }
                            }

                            EntityLiving var39;

                            try {
                              var39 = (EntityLiving) var22.entityClass.getConstructor(World.class).newInstance(par0WorldServer);

                              var39.setLocationAndAngles((double) var24, (double) var25, (double) var26, par0WorldServer.rand.nextFloat() * 360.0F, 0.0F);

                              Event.Result canSpawn = ForgeEventFactory.canEntitySpawn(var39, par0WorldServer, var24, var25, var26);
                              if (canSpawn == Event.Result.ALLOW || (canSpawn == Event.Result.DEFAULT && var39.getCanSpawnHere())) {
                                ++var16;
                                par0WorldServer.spawnEntityInWorld(var39);
                                if (!ForgeEventFactory.doSpecialSpawn(var39, par0WorldServer, var24, var25, var26)) {
                                  unusedEntityLivingData = var39.onSpawnWithEgg(unusedEntityLivingData);
                                }

                                if (var16 >= var39.getMaxSpawnedInChunk()) {
                                  continue label110;
                                }
                              }

                              var4 += var16;
View Full Code Here

            SpawnListEntry creatureClass = worldServer.spawnRandomCreature(creatureType, ssX, ssY, ssZ);
            if (creatureClass == null) {
              break;
            }

            EntityLiving spawnedEntity;
            try {
              spawnedEntity = (EntityLiving) creatureClass.entityClass.getConstructor(World.class).newInstance(worldServer);
              spawnedEntity.setLocationAndAngles((double) ssX, (double) ssY, (double) ssZ, worldServer.rand.nextFloat() * 360.0F, 0.0F);

              Event.Result canSpawn = ForgeEventFactory.canEntitySpawn(spawnedEntity, worldServer, ssX, ssY, ssZ);
              if (canSpawn == Event.Result.ALLOW || (canSpawn == Event.Result.DEFAULT && spawnedEntity.getCanSpawnHere())) {
                worldServer.spawnEntityInWorld(spawnedEntity);
                if (!ForgeEventFactory.doSpecialSpawn(spawnedEntity, worldServer, ssX, ssY, ssZ)) {
                  unusedEntityLivingData = spawnedEntity.onSpawnWithEgg(unusedEntityLivingData);
                }
              }
              attemptedSpawnedMobs++;
            } catch (Exception e) {
              Log.warning("Failed to spawn entity " + creatureClass, e);
View Full Code Here

TOP

Related Classes of net.minecraft.entity.EntityLiving

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.