예제 #1
0
 private void handleQuestData(EntityPlayer player, DataReader dr) {
   int questId = dr.readData(DataBitHelper.QUESTS);
   Quest quest = Quest.getQuest(questId);
   if (quest != null) {
     quest.preRead(dr.readData(DataBitHelper.PLAYERS), quest.getQuestData(player));
     quest.read(dr, quest.getQuestData(player), QuestingData.FILE_VERSION, true);
   }
 }
예제 #2
0
 private void handleTaskRequest(EntityPlayer player, DataReader dr) {
   int questId = dr.readData(DataBitHelper.QUESTS);
   int taskId = dr.readData(DataBitHelper.TASKS);
   Quest quest = Quest.getQuest(questId);
   if (quest != null && taskId >= 0 && taskId < quest.getTasks().size()) {
     QuestTask task = quest.getTasks().get(taskId);
     task.onUpdate(player, dr);
   }
 }
예제 #3
0
 private void handleSelectTask(EntityPlayer player, DataReader dr) {
   int questId = dr.readData(DataBitHelper.QUESTS);
   int taskId = dr.readData(DataBitHelper.TASKS);
   Quest quest = Quest.getQuest(questId);
   if (quest != null && taskId >= 0 && taskId < quest.getTasks().size()) {
     QuestingData data = QuestingData.getQuestingData(player);
     data.selectedQuest = questId;
     data.selectedTask = taskId;
   }
 }
예제 #4
0
  private void handleBlockSync(EntityPlayer player, DataReader dr) {
    boolean onServer = !player.worldObj.isRemote;
    int x = dr.readData(DataBitHelper.WORLD_COORDINATE);
    int y = dr.readData(DataBitHelper.WORLD_COORDINATE);
    int z = dr.readData(DataBitHelper.WORLD_COORDINATE);

    TileEntity te = player.worldObj.getTileEntity(x, y, z);
    if (te instanceof IBlockSync) {
      IBlockSync block = (IBlockSync) te;
      int id = dr.readData(block.infoBitLength());

      block.readData(dr, player, onServer, id);
    }
  }
예제 #5
0
 private void handleRewardClaim(EntityPlayer player, DataReader dr) {
   int questId = dr.readData(DataBitHelper.QUESTS);
   Quest quest = Quest.getQuest(questId);
   if (quest != null) {
     quest.claimReward(player, dr);
   }
 }
예제 #6
0
  private void onPacketData(byte[] incomingData, EntityPlayer player, boolean onServer) {

    DataReader dr = null;
    try {
      dr = getDataReaderForPacket(incomingData);
      if (dr == null) {
        return;
      }

      // read the packet count that was manually read before the creation of the data reader
      dr.readByte();

      PacketId id = PacketId.getFromId((byte) dr.readData(DataBitHelper.PACKET_ID));

      switch (id) {
        case OPEN_INTERFACE:
          boolean isOpBook = dr.readBoolean();
          if (isOpBook) {
            String openName = dr.readString(DataBitHelper.NAME_LENGTH);
            clientNameOverride =
                openName.equals(player.getGameProfile().getName()) ? null : openName;
          }
          QuestingData.getQuestingData(player).receiveDataFromServer(dr);
          GuiQuestBook.displayGui(player, isOpBook);
          break;
        case QUEST_DATA:
          handleQuestData(player, dr);
          break;
        case TASK_REQUEST:
          handleTaskRequest(player, dr);
          break;
        case CLAIM_REWARD:
          handleRewardClaim(player, dr);
          break;
        case SELECT_TASK:
          handleSelectTask(player, dr);
          break;
        case SOUND:
          SoundHandler.handleSoundPacket(dr);
          break;
        case LORE:
          SoundHandler.handleLorePacket(player, dr);
          break;
        case TEAM:
          Team.handlePacket(player, dr, onServer);
          break;
        case REFRESH_INTERFACE:
          QuestingData.getQuestingData(player).receiveDataFromServer(dr);
          break;
        case CLOSE_INTERFACE:
          remove(player);
          break;
        case REFRESH_TEAM:
          QuestingData.getQuestingData(player).getTeam().onPacket(dr);
          break;
        case OP_BOOK:
          OPBookHelper.handlePacket(player, dr);
          break;
        case QUEST_SYNC:
          QuestLine.receiveServerSync(dr);
          GuiEditMenuItem.Search.initItems();
          break;
        case BAG_INTERFACE:
          GuiReward.open(player, dr);
          break;
        case DEATH_STATS_UPDATE:
          DeathStats.handlePacket(player, dr);
          break;
        case TEAM_STATS_UPDATE:
          TeamStats.handlePacket(player, dr);
          break;
        case TRACKER_ACTIVATE:
          TileEntityTracker.openInterface(player, dr);
          break;
        case TRACKER_RESPONSE:
          TileEntityTracker.saveToServer(player, dr);
          break;
        case BLOCK_SYNC:
          handleBlockSync(player, dr);
      }
    } catch (Throwable ex) {
      ex.printStackTrace();
    } finally {
      if (dr != null) {
        dr.close();
      }
    }
  }