Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-99762

help command not working for commands and not throwing exceptions in command block

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • Minecraft 1.9.1 Pre-Release 3
    • Unconfirmed

      Caused by MC-69038

      The bug

      The /help command is not correctly working anymore in command blocks. For example /help -2 is not throwing a NumberInvalidException exception and /help testfor is not showing the help for the /testfor command.

      The reason

      The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.

      The reason why this happens is because the method net.minecraft.command.CommandHelp.execute(MinecraftServer, ICommandSender, String[]) does not try to parse any of the arguments if the sender is a command block.

      /**
       * Callback for when the command is executed
       *  
       * @param server The Minecraft server instance
       * @param sender The source of the command invocation
       * @param args The arguments that were passed
       */
      public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
      {
          // Replaced the old code
          //if (sender instanceof CommandBlockBaseLogic)
          //{
          //    sender.addChatMessage((new TextComponentString("Searge says: ")).appendText(seargeSays[this.rand.nextInt(seargeSays.length) % seargeSays.length]));
          //}
          //else
          //{
              //...
          //}
          
          List<ICommand> list = this.func_184900_a(sender, server);
          int i = 7;
          int j = (list.size() - 1) / 7;
          int k = 0;
      
          try
          {
              k = args.length == 0 ? 0 : parseInt(args[0], 1, j + 1) - 1;
          }
          catch (NumberInvalidException numberinvalidexception)
          {
              Map<String, ICommand> map = this.func_184899_a(server);
              ICommand icommand = (ICommand)map.get(args[0]);
      
              if (icommand != null)
              {
                  throw new WrongUsageException(icommand.getCommandUsage(sender), new Object[0]);
              }
      
              if (MathHelper.parseIntWithDefault(args[0], -1) != -1)
              {
                  throw numberinvalidexception;
              }
      
              throw new CommandNotFoundException();
          }
           
          if (sender instanceof CommandBlockBaseLogic)
          {
              sender.addChatMessage((new TextComponentString("Searge says: ")).appendText(seargeSays[this.rand.nextInt(seargeSays.length) % seargeSays.length]));
              return;
          }
          else {
             //...
          }
      }
      

            Unassigned Unassigned
            marcono1234 Marcono1234
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: