示例#1
0
 public static DataWriter getWriter(PacketId id) {
   DataWriter dw = new DataWriter();
   dw.writeByte(
       1); // amount of packets, defaults to 1. Hast obe a byte so it's easy to modify afterwards
   dw.writeData(id.getId(), DataBitHelper.PACKET_ID);
   return dw;
 }
示例#2
0
  private static void sendToBookPlayer(String name, DataWriter dw) {
    if (QuestingData.getQuestingData(name).getTeam().getEntry(name).isBookOpen()) {
      EntityPlayer player = QuestingData.getPlayer(name);
      if (player != null) {
        dw.sendToPlayer((EntityPlayerMP) player);
      }
    }

    String playerName = nameOverrideReversed.get(name);
    if (playerName != null) {
      EntityPlayer other = QuestingData.getPlayer(playerName);
      if (other != null) {
        dw.sendToPlayer((EntityPlayerMP) other);
      }
    }
  }
示例#3
0
 public static void sendToAllPlayersWithOpenBook(DataWriter dw) {
   if (!Quest.isEditing || QuestingData.isSinglePlayer()) {
     for (String name :
         FMLCommonHandler.instance()
             .getMinecraftServerInstance()
             .getConfigurationManager()
             .getAllUsernames()) {
       sendToBookPlayer(name, dw);
     }
   }
   dw.close();
 }
示例#4
0
  public static void sendBlockPacket(IBlockSync block, EntityPlayer player, int id) {
    if (block instanceof TileEntity) {
      DataWriter dw = getWriter(PacketId.BLOCK_SYNC);
      TileEntity te = (TileEntity) block;
      boolean onServer = !te.getWorldObj().isRemote;

      dw.writeData(te.xCoord, DataBitHelper.WORLD_COORDINATE);
      dw.writeData(te.yCoord, DataBitHelper.WORLD_COORDINATE);
      dw.writeData(te.zCoord, DataBitHelper.WORLD_COORDINATE);
      dw.writeData(id, block.infoBitLength());

      block.writeData(dw, player, onServer, id);

      if (!onServer) {
        dw.sendToServer();
      } else if (player != null) {
        dw.sendToPlayer((EntityPlayerMP) player);
      } else {
        dw.sendToAllPlayersAround(te, BLOCK_UPDATE_RANGE);
      }

      dw.close();
    }
  }
示例#5
0
 public static void sendToServer(DataWriter dw) {
   if (!Quest.isEditing || QuestingData.isSinglePlayer()) {
     dw.sendToServer();
   }
   dw.close();
 }
示例#6
0
 public static void sendToAllPlayers(DataWriter dw) {
   if (!Quest.isEditing && !QuestingData.isSinglePlayer()) {
     dw.sendToAllPlayers();
   }
   dw.close();
 }
示例#7
0
 public static void sendToRawPlayer(EntityPlayer player, DataWriter dw) {
   if (!Quest.isEditing || QuestingData.isSinglePlayer()) {
     dw.sendToPlayer((EntityPlayerMP) player);
   }
   dw.close();
 }
示例#8
0
 public static void sendToPlayer(String name, DataWriter dw) {
   if (!Quest.isEditing || QuestingData.isSinglePlayer()) {
     sendToBookPlayer(name, dw);
   }
   dw.close();
 }