public void handleCustomPayload(Packet250CustomPayload par1Packet250CustomPayload) {
    if ("MC|BEdit".equals(par1Packet250CustomPayload.channel)) {
      try {
        DataInputStream datainputstream =
            new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data));
        ItemStack itemstack = Packet.readItemStack(datainputstream);

        if (!ItemWritableBook.validBookTagPages(itemstack.getTagCompound())) {
          throw new IOException("Invalid book tag!");
        }

        ItemStack itemstack2 = playerEntity.inventory.getCurrentItem();

        if (itemstack != null
            && itemstack.itemID == Item.writableBook.shiftedIndex
            && itemstack.itemID == itemstack2.itemID) {
          itemstack2.setTagCompound(itemstack.getTagCompound());
        }
      } catch (Exception exception) {
        exception.printStackTrace();
      }
    } else if ("MC|BSign".equals(par1Packet250CustomPayload.channel)) {
      try {
        DataInputStream datainputstream1 =
            new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data));
        ItemStack itemstack1 = Packet.readItemStack(datainputstream1);

        if (!ItemEditableBook.validBookTagContents(itemstack1.getTagCompound())) {
          throw new IOException("Invalid book tag!");
        }

        ItemStack itemstack3 = playerEntity.inventory.getCurrentItem();

        if (itemstack1 != null
            && itemstack1.itemID == Item.writtenBook.shiftedIndex
            && itemstack3.itemID == Item.writableBook.shiftedIndex) {
          itemstack3.setTagCompound(itemstack1.getTagCompound());
          itemstack3.itemID = Item.writtenBook.shiftedIndex;
        }
      } catch (Exception exception1) {
        exception1.printStackTrace();
      }
    } else if ("MC|TrSel".equals(par1Packet250CustomPayload.channel)) {
      try {
        DataInputStream datainputstream2 =
            new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data));
        int i = datainputstream2.readInt();
        Container container = playerEntity.craftingInventory;

        if (container instanceof ContainerMerchant) {
          ((ContainerMerchant) container).setCurrentRecipeIndex(i);
        }
      } catch (Exception exception2) {
        exception2.printStackTrace();
      }
    } else {
      ModLoader.serverCustomPayload(this, par1Packet250CustomPayload);
    }
  }
