Package net.minecraft.entity.projectile

Examples of net.minecraft.entity.projectile.EntityThrowable


      ((ILens) compositeLens.getItem()).apply(compositeLens, props);
  }

  @Override
  public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
    EntityThrowable entity = (EntityThrowable) burst;

    switch(stack.getItemDamage()) {
    case BOUNCE : {
      if(!isManaBlock && pos.entityHit == null) {
        ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
View Full Code Here


    return dead;
  }

  @Override
  public void updateBurst(IManaBurst burst, ItemStack stack) {
    EntityThrowable entity = (EntityThrowable) burst;
    int storedColor = getStoredColor(stack);

    if(storedColor == 16 && entity.worldObj.isRemote)
      burst.setColor(getLensColor(stack));

    boolean magnetized = entity.getEntityData().hasKey("Botania:Magnetized");
    switch(stack.getItemDamage()) {
    case DAMAGE : {
      AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ).expand(1, 1, 1);
      List<EntityLivingBase> entities = entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis);
      for(EntityLivingBase living : entities) {
        if(living instanceof EntityPlayer)
          continue;

        if(living.hurtTime == 0) {
          int mana = burst.getMana();
          if(mana >= 16) {
            burst.setMana(mana - 16);
            if(!burst.isFake() && !entity.worldObj.isRemote)
              living.attackEntityFrom(DamageSource.magic, 4);
            break;
          }
        }
      }
      break;
    }
    case MAGNET : {
      int x = (int) entity.posX;
      int y = (int) entity.posY;
      int z = (int) entity.posZ;
      int range = 3;

      magnetize : {
        for(int i = -range; i < range; i++)
          for(int j = -range; j < range; j++)
            for(int k = -range; k < range; k++)
              if(entity.worldObj.getTileEntity(i + x, j + y, k + z) instanceof IManaReceiver) {
                TileEntity tile = entity.worldObj.getTileEntity(i + x, j + y, k + z);

                if(magnetized) {
                  int magX = entity.getEntityData().getInteger("Botania:MagnetizedX");
                  int magY = entity.getEntityData().getInteger("Botania:MagnetizedY");
                  int magZ = entity.getEntityData().getInteger("Botania:MagnetizedZ");
                  if(tile.xCoord != magX || tile.yCoord != magY || tile.zCoord != magZ)
                    continue;
                }

                IManaReceiver receiver = (IManaReceiver) tile;

                ChunkCoordinates srcCoords = burst.getBurstSourceChunkCoordinates();

                if(MathHelper.pointDistanceSpace(tile.xCoord, tile.yCoord, tile.zCoord, srcCoords.posX, srcCoords.posY, srcCoords.posZ) > 3 && receiver.canRecieveManaFromBursts() && !receiver.isFull()) {
                  Vector3 burstVec = Vector3.fromEntity(entity);
                  Vector3 tileVec = Vector3.fromTileEntityCenter(tile).add(0, -0.1, 0);
                  Vector3 motionVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ);

                  Vector3 normalMotionVec = motionVec.copy().normalize();
                  Vector3 magnetVec = tileVec.sub(burstVec).normalize();
                  Vector3 differenceVec = normalMotionVec.sub(magnetVec).multiply(motionVec.mag() * 0.1);

                  Vector3 finalMotionVec = motionVec.sub(differenceVec);
                  if(!magnetized) {
                    finalMotionVec.multiply(0.75);
                    entity.getEntityData().setBoolean("Botania:Magnetized", true);
                    entity.getEntityData().setInteger("Botania:MagnetizedX", tile.xCoord);
                    entity.getEntityData().setInteger("Botania:MagnetizedY", tile.yCoord);
                    entity.getEntityData().setInteger("Botania:MagnetizedZ", tile.zCoord);
                  }

                  burst.setMotion(finalMotionVec.x, finalMotionVec.y, finalMotionVec.z);
                  break magnetize;
                }
View Full Code Here

    return dead;
  }

  @Override
  public void updateBurst(IManaBurst burst, ItemStack stack) {
    EntityThrowable entity = (EntityThrowable) burst;
    AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ).expand(1, 1, 1);
    List<EntityLivingBase> entities = entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis);
    String attacker = ItemNBTHelper.getString(burst.getSourceLens(), TAG_ATTACKER_USERNAME, "");

    for(EntityLivingBase living : entities) {
      if(living instanceof EntityPlayer && (((EntityPlayer) living).getCommandSenderName().equals(attacker) || MinecraftServer.getServer() != null && !MinecraftServer.getServer().isPVPEnabled()))
        continue;

      if(living.hurtTime == 0) {
        int cost = MANA_PER_DAMAGE / 3;
        int mana = burst.getMana();
        if(mana >= cost) {
          burst.setMana(mana - cost);
          float damage = 4F + BotaniaAPI.terrasteelToolMaterial.getDamageVsEntity();
          if(!burst.isFake() && !entity.worldObj.isRemote) {
            EntityPlayer player = living.worldObj.getPlayerEntityByName(attacker);
            living.attackEntityFrom(player == null ? DamageSource.magic : DamageSource.causePlayerDamage(player), damage);
            entity.setDead();
            break;
          }
        }
      }
    }
View Full Code Here

  @Override
  public void updateBurst(IManaBurst burst, ItemStack stack) {
    double speed = 0.35;
    int targetDistance = BASE_OFFSET;
    EntityThrowable entity = (EntityThrowable) burst;
    if(!entity.worldObj.isRemote) {
      entity.motionX = 0;
      entity.motionY = speed;
      entity.motionZ = 0;

      final int spawnTicks = 2;
      final int placeTicks = net.minecraft.util.MathHelper.floor_double(targetDistance / speed);

      ItemStack lens = burst.getSourceLens();

      if(burst.getTicksExisted() == spawnTicks) {
        int x = ItemNBTHelper.getInt(lens, TAG_X, 0);
        int y = ItemNBTHelper.getInt(lens, TAG_Y, -1);
        int z = ItemNBTHelper.getInt(lens, TAG_Z, 0);

        if(y != -1)
          spawnBurst(entity.worldObj, x, y, z, lens);
      } else if(burst.getTicksExisted() == placeTicks) {
        int x = net.minecraft.util.MathHelper.floor_double(entity.posX);
        int y = ItemNBTHelper.getInt(lens, TAG_Y_START, -1) + targetDistance;
        int z = net.minecraft.util.MathHelper.floor_double(entity.posZ);

        if(entity.worldObj.isAirBlock(x, y, z)) {
          int id = ItemNBTHelper.getInt(lens, TAG_BLOCK, 0);
          Block block = Block.getBlockById(id);
          int meta = ItemNBTHelper.getInt(lens, TAG_META, 0);

          TileEntity tile = null;
          NBTTagCompound tilecmp = ItemNBTHelper.getCompound(lens, TAG_TILE, false);
          if(tilecmp.hasKey("id"))
            tile = TileEntity.createAndLoadEntity(tilecmp);

          entity.worldObj.setBlock(x, y, z, block, meta, 1 | 2);
          entity.worldObj.playAuxSFX(2001, x, y, z, id + (meta << 12));
          if(tile != null) {
            tile.xCoord = x;
            tile.yCoord = y;
            tile.zCoord = z;
            entity.worldObj.setTileEntity(x, y, z, tile);
          }
        }

        entity.setDead();
      }
    }
  }
View Full Code Here

    }
  }

  @Override
  public boolean doParticles(IManaBurst burst, ItemStack stack) {
    EntityThrowable entity = (EntityThrowable) burst;
    ItemStack lens = burst.getSourceLens();
    int id = ItemNBTHelper.getInt(lens, TAG_BLOCK, 0);
    Block.getBlockById(id);
    int meta = ItemNBTHelper.getInt(lens, TAG_META, 0);
    entity.worldObj.spawnParticle("blockcrack_" + id + "_" + meta, entity.posX, entity.posY, entity.posZ, entity.motionX, entity.motionY, entity.motionZ);
View Full Code Here

TOP

Related Classes of net.minecraft.entity.projectile.EntityThrowable

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.