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);
    }
  }
Beispiel #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();
      }
    }
  }