Package net.minecraft.entity

Examples of net.minecraft.entity.Entity


  public static void leftClick(EntityPlayer player) {
    ItemStack stack = player.getHeldItem();
    if(stack != null && stack.getItem() == ModItems.gravityRod) {
      int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1);
      ItemNBTHelper.getDouble(stack, TAG_DIST, -1);
      Entity item = null;
      if(targetID != -1 && player.worldObj.getEntityByID(targetID) != null) {
        Entity taritem = player.worldObj.getEntityByID(targetID);

        boolean found = false;
        Vector3 target = Vector3.fromEntityCenter(player);
        List<Entity> entities = new ArrayList<Entity>();
        int distance = 1;
View Full Code Here


    MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3, vec31);


    if (!worldObj.isRemote)
    {
      Entity entity = null;
      List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX*2, motionY*2, motionZ*2).expand(2.0D, 2.0D, 2.0D));
      double d0 = 0.0D;

      for (int j = 0; j < list.size(); ++j)
      {
        Entity entity1 = (Entity)list.get(j);

        if (entity1.canBeCollidedWith() && (!(entity1 instanceof EntityPlayer) || delayBeforeCanPickup == 0))
        {
          float f = 1.0F;
          AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f);
          MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31);

          if (movingobjectposition1 != null)
          {
            double d1 = vec3.distanceTo(movingobjectposition1.hitVec);

            if (d1 < d0 || d0 == 0.0D)
            {
              entity = entity1;
              d0 = d1;
            }
          }
        }
      }

      if (entity != null)
      {
        movingobjectposition = new MovingObjectPosition(entity);
      }
    }

    if (movingobjectposition != null)
    {
      if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ) == Blocks.portal)
      {
        setInPortal();
      }
      else
      {
        if (movingobjectposition.entityHit != null) {
          movingobjectposition.entityHit.attackEntityFrom(DamageSource.magic, 2.0F);
          if (!worldObj.isRemote) {
            Entity item = getEntityItem().getItem().createEntity(worldObj, this, getEntityItem());
            if (item == null) {
              item = new EntityItem(worldObj, posX, posY, posZ, getEntityItem());
              worldObj.spawnEntityInWorld(item);
              item.motionX = motionX*0.25F;
              item.motionY = motionY*0.25F;
              item.motionZ = motionZ*0.25F;

            }
            else
            {
              item.motionX = motionX*0.25F;
              item.motionY = motionY*0.25F;
              item.motionZ = motionZ*0.25F;
            }
          }
          setDead();

        }
      }
    }

    Vector3 vec3m = new Vector3(motionX, motionY, motionZ);
    if (vec3m.mag() < 1.0F) {
      if (!worldObj.isRemote) {
        Entity item = getEntityItem().getItem().createEntity(worldObj, this, getEntityItem());
        if (item == null) {
          item = new EntityItem(worldObj, posX, posY, posZ, getEntityItem());
          worldObj.spawnEntityInWorld(item);
          item.motionX = motionX;
          item.motionY = motionY;
View Full Code Here

  @Override
  public ISparkEntity getAttachedSpark() {
    List<ISparkEntity> sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1));
    if(sparks.size() == 1) {
      Entity e = (Entity) sparks.get(0);
      return (ISparkEntity) e;
    }

    return null;
  }
View Full Code Here


    List<ISparkEntity> allSparks = SparkHelper.getSparksAround(worldObj, posX, posY, posZ);
    if(worldObj.isRemote && !didStartupParticles) {
      for(ISparkEntity spark : allSparks) {
        Entity e = (Entity) spark;
        Vector3 orig = new Vector3(e.posX , e.posY + 0.25, e.posZ);
        Vector3 end = new Vector3(posX, posY + 0.25, posZ);
        Vector3 diff = end.copy().sub(orig);
        Vector3 movement = diff.copy().normalize().multiply(0.05);
        int iters = (int) (diff.mag() / movement.mag());
View Full Code Here

      if(s.isEmpty())
        continue;

      int id = Integer.parseInt(s);
      boolean added = false;
      Entity e = worldObj.getEntityByID(id);
      if(e != null && e instanceof ISparkEntity) {
        ISparkEntity spark = (ISparkEntity) e;
        if(spark != this && !spark.areIncomingTransfersDone() && spark.getAttachedTile() != null && !spark.getAttachedTile().isFull() && (getUpgrade() == 0 && spark.getUpgrade() == 2 || getUpgrade() == 3 && (spark.getUpgrade() == 0 || spark.getUpgrade() == 1) || !(spark.getAttachedTile() instanceof IManaPool))) {
          entities.add((ISparkEntity) e);
          added = true;
View Full Code Here

    if(movingobjectposition != null)
      vec31 = new Vector3(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord).toVec3D();

    if(!worldObj.isRemote) {
      Entity entity = null;
      List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;
      EntityLivingBase entitylivingbase = getThrower();

      for(int j = 0; j < list.size(); ++j) {
        Entity entity1 = (Entity) list.get(j);

        if(entity1.canBeCollidedWith() && (entity1 != entitylivingbase || ticksInAir >= 5)) {
          float f = 0.3F;
          AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f);
          MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31);

          if(movingobjectposition1 != null) {
View Full Code Here

        int spawnCount = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.SPAWN_COUNT);
        int spawnRange = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.SPAWN_RANGE);
        int maxNearbyEntities = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.MAX_NEARBY_ENTITIES);

        for(int i = 0; i < spawnCount; ++i) {
          Entity entity = EntityList.createEntityByName(logic.getEntityNameToSpawn(), logic.getSpawnerWorld());

          if (entity == null)
            return;

          int j = logic.getSpawnerWorld().getEntitiesWithinAABB(entity.getClass(), AxisAlignedBB.getBoundingBox(logic.getSpawnerX(), logic.getSpawnerY(), logic.getSpawnerZ(), logic.getSpawnerX() + 1, logic.getSpawnerY() + 1, logic.getSpawnerZ() + 1).expand(spawnRange * 2, 4.0D, spawnRange * 2)).size();

          if (j >= maxNearbyEntities) {
            resetTimer(logic);
            return;
          }

          double d2 = logic.getSpawnerX() + (logic.getSpawnerWorld().rand.nextDouble() - logic.getSpawnerWorld().rand.nextDouble()) * spawnRange;
          double d3 = logic.getSpawnerY() + logic.getSpawnerWorld().rand.nextInt(3) - 1;
          double d4 = logic.getSpawnerZ() + (logic.getSpawnerWorld().rand.nextDouble() - logic.getSpawnerWorld().rand.nextDouble()) * spawnRange;
          EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving)entity : null;
          entity.setLocationAndAngles(d2, d3, d4, logic.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F);

          if(entityliving == null || entityliving.getCanSpawnHere()) {
            logic.func_98265_a(entity);
            logic.getSpawnerWorld().playAuxSFX(2004, logic.getSpawnerX(), logic.getSpawnerY(), logic.getSpawnerZ(), 0);

View Full Code Here

  @Override
  protected void damageEntity(DamageSource par1DamageSource, float par2) {
    super.damageEntity(par1DamageSource, par2);

    Entity attacker = par1DamageSource.getEntity();
    if(attacker != null) {
      Vector3 thisVector = Vector3.fromEntityCenter(this);
      Vector3 playerVector = Vector3.fromEntityCenter(attacker);
      Vector3 motionVector = thisVector.copy().sub(playerVector).copy().normalize().multiply(0.75);
View Full Code Here

  @Override
  public ISparkEntity getAttachedSpark() {
    List<ISparkEntity> sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1));
    if(sparks.size() == 1) {
      Entity e = (Entity) sparks.get(0);
      return (ISparkEntity) e;
    }

    return null;
  }
View Full Code Here

  @Override
  public ISparkEntity getAttachedSpark() {
    List<ISparkEntity> sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1));
    if(sparks.size() == 1) {
      Entity e = (Entity) sparks.get(0);
      return (ISparkEntity) e;
    }

    return null;
  }
View Full Code Here

TOP

Related Classes of net.minecraft.entity.Entity

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.