@Override
 protected boolean set(ItemStack dataHolder, FluidStackSnapshot value) {
   FluidType fluidType = value.getFluid();
   if (fluidType == FluidTypes.WATER) {
     dataHolder.setItem(Items.water_bucket);
     return true;
   } else if (fluidType == FluidTypes.LAVA) {
     dataHolder.setItem(Items.lava_bucket);
     return true;
   } else {
     return false;
   }
 }
 @Override
 public DataTransactionResult removeFrom(ValueContainer<?> container) {
   if (container instanceof ItemStack) {
     final ItemStack itemStack = (ItemStack) container;
     if (itemStack.getItem() == Items.water_bucket) {
       itemStack.setItem(Items.bucket);
       return DataTransactionResult.successRemove(constructImmutableValue(WATER));
     } else if (itemStack.getItem() == Items.lava_bucket) {
       itemStack.setItem(Items.bucket);
       return DataTransactionResult.successRemove(constructImmutableValue(LAVA));
     }
   }
   return DataTransactionResult.failNoData();
 }
  /** Process the contents of this packet */
  public void handle(NetHandlerPlayServer handler) {
    PacketThreadUtil.processPacket(this, handler, handler.playerEntity.getWorldForPlayer());
    PacketBuffer var2;
    ItemStack var3;
    ItemStack var4;

    if ("MC|BEdit".equals(this.channel)) {
      var2 = new PacketBuffer(Unpooled.wrappedBuffer(this.data));

      try {
        var3 = var2.readItemStackFromBuffer();

        if (var3 == null) return;

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

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

        if (var4 != null) {
          if (var3.getItem() == Items.writable_book && var3.getItem() == var4.getItem()) {
            var4.setTagInfo("pages", var3.getTagCompound().getTagList("pages", 8));
          }
        }
      } catch (Exception ignored) {
      } finally {
        var2.release();
      }

    } else if ("MC|BSign".equals(this.channel)) {
      var2 = new PacketBuffer(Unpooled.wrappedBuffer(this.data));

      try {
        var3 = var2.readItemStackFromBuffer();

        if (var3 == null) {
          return;
        }

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

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

        if (var4 != null) {
          if (var3.getItem() == Items.written_book && var4.getItem() == Items.writable_book) {
            var4.setTagInfo("author", new NBTTagString(handler.playerEntity.getName()));
            var4.setTagInfo("title", new NBTTagString(var3.getTagCompound().getString("title")));
            var4.setTagInfo("pages", var3.getTagCompound().getTagList("pages", 8));
            var4.setItem(Items.written_book);
          }
        }
      } catch (Exception ignored) {
      } finally {
        var2.release();
      }
    } else if ("MC|TrSel".equals(this.channel)) {
      try {
        int var40 = this.data.readInt();
        Container container = handler.playerEntity.openContainer;

        if (container instanceof ContainerMerchant) {
          ((ContainerMerchant) container).setCurrentRecipeIndex(var40);
        }
      } catch (Exception ignored) {
      }
    } else if ("MC|AdvCdm".equals(this.channel)) {
      if (!handler.serverController.isCommandBlockEnabled()) {
        handler.playerEntity.addChatMessage(new FormattedTextTranslation("advMode.notEnabled"));
      } else if (handler.playerEntity.canCommandSenderUseCommand(2, "")
          && handler.playerEntity.capabilities.isCreativeMode) {
        var2 = this.data;

        try {
          byte var43 = var2.readByte();
          CommandBlockLogic var46 = null;

          if (var43 == 0) {
            var46 =
                $.bind(
                    handler.playerEntity.world.getTileEntity(
                        new BlockPos(var2.readInt(), var2.readInt(), var2.readInt()),
                        TileEntityCommandBlock.class),
                    TileEntityCommandBlock::getCommandBlockLogic);
          } else if (var43 == 1) {
            var46 =
                $.bind(
                    handler.playerEntity.world.getEntityByID(
                        var2.readInt(), EntityMinecartCommandBlock.class),
                    EntityMinecartCommandBlock::getCommandBlockLogic);
          }

          String var49 = var2.readString(var2.readableBytes());
          boolean var6 = var2.readBoolean();

          if (var46 != null) {
            var46.setCommand(var49);
            var46.setCommandFeedback(var6);

            if (!var6) {
              var46.func_145750_b(null);
            }

            var46.markForUpdate();
            handler.playerEntity.addChatMessage(
                new FormattedTextTranslation("advMode.setCommand.success", var49));
          }
        } catch (Exception ignored) {
        } finally {
          var2.release();
        }
      } else {
        handler.playerEntity.addChatMessage(new FormattedTextTranslation("advMode.notAllowed"));
      }
    } else if ("MC|Beacon".equals(this.channel)) {
      if (handler.playerEntity.openContainer instanceof ContainerBeacon) {
        try {
          var2 = this.data;
          int var44 = var2.readInt();
          int var47 = var2.readInt();
          ContainerBeacon var50 = (ContainerBeacon) handler.playerEntity.openContainer;
          Slot var51 = var50.getSlot(0);

          if (var51.hasStack()) {
            var51.decreaseStackSize(1);
            IInventory var7 = var50.getTileEntity();
            var7.setField(1, var44);
            var7.setField(2, var47);
            var7.markDirty();
          }
        } catch (Exception ignored) {
        }
      }
    } else if ("MC|ItemName".equals(this.channel)
        && handler.playerEntity.openContainer instanceof ContainerAnvil) {
      ContainerAnvil container = (ContainerAnvil) handler.playerEntity.openContainer;

      if (this.data != null && this.data.readableBytes() >= 1) {
        String data = ChatAllowedCharacters.filterAllowedCharacters(this.data.readString(32767));

        if (data.length() <= 30) {
          container.updateItemName(data);
        }
      } else {
        container.updateItemName("");
      }
    }
  }