コード例 #1
0
ファイル: PlayerStorage.java プロジェクト: synelle/Pixelmon
  public void addToParty(EntityPixelmon p) {
    if (mode == PokeballManagerMode.Player && pokedex != null) {
      pokedex.set(Pokedex.nameToID(p.getName()), DexRegisterStatus.caught);
      pokedex.sendToPlayer(pokedex.owner);
    }
    if (p.moveset.size() == 0) p.loadMoveset();
    if (!hasSpace()) {
      ChatHandler.sendChat(
          p.getOwner(), "Your party is full, " + p.getName() + " is sent to your computer!");
      PixelmonStorage.ComputerManager.getPlayerStorage(player).addToComputer(p);
      return;
    }
    if (p.caughtBall == null) p.caughtBall = EnumPokeballs.PokeBall;
    if (mode == PokeballManagerMode.Player) p.setOwner(player.username);
    else if (mode == PokeballManagerMode.Trainer) p.setTrainer(trainer);
    NBTTagCompound n = new NBTTagCompound();
    int id = 0;
    if (mode == PokeballManagerMode.Player) id = new Random().nextInt(32000);
    else if (mode == PokeballManagerMode.Trainer) id = new Random().nextInt(32000) * -1 - 1;
    boolean isUsed = false;
    do {
      isUsed = false;
      for (int i = 0; i < partyPokemon.length; i++) {
        NBTTagCompound nbt = partyPokemon[i];
        if (nbt != null) {
          if (mode == PokeballManagerMode.Player) {
            id = new Random().nextInt(32000);
          } else if (mode == PokeballManagerMode.Trainer) {
            id = new Random().nextInt(32000) * -1 - 1;
          }
        }
      }
    } while (contains(id));

    p.setPokemonId(id);
    p.writeEntityToStorageNBT(n);
    p.writeToNBT(n);
    n.setString("id", "Pixelmon");
    n.setName(p.getName());
    n.setBoolean("IsInBall", true);
    n.setBoolean("IsShiny", p.getIsShiny());
    n.setInteger("PixelmonOrder", getNextOpen());
    if (p.getHeldItem() != null) {
      n.setCompoundTag("Held Item", p.getHeldItem().writeToNBT(new NBTTagCompound()));
    }
    partyPokemon[getNextOpen()] = n;
    if (p.getHealth() > 0) n.setBoolean("IsFainted", false);
    if (mode == PokeballManagerMode.Player)
      ((EntityPlayerMP) player)
          .playerNetServerHandler.sendPacketToPlayer(
              new PixelmonDataPacket(n, EnumPackets.AddToStorage).getPacket());
  }
コード例 #2
0
ファイル: PlayerStorage.java プロジェクト: synelle/Pixelmon
 public void retrieve(EntityPixelmon currentPixelmon) {
   for (int i = 0; i < partyPokemon.length; i++) {
     NBTTagCompound n = partyPokemon[i];
     if (n != null) {
       if (n.getInteger("pixelmonID") == currentPixelmon.getPokemonId()) {
         currentPixelmon.writeEntityToStorageNBT(n);
         currentPixelmon.writeToNBT(n);
         n.setName(currentPixelmon.getName());
         n.setBoolean("IsInBall", true);
         currentPixelmon.unloadEntity();
       }
     }
   }
 }
コード例 #3
0
ファイル: PlayerStorage.java プロジェクト: synelle/Pixelmon
 public void updateNBT(EntityPixelmon pixelmon) {
   for (int i = 0; i < partyPokemon.length; i++) {
     NBTTagCompound nbt = partyPokemon[i];
     if (nbt != null) {
       if (nbt.getInteger("pixelmonID") == pixelmon.getPokemonId()) {
         pixelmon.writeEntityToStorageNBT(nbt);
         pixelmon.writeToNBT(nbt);
         nbt.setString("id", pixelmon.getName());
         nbt.setName(pixelmon.getName());
         if (pixelmon.getHealth() <= 0) nbt.setBoolean("IsFainted", true);
         if (mode == PokeballManagerMode.Player)
           player.playerNetServerHandler.sendPacketToPlayer(
               new PixelmonDataPacket(nbt, EnumPackets.UpdateStorage).getPacket());
       }
     }
   }
 }
コード例 #4
0
ファイル: PlayerStorage.java プロジェクト: synelle/Pixelmon
 public void replace(EntityPixelmon entityPixelmon, EntityPixelmon entityCapturedPixelmon) {
   for (int i = 0; i < partyPokemon.length; i++) {
     NBTTagCompound nbt = partyPokemon[i];
     if (nbt != null) {
       if (nbt.getInteger("pixelmonID") == entityPixelmon.getPokemonId()) {
         entityCapturedPixelmon.setPokemonId(entityPixelmon.getPokemonId());
         entityCapturedPixelmon.writeEntityToStorageNBT(nbt);
         entityCapturedPixelmon.writeToNBT(nbt);
         nbt.setString("id", entityCapturedPixelmon.getName());
         nbt.setName(entityCapturedPixelmon.getName());
         if (mode == PokeballManagerMode.Player)
           player.playerNetServerHandler.sendPacketToPlayer(
               new PixelmonDataPacket(nbt, EnumPackets.UpdateStorage).getPacket());
       }
     }
   }
 }
コード例 #5
0
ファイル: PlayerStorage.java プロジェクト: synelle/Pixelmon
  @SuppressWarnings("rawtypes")
  public void readFromNBT(NBTTagCompound var1) {
    pokeDollars = var1.getInteger("pixelDollars");
    Iterator iterator = var1.getTags().iterator();
    do {
      if (!iterator.hasNext()) break;

      NBTBase nbtbase = (NBTBase) iterator.next();

      if (nbtbase instanceof NBTTagCompound) {
        NBTTagCompound pokemonData = (NBTTagCompound) nbtbase;
        pokemonData.setName(pokemonData.getString("Name"));
        partyPokemon[pokemonData.getInteger("PixelmonOrder")] = pokemonData;
        if (mode == PokeballManagerMode.Player)
          player.playerNetServerHandler.sendPacketToPlayer(
              new PixelmonDataPacket(pokemonData, EnumPackets.AddToStorage).getPacket());
      }
    } while (true);
    if (pokedex != null) pokedex.readFromNBT(var1);
  }