Exemple #1
0
 public ItemPokeBall(int i, EnumPokeballs type) {
   super(
       i,
       "pokeballs/" + type.toString().toLowerCase(),
       type.toString().substring(0, type.toString().indexOf("Ball")) + " Ball");
   SetUsableInBattle(true);
   maxStackSize = 64;
   setMaxDamage(0xf4240);
   this.type = type;
   playerTimers = new HashMap<EntityPlayer, Integer>();
   setCreativeTab(PixelmonCreativeTabs.pokeball);
 }
 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;
 }
 public static double getBallBonus(
     EnumPokeballs type, EntityLiving thrower, EntityPixelmon p2, Mode mode) {
   double ballBonus = type.getBallBonus();
   for (CaptureBase c : captureList)
     if (c.pokeball == type) return c.getBallBonus(type, (EntityPlayer) thrower, p2, mode);
   return ballBonus;
 }
 public ItemPokeBall(int i, EnumPokeballs type) {
   super(i);
   SetUsableInBattle(true);
   maxStackSize = 64;
   setMaxDamage(0xf4240);
   this.type = type;
   playerTimers = new HashMap<EntityPlayer, Integer>();
   setIconIndex(type.getIconIndex());
   setTextureFile("/pixelmon/image/pitems2.png");
   setCreativeTab(PixelmonCreativeTabs.pokeball);
 }
 public EntityPokeBall(
     World world, EntityLiving entityliving, EnumPokeballs type, boolean dropItem) {
   super(world, entityliving);
   thrower = entityliving;
   this.mode = Mode.empty;
   dataWatcher.addObject(10, type.getIndex());
   dataWatcher.addObject(11, (short) 0); // IsCaptured
   dataWatcher.addObject(12, (short) 0); // IsWaiting
   dataWatcher.addObject(13, (short) 0); // IsOnGround
   dataWatcher.addObject(14, (short) 0); // IsOpen
   isInitialized = true;
   this.dropItem = dropItem;
 }
 public EntityPokeBall(
     World world,
     EntityLiving thrower,
     EntityPixelmon target,
     EnumPokeballs type,
     BattleController battleController) {
   super(world, thrower);
   this.thrower = thrower;
   dropItem = false;
   endRotationYaw = thrower.rotationYawHead;
   pixelmon = target;
   dataWatcher.addObject(10, type.getIndex());
   dataWatcher.addObject(11, (short) 0); // IsCaptured
   dataWatcher.addObject(12, (short) 0); // IsWaiting
   dataWatcher.addObject(13, (short) 0); // IsOnGround
   dataWatcher.addObject(14, (short) 0); // IsOpen
   mode = Mode.battle;
   isBattleThrown = true;
   this.battleController = battleController;
   worldObj = thrower.worldObj;
   battleController.pauseBattle();
   this.setLocationAndAngles(
       thrower.posX,
       thrower.posY + (double) thrower.getEyeHeight(),
       thrower.posZ,
       thrower.rotationYaw,
       thrower.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;
   isInitialized = true;
   Vec3 posVec =
       Vec3.createVectorHelper(posX - pixelmon.posX, posY - pixelmon.posY, posZ - pixelmon.posZ);
   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(0)) * 0.8;
 }
 public void flash() {
   if (EnumPokeballs.getFromIndex(dataWatcher.getWatchableObjectInt(10))
       == EnumPokeballs.PremierBall) {
     worldObj.spawnParticle(
         "reddust", this.posX + 0.1, this.posY + 0.2, this.posZ + 0.1, 0.0D, 0.0D, 0.0D);
     worldObj.spawnParticle(
         "reddust", this.posX, this.posY + 0.2, this.posZ + 0.1, 0.0D, 0.0D, 0.0D);
     worldObj.spawnParticle("reddust", this.posX, this.posY + 0.2, this.posZ, 0.0D, 0.0D, 0.0D);
     worldObj.spawnParticle(
         "reddust", this.posX + 0.1, this.posY + 0.2, this.posZ, 0.0D, 0.0D, 0.0D);
     worldObj.spawnParticle(
         "reddust", this.posX + 0.1, this.posY + 0.2, this.posZ + 0.1, 0.0D, 0.0D, 0.0D);
     worldObj.spawnParticle(
         "reddust", this.posX + 0.1, this.posY + 0.4, this.posZ + 0.1, 0.0D, 0.0D, 0.0D);
     worldObj.spawnParticle(
         "reddust", this.posX, this.posY + 0.4, this.posZ + 0.1, 0.0D, 0.0D, 0.0D);
     worldObj.spawnParticle("reddust", this.posX, this.posY + 0.4, this.posZ, 0.0D, 0.0D, 0.0D);
     worldObj.spawnParticle(
         "reddust", this.posX + 0.1, this.posY + 0.4, this.posZ, 0.0D, 0.0D, 0.0D);
     worldObj.spawnParticle(
         "reddust", this.posX + 0.1, this.posY + 0.4, this.posZ + 0.1, 0.0D, 0.0D, 0.0D);
   }
 }
 public EnumPokeballs getType() {
   return EnumPokeballs.getFromIndex(dataWatcher.getWatchableObjectInt(10));
 }
  @Override
  protected void onImpact(MovingObjectPosition movingobjectposition) {
    if (getIsWaiting()) {
      return;
    }

    if (dropItem
        && breakChance == 1
        && EnumPokeballs.getFromIndex(dataWatcher.getWatchableObjectInt(10))
            != EnumPokeballs.MasterBall) {
      worldObj.playSoundAtEntity(
          this, "random.break", 0.8F, 0.8F + this.worldObj.rand.nextFloat() * 0.4F);
      entityDropItem(new ItemStack(Block.stoneButton), 0.0F);
      entityDropItem(new ItemStack(PixelmonItemsPokeballs.ironBase), 0.0F);
      entityDropItem(new ItemStack(breakBall()), 0.0F);
      setDead();
      return;
    }

    if (isBattleThrown && !worldObj.isRemote) {
      p = pixelmon;
      p.hitByPokeball = true;
      doCaptureCalc(p);
      setIsWaiting(true);
      motionX = motionZ = 0;
      motionY = 0;
      // }
    } else if (mode == Mode.full) {
      if (movingobjectposition != null && !worldObj.isRemote) {
        if (pixelmon != null) {
          if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) {
            if (movingobjectposition.sideHit == 0) // Bottom
            pixelmon.setLocationAndAngles(
                  movingobjectposition.blockX + 0.5,
                  movingobjectposition.blockY - 1,
                  movingobjectposition.blockZ + 0.5,
                  rotationYaw,
                  0.0F);
            if (movingobjectposition.sideHit == 1) // Top
            pixelmon.setLocationAndAngles(
                  movingobjectposition.blockX + 0.5,
                  movingobjectposition.blockY + 1,
                  movingobjectposition.blockZ + 0.5,
                  rotationYaw,
                  0.0F);
            if (movingobjectposition.sideHit == 2) // East
            pixelmon.setLocationAndAngles(
                  movingobjectposition.blockX + 0.5,
                  movingobjectposition.blockY,
                  movingobjectposition.blockZ + 0.5 - 1,
                  rotationYaw,
                  0.0F);
            if (movingobjectposition.sideHit == 3) // West
            pixelmon.setLocationAndAngles(
                  movingobjectposition.blockX + 0.5,
                  movingobjectposition.blockY,
                  movingobjectposition.blockZ + 0.5 + 1,
                  rotationYaw,
                  0.0F);
            if (movingobjectposition.sideHit == 4) // North
            pixelmon.setLocationAndAngles(
                  movingobjectposition.blockX + 0.5 - 1,
                  movingobjectposition.blockY,
                  movingobjectposition.blockZ + 0.5,
                  rotationYaw,
                  0.0F);
            if (movingobjectposition.sideHit == 5) // South
            pixelmon.setLocationAndAngles(
                  movingobjectposition.blockX + 0.5 + 1,
                  movingobjectposition.blockY,
                  movingobjectposition.blockZ + 0.5,
                  rotationYaw,
                  0.0F);
          } else {
            pixelmon.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F);
          }
          pixelmon.motionX = pixelmon.motionY = pixelmon.motionZ = 0;
          pixelmon.releaseFromPokeball();
          if (movingobjectposition.entityHit != null
              && (movingobjectposition.entityHit instanceof EntityPixelmon)
              && !PixelmonStorage.PokeballManager.getPlayerStorage(((EntityPlayerMP) thrower))
                  .isIn((EntityPixelmon) movingobjectposition.entityHit)) {
            if (((EntityPixelmon) movingobjectposition.entityHit).battleController != null) {
              setDead();
              return;
            }
            BattleParticipant part;
            if (((EntityPixelmon) movingobjectposition.entityHit).getOwner() != null)
              part =
                  new PlayerParticipant(
                      (EntityPlayerMP) ((EntityPixelmon) movingobjectposition.entityHit).getOwner(),
                      (EntityPixelmon) movingobjectposition.entityHit);
            else
              part = new WildPixelmonParticipant((EntityPixelmon) movingobjectposition.entityHit);

            pixelmon.StartBattle(new PlayerParticipant((EntityPlayerMP) thrower, pixelmon), part);

          } else if (movingobjectposition.entityHit != null
              && movingobjectposition.entityHit instanceof EntityTrainer) {
            if (((EntityTrainer) movingobjectposition.entityHit).releasedPokemon != null
                && ((EntityTrainer) movingobjectposition.entityHit).releasedPokemon.battleController
                    != null) {
              setDead();
              return;
            }

            TrainerParticipant trainer =
                new TrainerParticipant(
                    (EntityTrainer) movingobjectposition.entityHit, (EntityPlayer) thrower);
            pixelmon.StartBattle(
                new PlayerParticipant((EntityPlayerMP) thrower, pixelmon), trainer);
          } else pixelmon.clearAttackTarget();
          if (thrower instanceof EntityPlayer) {}

          // spawnCaptureParticles();
        }
        setDead();
      }
    } else {
      if (movingobjectposition != null) {
        if (movingobjectposition.entityHit != null
            && (movingobjectposition.entityHit instanceof EntityPixelmon)) {
          EntityPixelmon entitypixelmon = (EntityPixelmon) movingobjectposition.entityHit;
          p = entitypixelmon;

          if (p.battleController != null) {
            ChatHandler.sendChat(
                (EntityPlayer) thrower,
                "You can't catch pokemon who are battling in another battle!");
            if (dropItem) {
              entityDropItem(new ItemStack(getType().getItem()), 0.0F);
            }
            setDead();
            return;
          }

          if (p.getOwner() != null || p.getTrainer() != null) {
            if (p.getOwner() == thrower)
              ChatHandler.sendChat(
                  (EntityPlayer) thrower, "You can't catch Pokemon you already own!");
            else
              ChatHandler.sendChat(
                  (EntityPlayer) thrower, "You can't catch other people's Pokemon!");
            if (dropItem) {
              entityDropItem(new ItemStack(getType().getItem()), 0.0F);
            }
            setDead();
            return;
          }

          if (p.hitByPokeball) {
            if (dropItem) {
              entityDropItem(new ItemStack(getType().getItem()), 0.0F);
            }
            setDead();
            return;
          }
          p.hitByPokeball = true;
          doCaptureCalc(p);
          setIsWaiting(true);
          motionX = motionZ = 0;
          motionY = -0.1;
        } else {
          Material mat =
              worldObj.getBlockMaterial(
                  movingobjectposition.blockX,
                  movingobjectposition.blockY,
                  movingobjectposition.blockZ);
          if (!getIsWaiting() && mat != null && mat.isSolid()) {
            if (dropItem) {
              entityDropItem(new ItemStack(getType().getItem()), 0.0F);
            }
            setDead();
          }
        }
      }
    }
  }