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); } }
@Override public IItemStack withTag(IData tag) { ItemStack result = new ItemStack(stack.getItem(), stack.getCount(), stack.getItemDamage()); if (tag == null) { result.setTagCompound(null); } else { result.setTagCompound((NBTTagCompound) NBTConverter.from(tag)); } return new MCItemStack(result, tag); }
@Override public IItemStack withDamage(int damage) { if (stack.getItem().getHasSubtypes()) { MineTweakerAPI.logWarning("subitems don't have damaged states"); return this; } else { ItemStack result = new ItemStack(stack.getItem(), stack.getCount(), damage); result.setTagCompound(stack.getTagCompound()); return new MCItemStack(result, tag); } }
@Override public IItemStack removeTag(String tag) { ItemStack result = new ItemStack(stack.getItem(), stack.getCount(), stack.getItemDamage()); if (tag == null) { result.setTagCompound(null); } else { result.getTagCompound().removeTag(tag); } IData dataTag = NBTConverter.from(result.getTagCompound(), false); return new MCItemStack(result, dataTag); }
@Override public IIngredient anyDamage() { if (stack.getItem().getHasSubtypes()) { MineTweakerAPI.logWarning("subitems don't have damaged states"); return this; } else { ItemStack result = new ItemStack(stack.getItem(), stack.getCount(), OreDictionary.WILDCARD_VALUE); result.setTagCompound(stack.getTagCompound()); return new MCItemStack(result, tag); } }
@Override public IItemStack withAmount(int amount) { ItemStack result = new ItemStack(stack.getItem(), amount, stack.getItemDamage()); result.setTagCompound(stack.getTagCompound()); return new MCItemStack(result, tag); }
@Override public IItemStack anyAmount() { ItemStack result = new ItemStack(stack.getItem(), 1, stack.getItemDamage()); result.setTagCompound(stack.getTagCompound()); return new MCItemStack(result, tag, true); }