Exemple #2
0
  public void handleCustomPayload(Packet250CustomPayload par1Packet250CustomPayload) {
    DataInputStream var2;
    ItemStack var3;
    ItemStack var4;

    if ("MC|BEdit".equals(par1Packet250CustomPayload.channel)) {
      try {
        var2 = new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data));
        var3 = Packet.readItemStack(var2);

        if (!ItemWritableBook.validBookTagPages(var3.getTagCompound())) {
          throw new IOException("Invalid book tag!");
        }

        var4 = this.playerEntity.inventory.getCurrentItem();

        if (var3 != null
            && var3.itemID == Item.writableBook.shiftedIndex
            && var3.itemID == var4.itemID) {
          var4.setTagCompound(var3.getTagCompound());
        }
      } catch (Exception var7) {
        var7.printStackTrace();
      }
    } else if ("MC|BSign".equals(par1Packet250CustomPayload.channel)) {
      try {
        var2 = new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data));
        var3 = Packet.readItemStack(var2);

        if (!ItemEditableBook.validBookTagContents(var3.getTagCompound())) {
          throw new IOException("Invalid book tag!");
        }

        var4 = this.playerEntity.inventory.getCurrentItem();

        if (var3 != null
            && var3.itemID == Item.field_77823_bG.shiftedIndex
            && var4.itemID == Item.writableBook.shiftedIndex) {
          var4.setTagCompound(var3.getTagCompound());
          var4.itemID = Item.field_77823_bG.shiftedIndex;
        }
      } catch (Exception var6) {
        var6.printStackTrace();
      }
    } else if ("MC|TrSel".equals(par1Packet250CustomPayload.channel)) {
      try {
        var2 = new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data));
        int var8 = var2.readInt();
        Container var9 = this.playerEntity.craftingInventory;

        if (var9 instanceof ContainerMerchant) {
          ((ContainerMerchant) var9).func_75175_c(var8);
        }
      } catch (Exception var5) {
        var5.printStackTrace();
      }
    }
  }
  public void func_72501_a(Packet250CustomPayload p_72501_1_) {
    DataInputStream var2;
    ItemStack var3;
    ItemStack var4;
    if ("MC|BEdit".equals(p_72501_1_.field_73630_a)) {
      try {
        var2 = new DataInputStream(new ByteArrayInputStream(p_72501_1_.field_73629_c));
        var3 = Packet.func_73276_c(var2);
        if (!ItemWritableBook.func_77829_a(var3.func_77978_p())) {
          throw new IOException("Invalid book tag!");
        }

        var4 = this.field_72574_e.field_71071_by.func_70448_g();
        if (var3 != null
            && var3.field_77993_c == Item.field_77821_bF.field_77779_bT
            && var3.field_77993_c == var4.field_77993_c) {
          var4.func_77983_a("pages", var3.func_77978_p().func_74761_m("pages"));
        }
      } catch (Exception var14) {
        var14.printStackTrace();
      }
    } else if ("MC|BSign".equals(p_72501_1_.field_73630_a)) {
      try {
        var2 = new DataInputStream(new ByteArrayInputStream(p_72501_1_.field_73629_c));
        var3 = Packet.func_73276_c(var2);
        if (!ItemEditableBook.func_77828_a(var3.func_77978_p())) {
          throw new IOException("Invalid book tag!");
        }

        var4 = this.field_72574_e.field_71071_by.func_70448_g();
        if (var3 != null
            && var3.field_77993_c == Item.field_77823_bG.field_77779_bT
            && var4.field_77993_c == Item.field_77821_bF.field_77779_bT) {
          var4.func_77983_a(
              "author", new NBTTagString("author", this.field_72574_e.field_71092_bJ));
          var4.func_77983_a(
              "title", new NBTTagString("title", var3.func_77978_p().func_74779_i("title")));
          var4.func_77983_a("pages", var3.func_77978_p().func_74761_m("pages"));
          var4.field_77993_c = Item.field_77823_bG.field_77779_bT;
        }
      } catch (Exception var13) {
        var13.printStackTrace();
      }
    } else {
      int var5;
      if ("MC|TrSel".equals(p_72501_1_.field_73630_a)) {
        try {
          var2 = new DataInputStream(new ByteArrayInputStream(p_72501_1_.field_73629_c));
          var5 = var2.readInt();
          Container var6 = this.field_72574_e.field_71070_bA;
          if (var6 instanceof ContainerMerchant) {
            ((ContainerMerchant) var6).func_75175_c(var5);
          }
        } catch (Exception var12) {
          var12.printStackTrace();
        }
      } else {
        String var8;
        int var15;
        if ("MC|AdvCdm".equals(p_72501_1_.field_73630_a)) {
          if (!this.field_72573_d.func_82356_Z()) {
            this.field_72574_e.func_70006_a(
                this.field_72574_e.func_70004_a("advMode.notEnabled", new Object[0]));
          } else if (this.field_72574_e.func_70003_b(2, "")
              && this.field_72574_e.field_71075_bZ.field_75098_d) {
            try {
              var2 = new DataInputStream(new ByteArrayInputStream(p_72501_1_.field_73629_c));
              var5 = var2.readInt();
              var15 = var2.readInt();
              int var7 = var2.readInt();
              var8 = Packet.func_73282_a(var2, 256);
              TileEntity var9 = this.field_72574_e.field_70170_p.func_72796_p(var5, var15, var7);
              if (var9 != null && var9 instanceof TileEntityCommandBlock) {
                ((TileEntityCommandBlock) var9).func_82352_b(var8);
                this.field_72574_e.field_70170_p.func_72845_h(var5, var15, var7);
                this.field_72574_e.func_70006_a("Command set: " + var8);
              }
            } catch (Exception var11) {
              var11.printStackTrace();
            }
          } else {
            this.field_72574_e.func_70006_a(
                this.field_72574_e.func_70004_a("advMode.notAllowed", new Object[0]));
          }
        } else if ("MC|Beacon".equals(p_72501_1_.field_73630_a)) {
          if (this.field_72574_e.field_71070_bA instanceof ContainerBeacon) {
            try {
              var2 = new DataInputStream(new ByteArrayInputStream(p_72501_1_.field_73629_c));
              var5 = var2.readInt();
              var15 = var2.readInt();
              ContainerBeacon var16 = (ContainerBeacon) this.field_72574_e.field_71070_bA;
              Slot var18 = var16.func_75139_a(0);
              if (var18.func_75216_d()) {
                var18.func_75209_a(1);
                TileEntityBeacon var19 = var16.func_82863_d();
                var19.func_82128_d(var5);
                var19.func_82127_e(var15);
                var19.func_70296_d();
              }
            } catch (Exception var10) {
              var10.printStackTrace();
            }
          }
        } else if ("MC|ItemName".equals(p_72501_1_.field_73630_a)
            && this.field_72574_e.field_71070_bA instanceof ContainerRepair) {
          ContainerRepair var17 = (ContainerRepair) this.field_72574_e.field_71070_bA;
          if (p_72501_1_.field_73629_c != null && p_72501_1_.field_73629_c.length >= 1) {
            var8 = ChatAllowedCharacters.func_71565_a(new String(p_72501_1_.field_73629_c));
            if (var8.length() <= 30) {
              var17.func_82850_a(var8);
            }
          } else {
            var17.func_82850_a("");
          }
        } else {
          ModLoader.serverCustomPayload(this, p_72501_1_);
        }
      }
    }
  }